[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
This commit is contained in:
parent
ed4a891e82
commit
8d28fc5a61
32
setup.py
32
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:
|
||||
|
|
Loading…
Reference in New Issue