function: magic.autopath

 return the (local) path of the "current" file pointed to by globals
        or - if it is none - alternatively the callers frame globals.

        the path will always point to a .py file  or to None.
        the path will have the following payload:
        pkgdir   is the last parent directory path containing 'basefile'
                 starting backwards from the current file.
    
def autopath(globs=None, basefile='__init__.py'):

origin:<UNKNOWN>

where:

exceptions that might appear during execution:

function source:

def autopath(globs=None, basefile='__init__.py'):
    """ return the (local) path of the "current" file pointed to by globals
        or - if it is none - alternatively the callers frame globals.

        the path will always point to a .py file  or to None.
        the path will have the following payload:
        pkgdir   is the last parent directory path containing 'basefile'
                 starting backwards from the current file.
    """
    if globs is None:
        globs = sys._getframe(1).f_globals
    try:
        __file__ = globs['__file__']
    except KeyError:
        if not sys.argv[0]:
            raise ValueError, "cannot compute autopath in interactive mode"
        __file__ = os.path.abspath(sys.argv[0])

    custom__file__ = isinstance(__file__, PathStr)
    if custom__file__:
        ret = __file__.__path__
    else:
        ret = local(__file__)
        if ret.ext in ('.pyc', '.pyo'):
            ret = ret.new(ext='.py')
    current = pkgdir = ret.dirpath()
    while 1:
        if basefile in current:
            pkgdir = current
            current = current.dirpath()
            if pkgdir != current:
                continue
        elif not custom__file__ and str(current) not in sys.path:
            sys.path.insert(0, str(current))
        break
    ret.pkgdir = pkgdir
    return ret

call sites:

called in <string>

traceback magic.autopath.0

called in /home/johnny/projects/merlinux/py/dist/py/path/svn/testing/svntestbase.py

traceback magic.autopath.1

called in <string>

traceback magic.autopath.2

called in /home/johnny/projects/merlinux/py/dist/py/path/extpy/testing/test_extpy.py

traceback magic.autopath.3

called in /home/johnny/projects/merlinux/py/dist/py/misc/testing/test_svnlook.py

traceback magic.autopath.4

called in <string>

traceback magic.autopath.5

called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/test_htmlrest.py

traceback magic.autopath.6

called in <string>

traceback magic.autopath.7

called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/test_directive.py

traceback magic.autopath.8

called in <string>

traceback magic.autopath.9

called in /home/johnny/projects/merlinux/py/dist/py/test/testing/test_session.py

traceback magic.autopath.10

called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/test_rst2pdf.py

traceback magic.autopath.11

called in <string>

traceback magic.autopath.12

called in /home/johnny/projects/merlinux/pypy-dist/pypy/config/pypyoption.py

traceback magic.autopath.13

called in <string>

traceback magic.autopath.14

called in <string>

traceback magic.autopath.15

called in /home/johnny/projects/merlinux/py/dist/py/documentation/test_conftest.py

traceback magic.autopath.16

called in /home/johnny/projects/merlinux/py/dist/py/rest/testing/test_convert.py

traceback magic.autopath.17

called in /home/johnny/projects/merlinux/py/dist/py/documentation/test_conftest.py

traceback magic.autopath.18

called in /home/johnny/projects/merlinux/pypy-dist/pypy/conftest.py

traceback magic.autopath.19

called in /home/johnny/projects/merlinux/py/dist/py/test/testing/test_collect.py

traceback magic.autopath.20