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 /emf-dump.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 'emf-dump.py')
-rwxr-xr-x | emf-dump.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/emf-dump.py b/emf-dump.py index 2b12b06..c40f101 100755 --- a/emf-dump.py +++ b/emf-dump.py @@ -19,7 +19,7 @@ class EMFDumper: file = open(self.filepath, 'rb') strm = emfrecord.EMFStream(file.read()) file.close() - print '<?xml version="1.0"?>' + print('<?xml version="1.0"?>') strm.dump() @@ -27,6 +27,7 @@ def main(args): dumper = EMFDumper(args[1]) dumper.dump() + if __name__ == '__main__': main(sys.argv) |