[Libreoffice-commits] mso-dumper.git: emf-dump.py test/emf test/wmf wmf-dump.py xls-dump.py

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 1 13:07:42 UTC 2021


 emf-dump.py      |   17 +++++++++++++----
 test/emf/test.py |    3 ++-
 test/wmf/test.py |    3 ++-
 wmf-dump.py      |   17 +++++++++++++----
 xls-dump.py      |    1 +
 5 files changed, 31 insertions(+), 10 deletions(-)

New commits:
commit 8de7672dde1a8c1a344f058ff2d3588675b1b94f
Author:     Hossein <hossein at libreoffice.org>
AuthorDate: Fri Oct 1 14:19:32 2021 +0200
Commit:     Hossein <hossein at libreoffice.org>
CommitDate: Fri Oct 1 15:07:23 2021 +0200

    Parameter checking support for emf and wmf dump
    
    Added parameter checking support for emf-dump.py and wmf-dump.py.
    Currently, there is only one parameter: -h for help
    
    Change-Id: I4d97df26c9d70262f4a0b6d217aae9f3294b8365
    Reviewed-on: https://gerrit.libreoffice.org/c/mso-dumper/+/122921
    Tested-by: Hossein <hossein at libreoffice.org>
    Reviewed-by: Hossein <hossein at libreoffice.org>

diff --git a/emf-dump.py b/emf-dump.py
index 7a900c6..57e292c 100755
--- a/emf-dump.py
+++ b/emf-dump.py
@@ -5,7 +5,8 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
-from msodumper import emfrecord
+from msodumper import emfrecord, globals
+import optparse
 import sys
 
 
@@ -21,12 +22,20 @@ class EMFDumper:
         strm.dump()
 
 
-def main(args):
-    dumper = EMFDumper(args[1])
+def main():
+    parser = optparse.OptionParser()
+    options, args = parser.parse_args()
+
+    if len(args) < 1:
+        globals.error("takes at least one argument\n")
+        parser.print_help()
+        sys.exit(1)
+
+    dumper = EMFDumper(args[0])
     dumper.dump()
 
 
 if __name__ == '__main__':
-    main(sys.argv)
+    main()
 
 # vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
diff --git a/test/emf/test.py b/test/emf/test.py
index a9341aa..82499f3 100755
--- a/test/emf/test.py
+++ b/test/emf/test.py
@@ -23,7 +23,8 @@ class Test(unittest.TestCase):
         sock = open("%s.emf.xml" % name, "w")
         saved = sys.stdout
         sys.stdout = sock
-        emf_dumper.main(["emf-dumper", "%s.emf" % name])
+        dumper = emf_dumper.EMFDumper("%s.emf" % name)
+        dumper.dump()
         sys.stdout = saved
         sock.close()
         tree = ElementTree.parse('%s.emf.xml' % name)
diff --git a/test/wmf/test.py b/test/wmf/test.py
index 831125e..ec0250a 100755
--- a/test/wmf/test.py
+++ b/test/wmf/test.py
@@ -23,7 +23,8 @@ class Test(unittest.TestCase):
         sock = open("%s.wmf.xml" % name, "w")
         saved = sys.stdout
         sys.stdout = sock
-        wmf_dumper.main(["wmf-dumper", "%s.wmf" % name])
+        dumper = wmf_dumper.WMFDumper("%s.wmf" % name)
+        dumper.dump()
         sys.stdout = saved
         sock.close()
         tree = ElementTree.parse('%s.wmf.xml' % name)
diff --git a/wmf-dump.py b/wmf-dump.py
index 3c17636..d46ca01 100755
--- a/wmf-dump.py
+++ b/wmf-dump.py
@@ -5,8 +5,9 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
-from msodumper import wmfrecord
+from msodumper import wmfrecord, globals
 import sys
+import optparse
 
 class WMFDumper:
     def __init__(self, filepath):
@@ -20,12 +21,20 @@ class WMFDumper:
         strm.dump()
 
 
-def main(args):
-    dumper = WMFDumper(args[1])
+def main():
+    parser = optparse.OptionParser()
+    options, args = parser.parse_args()
+
+    if len(args) < 1:
+        globals.error("takes at least one argument\n")
+        parser.print_help()
+        sys.exit(1)
+
+    dumper = WMFDumper(args[0])
     dumper.dump()
 
 
 if __name__ == '__main__':
-    main(sys.argv)
+    main()
 
 # vim:set filetype=python shiftwidth=4 softtabstop=4 expandtab:
diff --git a/xls-dump.py b/xls-dump.py
index 15bf8f9..08b47b1 100755
--- a/xls-dump.py
+++ b/xls-dump.py
@@ -237,6 +237,7 @@ def main ():
         parser.print_help()
         sys.exit(1)
 
+
 if __name__ == '__main__':
     main()
 


More information about the Libreoffice-commits mailing list