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

-- 
José Abílio
Index: lyxpreview_tools.py
===================================================================
--- lyxpreview_tools.py	(revision 15105)
+++ lyxpreview_tools.py	(working copy)
@@ -16,6 +16,21 @@
 
 import os, re, string, sys, tempfile
 
+# compatibility with python 2.2
+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
+# end compatibility chunk
+
 use_win32_modules = 0
 if os.name == "nt":
     use_win32_modules = 1
Index: fig_copy.py
===================================================================
--- fig_copy.py	(revision 15105)
+++ fig_copy.py	(working copy)
@@ -20,6 +20,21 @@
 
 import os, sys
 
+# compatibility with python 2.2
+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
+# end compatibility chunk
+
 if len(sys.argv) != 3:
     print >> sys.stderr, "Usage: fig_copy.py <from file> <to file>"
     sys.exit(1)
Index: TeXFiles.py
===================================================================
--- TeXFiles.py	(revision 15105)
+++ TeXFiles.py	(working copy)
@@ -40,6 +40,56 @@
 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
+
+    from __future__ import generators
+
+    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

Reply via email to