add (and use) method tools.oswalksymlinks

bzr revid: christophe@tinyerp.com-20080904235001-3ix8x19mcdobihwo
This commit is contained in:
Christophe Simonis 2008-09-05 01:50:01 +02:00
parent e1c774f5db
commit 6fbedbf2e5
2 changed files with 17 additions and 1 deletions

View File

@ -256,6 +256,22 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False):
raise IOError, 'File not found : '+str(name)
def oswalksymlinks(top, topdown=True, onerror=None):
"""
same as os.walk but follow symlinks
"""
for dirpath, dirnames, filenames in os.walk(top, topdown, onerror):
symlinks = filter(lambda dirname: os.path.islink(os.path.join(dirpath, dirname)), dirnames)
if not topdown:
for s in symlinks:
for x in oswalksymlinks(os.path.join(dirpath, s), topdown, onerror):
yield x
yield dirpath, dirnames, filenames
if topdown:
for s in symlinks:
for x in oswalksymlinks(os.path.join(dirpath, s), topdown, onerror):
yield x
#----------------------------------------------------------
# iterables
#----------------------------------------------------------

View File

@ -442,7 +442,7 @@ def trans_generate(lang, modules, dbname=None):
return 'base' # files that are not in a module are considered as being in 'base' module
modobj = pool.get('ir.module.module')
for root, dirs, files in os.walk(tools.config['root_path']):
for root, dirs, files in tools.oswalksymlinks(tools.config['root_path']):
for fname in fnmatch.filter(files, '*.py'):
fabsolutepath = join(root, fname)
frelativepath = fabsolutepath[len(tools.config['root_path'])+1:]