summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJulien Thewys <jth@openerp.com>2010-09-20 15:28:45 +0200
committerJulien Thewys <jth@openerp.com>2010-09-20 15:28:45 +0200
commit8d28fc5a617b9e27e64976a0116ea30e94258c1c (patch)
tree582f95d3f936777a152332bc1a393dfc0866da0a /setup.py
parented4a891e82f7aca10c965f97b63f88ec5331295f (diff)
[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
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py32
1 files changed, 32 insertions, 0 deletions
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: