Fix compatibility with python 2.2.x

* lib/configure.py:
	Add compatibility code for booleans and use True and False
	instead of 'true' and 'false'

	* lib/scripts/lyxpreview_tools.py:
	* lib/scripts/fig_copy.py:
	* lib/scripts/TeXFiles.py:
	Fix typo and make code compatible also with python versions
	greater than 2.2.0


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15947 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2006-11-16 10:23:34 +00:00
parent 0f641c9a84
commit 0698a90dd4
5 changed files with 41 additions and 16 deletions

View File

@ -1,3 +1,13 @@
2006-11-16 Enrico Forestieri <forenr@tlc.unipr.it>
* lib/configure.py: add compatibility code for booleans and use
True and False instead of 'true' and 'false'.
* lib/scripts/lyxpreview_tools.py:
* lib/scripts/fig_copy.py:
* lib/scripts/TeXFiles.py: fix typo and make code compatible also
with python versions greater than 2.2.0
2006-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* bind/menus.bind: digits may need the shift modifier (on french

View File

@ -12,6 +12,21 @@
import sys, os, re, shutil, glob
# compatibility with python 2.2
if sys.version_info[:2] == (2, 2):
__builtins__.True = (1 == 1)
__builtins__.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
__builtins__.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 "" "" ""')
#

View File

@ -49,9 +49,9 @@ bib_files = 'bibFiles.lst'
try:
os.walk
except AttributeError:
if sys.version_info[:3] == (2, 2, 0):
__builtin__.True = (1 == 1)
__builtin__.False = (1 == 0)
if sys.version_info[:2] == (2, 2):
__builtins__.True = (1 == 1)
__builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@ -59,7 +59,7 @@ except AttributeError:
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
__builtin__.bool = bool
__builtins__.bool = bool
del bool
def walk(top, topdown=True, onerror=None):

View File

@ -21,9 +21,9 @@
import os, sys
# compatibility with python 2.2
if sys.version_info[:3] == (2, 2, 0):
__builtin__.True = (1 == 1)
__builtin__.False = (1 == 0)
if sys.version_info[:2] == (2, 2):
__builtins__.True = (1 == 1)
__builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@ -31,7 +31,7 @@ if sys.version_info[:3] == (2, 2, 0):
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
__builtin__.bool = bool
__builtins__.bool = bool
del bool
# end compatibility chunk

View File

@ -17,9 +17,9 @@
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)
if sys.version_info[:2] == (2, 2):
__builtins__.True = (1 == 1)
__builtins__.False = (1 == 0)
def bool(value):
"""Demote a value to 0 or 1, depending on its truth value
@ -27,7 +27,7 @@ if sys.version_info[:3] == (2, 2, 0):
way too hard to duplicate in 2.1 to be worth the trouble.
"""
return not not value
__builtin__.bool = bool
__builtins__.bool = bool
del bool
# end compatibility chunk