Fix the remaing issues with comparisons with objects of different types.

In python it is possible to compare tuples with a lexicographic order.

Take advantage of that since there is no need to resort to the C-trick of converting a version in hex format.

We need to set a dummy version in case we are using ImageMagick to ensure that version is always an integer 3-tuple.
This commit is contained in:
José Matos 2019-06-03 19:07:20 +01:00
parent a8937b53ec
commit 639b5da1af

View File

@ -50,7 +50,7 @@ if version != None:
major = int(version.group(1))
minor = int(version.group(2))
patch = int(version.group(3))
version = hex(major * 65536 + minor * 256 + patch)
version = (major, minor, patch)
im = True
else:
# Try GraphicsMagick
@ -58,6 +58,8 @@ else:
version = re_version.match(output)
if version != None:
gm = True
# we need version to be a valid integer 3-tuple
version = (1,0,0)
# IM >= 5.5.8 separates options for source and target files
# See http://www.imagemagick.org/Usage/basics/#why
@ -68,11 +70,11 @@ elif sys.platform == 'darwin':
command = 'lyxconvert'
# If supported, add the -define option for pdf source formats
if sys.argv[1] == 'pdf' and (version >= 0x060206 or gm):
if sys.argv[1] == 'pdf' and (version >= (6,2,6) or gm):
sopts = '-define pdf:use-cropbox=true ' + sopts
# If supported, add the -flatten option for ppm target formats (see bug 4749)
if sys.argv[3] == 'ppm' and (im and version >= "0x060305" or gm):
if sys.argv[3] == 'ppm' and (im and version >= (6,3,5) or gm):
topts = '-flatten'
# print (command, sys.argv[2], sys.argv[4], file= sys.stdout)