fix autopath bug introduced with path refactoring
--HG-- branch : trunk
This commit is contained in:
parent
5118821c10
commit
046ac957ab
|
@ -1,14 +1,13 @@
|
||||||
import os, sys
|
import os, sys
|
||||||
from py.path import local
|
from py.path import local
|
||||||
|
|
||||||
def autopath(globs=None, basefile='__init__.py'):
|
def autopath(globs=None):
|
||||||
""" return the (local) path of the "current" file pointed to by globals
|
""" return the (local) path of the "current" file pointed to by globals
|
||||||
or - if it is none - alternatively the callers frame 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 always point to a .py file or to None.
|
||||||
the path will have the following payload:
|
the path will have the following payload:
|
||||||
pkgdir is the last parent directory path containing 'basefile'
|
pkgdir is the last parent directory path containing __init__.py
|
||||||
starting backwards from the current file.
|
|
||||||
"""
|
"""
|
||||||
if globs is None:
|
if globs is None:
|
||||||
globs = sys._getframe(1).f_globals
|
globs = sys._getframe(1).f_globals
|
||||||
|
@ -24,7 +23,7 @@ def autopath(globs=None, basefile='__init__.py'):
|
||||||
ret = ret.new(ext='.py')
|
ret = ret.new(ext='.py')
|
||||||
current = pkgdir = ret.dirpath()
|
current = pkgdir = ret.dirpath()
|
||||||
while 1:
|
while 1:
|
||||||
if basefile in current.listdir():
|
if current.join('__init__.py').check():
|
||||||
pkgdir = current
|
pkgdir = current
|
||||||
current = current.dirpath()
|
current = current.dirpath()
|
||||||
if pkgdir != current:
|
if pkgdir != current:
|
||||||
|
|
Loading…
Reference in New Issue