diff options
author | Jean-Francois Dockes <jf@dockes.org> | 2018-03-08 17:50:55 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-19 17:45:47 +0100 |
commit | 3401d913449a4b031094f7ad2420994d99cd1d7a (patch) | |
tree | 57fcb848ac942615ce3481df956b499f053f0a1c /msodumper/wmfrecord.py | |
parent | c99d5a22f9dfebd595308d9dc5f20112674a3b8c (diff) |
Port to Python3.
Compatible with Python 2.7, with an added dependancy on the 'future' module.
Main modifications:
- Change the 'import' statements to package-relative
- dic.has_key()->key in dic
- xrange() -> future.builtins.range() (py2) / range (py3)
- Convert print statements to method calls
- Fix exception statements: except Error, err -> except Error as err
- StringIO.StringIO -> io.BytesIO
- Change explicit unicode() constructors to somebytes.decode(), and other
uses of the unicode type.
- Fix indexing into bytes (bytes[i] -> byte string of length 1 in py2, int in
py3), ord(), chr() calls.
- Fix output functions to generally accept both bytes() and str() because
both types are still used by the parser outputs. Make sure they work the
same when piped.
- Fix comparisons between bytes and strings (dirname == "Workbook" ->
dirname == b"Workbook")
- Use explicit integer division in many places / -> //
- Deal with long ints being gone (0L is a syntax error)
Change-Id: Ife0b6f9fa8ab4c95ba203013b894a67c85c8e0ad
Reviewed-on: https://gerrit.libreoffice.org/50967
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'msodumper/wmfrecord.py')
-rw-r--r-- | msodumper/wmfrecord.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/msodumper/wmfrecord.py b/msodumper/wmfrecord.py index d318bc4..85a8bac 100644 --- a/msodumper/wmfrecord.py +++ b/msodumper/wmfrecord.py @@ -5,7 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -from binarystream import BinaryStream +from .binarystream import BinaryStream # The BrushStyle Enumeration specifies the different possible brush types that can be used in graphics operations. @@ -313,12 +313,12 @@ class RectL(WMFRecord): self.name = "rectL" def dump(self): - print '<%s type="RectL">' % self.name + print('<%s type="RectL">' % self.name) self.printAndSet("Left", self.readInt32(), hexdump=False) self.printAndSet("Top", self.readInt32(), hexdump=False) self.printAndSet("Right", self.readInt32(), hexdump=False) self.printAndSet("Bottom", self.readInt32(), hexdump=False) - print '</%s>' % self.name + print('</%s>' % self.name) self.parent.pos = self.pos @@ -332,10 +332,10 @@ class SizeL(WMFRecord): self.name = "sizeL" def dump(self): - print '<%s type="SizeL">' % self.name + print('<%s type="SizeL">' % self.name) self.printAndSet("cx", self.readuInt32(), hexdump=False) self.printAndSet("cy", self.readuInt32(), hexdump=False) - print '</%s>' % self.name + print('</%s>' % self.name) self.parent.pos = self.pos @@ -349,10 +349,10 @@ class PointL(WMFRecord): self.name = "pointL" def dump(self): - print '<%s type="PointL">' % self.name + print('<%s type="PointL">' % self.name) self.printAndSet("x", self.readInt32(), hexdump=False) self.printAndSet("y", self.readInt32(), hexdump=False) - print '</%s>' % self.name + print('</%s>' % self.name) self.parent.pos = self.pos @@ -363,10 +363,10 @@ class PointS(WMFRecord): self.name = name def dump(self): - print '<%s type="PointS">' % self.name + print('<%s type="PointS">' % self.name) self.printAndSet("x", self.readInt16(), hexdump=False) self.printAndSet("y", self.readInt16(), hexdump=False) - print '</%s>' % self.name + print('</%s>' % self.name) self.parent.pos = self.pos @@ -377,12 +377,12 @@ class ColorRef(WMFRecord): self.name = name def dump(self): - print '<%s type="ColorRef">' % self.name + print('<%s type="ColorRef">' % self.name) self.printAndSet("Red", self.readuInt8(), hexdump=False) self.printAndSet("Green", self.readuInt8(), hexdump=False) self.printAndSet("Blue", self.readuInt8(), hexdump=False) self.printAndSet("Reserved", self.readuInt8(), hexdump=False) - print '</%s>' % self.name + print('</%s>' % self.name) self.parent.pos = self.pos # vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab: |