José Matos wrote:
On Thursday 21 September 2006 23:26, José Matos wrote:
The second patch fixes the issues I have found in scripts. It
should work now.
OK, that should not work. I send another patch...
FWIW the only difference is the addition of one line
from __future__ import generators
Hi José,
I've tested the patched version of TeXFiles.py and python tells me
that "from __future__ import generators" must be placed at the beginning
of the file.
So I send you the version which is working for me...
Thank you,
Stephan
--------------------------
Index: TeXFiles.py
===================================================================
--- TeXFiles.py (Revision 15093)
+++ TeXFiles.py (Arbeitskopie)
@@ -33,6 +33,8 @@
# relies on python and kpsewhich (no shell command is used).
#
+from __future__ import generators
+
import os, sys, re
cls_stylefile = 'clsFiles.lst'
@@ -40,6 +42,54 @@
bst_stylefile = 'bstFiles.lst'
bib_files = 'bibFiles.lst'
+# this code was taken from twisted
+#
http://twistedmatrix.com/trac/browser/trunk/twisted/python/compat.py?rev=14178&format=txt
+# and allow us to use os.walk with python 2.2
+try:
+ os.walk
+except AttributeError:
+ if sys.version_info[:3] == (2, 2, 0):
+ __builtin__.True = (1 == 1)
+ __builtin__.False = (1 == 0)
+ def bool(value):
+ """Demote a value to 0 or 1, depending on its truth value
+
+ This is not to be confused with types.BooleanType, which is
+ way too hard to duplicate in 2.1 to be worth the trouble.
+ """
+ return not not value
+ __builtin__.bool = bool
+ del bool
+
+ 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
+# end compatibility chunk
+
def cmdOutput(cmd):
'''utility function: run a command and get its output as a string
cmd: command to run