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 /vsd-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 'vsd-dump.py')
-rwxr-xr-x | vsd-dump.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/vsd-dump.py b/vsd-dump.py index 0ec0e7b..f7d5bd3 100755 --- a/vsd-dump.py +++ b/vsd-dump.py @@ -21,12 +21,12 @@ class VSDDumper: strm = vsdstream.createVSDFile(file.read(), self.params) file.close() dirnames = strm.getDirectoryNames() - print '<?xml version="1.0"?>\n<streams ole-type="%s">' % strm.getName() + print('<?xml version="1.0"?>\n<streams ole-type="%s">' % strm.getName()) if strm.error: - print '<error what="%s"/>' % strm.error + print('<error what="%s"/>' % strm.error) for dirname in dirnames: strm.getDirectoryStreamByName(dirname).dump() - print '</streams>' + print('</streams>') def main(args): @@ -34,6 +34,7 @@ def main(args): dumper = VSDDumper(args[1], params) dumper.dump() + if __name__ == '__main__': main(sys.argv) |