From 8d28fc5a617b9e27e64976a0116ea30e94258c1c Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Mon, 20 Sep 2010 15:28:45 +0200 Subject: [PATCH] [FIX] Backported os.walk with followlinks from python 2.6 to make setup.py compatible with 2.5 bzr revid: jth@openerp.com-20100920132845-aanmyzcsrsd0acqh --- setup.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/setup.py b/setup.py index ec083fbde4e..8831e6f8da6 100755 --- a/setup.py +++ b/setup.py @@ -51,6 +51,38 @@ if 'bdist_rpm' in sys.argv: # get python short version py_short_version = '%s.%s' % sys.version_info[:2] +# backports os.walk with followlinks from python 2.6 +def walk_followlinks(top, topdown=True, onerror=None, followlinks=False): + from os.path import join, isdir, islink + from os import listdir, error + + try: + names = listdir(top) + except error, err: + if onerror is not None: + onerror(err) + return + + dirs, nondirs = [], [] + for name in names: + if isdir(join(top, name)): + dirs.append(name) + else: + nondirs.append(name) + + if topdown: + yield top, dirs, nondirs + for name in dirs: + path = join(top, name) + if followlinks or not islink(path): + for x in walk_followlinks(path, topdown, onerror, followlinks): + yield x + if not topdown: + yield top, dirs, nondirs + +if sys.version_info < (2, 6): + os.walk = walk_followlinks + def find_addons(): for root, _, names in os.walk(join('bin', 'addons'), followlinks=True): if '__openerp__.py' in names or '__terp__.py' in names: