On Tue, Nov 14, 2006 at 11:18:47PM +0000, José Matos wrote:
> On Tuesday 14 November 2006 6:05 pm, Enrico Forestieri wrote:
> > >
> > > I should prepare a patch for 1.4.
> >
> > I could do it, if you don't mind.
>
> Thank you, go ahead. :-)
Patch attached. Jean-Marc, can this go in?
(this time I tested it on both Windows and Unix :)
--
Enrico
Log:
Fix compatibility with python 2.2.x
* lib/configure.py:
Add compatibility code for booleans and use True and False
* lib/scripts/lyxpreview_tools.py
* lib/scripts/fig_copy.py
* lib/scripts/TeXFiles.py:
Make code compatible also with python versions greater than 2.2.0
Index: lib/scripts/lyxpreview_tools.py
===================================================================
--- lib/scripts/lyxpreview_tools.py (revision 15931)
+++ lib/scripts/lyxpreview_tools.py (working copy)
@@ -17,7 +17,7 @@
import os, re, string, sys, tempfile
# compatibility with python 2.2
-if sys.version_info[:3] == (2, 2, 0):
+if sys.version_info[:2] == (2, 2):
__builtin__.True = (1 == 1)
__builtin__.False = (1 == 0)
def bool(value):
Index: lib/scripts/fig_copy.py
===================================================================
--- lib/scripts/fig_copy.py (revision 15931)
+++ lib/scripts/fig_copy.py (working copy)
@@ -21,7 +21,7 @@
import os, sys
# compatibility with python 2.2
-if sys.version_info[:3] == (2, 2, 0):
+if sys.version_info[:2] == (2, 2):
__builtin__.True = (1 == 1)
__builtin__.False = (1 == 0)
def bool(value):
Index: lib/scripts/TeXFiles.py
===================================================================
--- lib/scripts/TeXFiles.py (revision 15931)
+++ lib/scripts/TeXFiles.py (working copy)
@@ -49,7 +49,7 @@ bib_files = 'bibFiles.lst'
try:
os.walk
except AttributeError:
- if sys.version_info[:3] == (2, 2, 0):
+ if sys.version_info[:2] == (2, 2):
__builtin__.True = (1 == 1)
__builtin__.False = (1 == 0)
def bool(value):
Index: lib/configure.py
===================================================================
--- lib/configure.py (revision 15931)
+++ lib/configure.py (working copy)
@@ -12,6 +12,21 @@
import sys, os, re, shutil, glob
+# compatibility with python 2.2
+if sys.version_info[:2] == (2, 2):
+ __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
+
class Tee:
''' Writing to a Tee object will write to all file objects it keeps.
@@ -185,15 +200,15 @@ def checkDTLtools():
if ((os.name == 'nt' or sys.platform == 'cygwin') and
checkProg('DVI to DTL converter', ['dv2dt']) != ['', ''] and
checkProg('DTL to DVI converter', ['dt2dv']) != ['', '']):
- dtl_tools = 'true'
+ dtl_tools = True
else:
- dtl_tools = 'false'
+ dtl_tools = False
return dtl_tools
def checkLatex(dtl_tools):
''' Check latex, return lyx_check_config '''
- if (dtl_tools == 'true'):
+ if dtl_tools:
# Windows only: DraftDVI
converter_entry = r'''\converter latex dvi2 "%%" "latex"
\converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o"
""'''
@@ -280,7 +295,7 @@ def checkFormatEntries(dtl_tools):
#
checkViewer('a DVI previewer', ['xdvi', 'kdvi'],
rc_entry = [r'\Format dvi dvi DVI D
"%%" ""'])
- if (dtl_tools == 'true'):
+ if dtl_tools:
# Windows only: DraftDVI
addToRC(r'\Format dvi2 dvi DraftDVI "" ""
""')
#