From 046ac957ab5b6671b13bd30196aac20a1d0dd042 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 21 Aug 2009 12:09:23 +0200 Subject: [PATCH] fix autopath bug introduced with path refactoring --HG-- branch : trunk --- py/magic/autopath.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/py/magic/autopath.py b/py/magic/autopath.py index f26521651..78bbafebe 100644 --- a/py/magic/autopath.py +++ b/py/magic/autopath.py @@ -1,14 +1,13 @@ import os, sys 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 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. + pkgdir is the last parent directory path containing __init__.py """ if globs is None: globs = sys._getframe(1).f_globals @@ -24,7 +23,7 @@ def autopath(globs=None, basefile='__init__.py'): ret = ret.new(ext='.py') current = pkgdir = ret.dirpath() while 1: - if basefile in current.listdir(): + if current.join('__init__.py').check(): pkgdir = current current = current.dirpath() if pkgdir != current: