def normalize_modpath(modpath, hide_init=True, hide_main=False):
if six.PY2:<EOL><INDENT>if modpath.endswith('<STR_LIT>'):<EOL><INDENT>modpath = modpath[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>if hide_init:<EOL><INDENT>if basename(modpath) == '<STR_LIT>':<EOL><INDENT>modpath = dirname(modpath)<EOL>hide_main = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>modpath_with_init = join(modpath, '<STR_LIT>')<EOL>if exists(modpath_with_init):<EOL><INDENT>modpath = modpath_with_init<EOL><DEDENT><DEDENT>if hide_main:<EOL><INDENT>if basename(modpath) == '<STR_LIT>':<EOL><INDENT>parallel_init = join(dirname(modpath), '<STR_LIT>')<EOL>if exists(parallel_init):<EOL><INDENT>modpath = dirname(modpath)<EOL><DEDENT><DEDENT><DEDENT>return modpath<EOL>
Normalizes __init__ and __main__ paths.

Notes:
    Adds __init__ if reasonable, but only removes __main__ by default

Args:
    hide_init (bool): if True, always return package modules
       as __init__.py files otherwise always return the dpath.
    hide_init (bool): if True, always strip away main files otherwise
       ignore __main__.py.

CommandLine:
    xdoctest -m xdoctest.static_analysis normalize_modpath

Example:
    >>> import xdoctest.static_analysis as static
    >>> modpath = static.__file__
    >>> assert static.normalize_modpath(modpath) == modpath.replace('.pyc', '.py')
    >>> dpath = dirname(modpath)
    >>> res0 = static.normalize_modpath(dpath, hide_init=0, hide_main=0)
    >>> res1 = static.normalize_modpath(dpath, hide_init=0, hide_main=1)
    >>> res2 = static.normalize_modpath(dpath, hide_init=1, hide_main=0)
    >>> res3 = static.normalize_modpath(dpath, hide_init=1, hide_main=1)
    >>> assert res0.endswith('__init__.py')
    >>> assert res1.endswith('__init__.py')
    >>> assert not res2.endswith('.py')
    >>> assert not res3.endswith('.py')