On Thursday 21 September 2006 10:08, Stephan Witt wrote: > I've just detected another phyton problem. > The script lib/scripts/TeXFiles.py failed with > > Indexing files of type cls > Traceback (most recent call last): > File "/home/witt/src/lyx/lyx-1.4.x/lib/scripts/TeXFiles.py", line 110, > in ? for root,path,files in os.walk(dir): > AttributeError: 'module' object has no attribute 'walk' > Menu warning: menu entries "Einstellungen...|i" and "TeX Information|I" > share the same shortcut. > Indexing files of type cls > Traceback (most recent call last): > File "/home/witt/src/lyx/lyx-1.4.x/lib/scripts/TeXFiles.py", line 110, > in ? for root,path,files in os.walk(dir): > AttributeError: 'module' object has no attribute 'walk' > Indexing files of type cls > Traceback (most recent call last): > File "/home/witt/src/lyx/lyx-1.4.x/lib/scripts/TeXFiles.py", line 110, > in ? for root,path,files in os.walk(dir): > AttributeError: 'module' object has no attribute 'walk'
The right fix is to take some code from twisted, http://twistedmatrix.com/trac/browser/trunk/twisted/python/compat.py?rev=14178&format=txt And the code is: try: os.walk except AttributeError: def walk(top, topdown=True, onerror=None): from os.path import join, isdir, islink try: names = os.listdir(top) except OSError, e: if onerror is not None: onerror(err) return nondir, dir = [], [] nameLists = [nondir, dir] for name in names: nameLists[isdir(join(top, name))].append(name) if topdown: yield top, dir, nondir for name in dir: path = join(top, name) if not islink(path): for x in walk(path, topdown, onerror): yield x if not topdown: yield top, dir, nondir os.walk = walk So if os.walk is not defined we define it. Conversely, the right fix for configure.py is to define the missing functions, this implies that the code will be the same everywhere and it is easier to maintain. if sys.version_info[:3] in ((2, 2, 0), (2, 2, 1)): def lstrip(s, c=string.whitespace): while s and s[0] in c: s = s[1:] return s def rstrip(s, c=string.whitespace): while s and s[-1] in c: s = s[:-1] return s def strip(s, c=string.whitespace, l=lstrip, r=rstrip): return l(r(s, c), c) object.__setattr__(str, 'lstrip', lstrip) object.__setattr__(str, 'rstrip', rstrip) object.__setattr__(str, 'strip', strip) I am leaving now, I don't have time to commit this. I would need some time to guarantee that the code is correct, basically that we import the right modules in python 2.2. The decision is your Jean-Marc. -- José Abílio