Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread Stephan Witt

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=14178format=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


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread José Matos
On Friday 22 September 2006 07:59, Stephan Witt wrote:

 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.

  Argh, you are right. I did not test the code, because it would be a no-op to 
me. :-)

 So I send you the version which is working for me...

  Thank you.

 Thank you,

 Stephan

  If you have any trouble with python scripts please report. The fixes are 
easy in most cases.

  Jean-Marc can this go into 1.4.x?

  FWIW, the code works with python 2.3 so there is no need to change 1.5.x

-- 
José Abílio


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread Jean-Marc Lasgouttes
 José == José Matos [EMAIL PROTECTED] writes:

José   If you have any trouble with python scripts please report. The
José fixes are easy in most cases.

José   Jean-Marc can this go into 1.4.x?

José   FWIW, the code works with python 2.3 so there is no need to
José change 1.5.x

Yes, this is OK.

JMarc


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread José Matos
On Friday 22 September 2006 10:39, Jean-Marc Lasgouttes wrote:

 Yes, this is OK.

  It is in. :-)

  It is interesting to note that python 2.2.x is analog to our 1.1.x series. 
They have used the small number versions for bugfixing as well as to add 
small features.

  In 2.3.x they decided, as we did in 1.2.x, that this was more trouble than 
what it worth and so from then on there are no new features only bugfixes for 
small point releases.
  
 JMarc

-- 
José Abílio


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread Stephan Witt

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=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


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread José Matos
On Friday 22 September 2006 07:59, Stephan Witt wrote:
>
> 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.

  Argh, you are right. I did not test the code, because it would be a no-op to 
me. :-)

> So I send you the version which is working for me...

  Thank you.

> Thank you,
>
> Stephan

  If you have any trouble with python scripts please report. The fixes are 
easy in most cases.

  Jean-Marc can this go into 1.4.x?

  FWIW, the code works with python 2.3 so there is no need to change 1.5.x

-- 
José Abílio


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread Jean-Marc Lasgouttes
> "José" == José Matos <[EMAIL PROTECTED]> writes:

José>   If you have any trouble with python scripts please report. The
José> fixes are easy in most cases.

José>   Jean-Marc can this go into 1.4.x?

José>   FWIW, the code works with python 2.3 so there is no need to
José> change 1.5.x

Yes, this is OK.

JMarc


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-22 Thread José Matos
On Friday 22 September 2006 10:39, Jean-Marc Lasgouttes wrote:
>
> Yes, this is OK.

  It is in. :-)

  It is interesting to note that python 2.2.x is analog to our 1.1.x series. 
They have used the small number versions for bugfixing as well as to add 
small features.

  In 2.3.x they decided, as we did in 1.2.x, that this was more trouble than 
what it worth and so from then on there are no new features only bugfixes for 
small point releases.
  
> JMarc

-- 
José Abílio


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-21 Thread José Matos
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=14178format=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


Re: Patches to support python 2.2 in lyx 1.4.4

2006-09-21 Thread José Matos
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  "
 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=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