jdum / odfdo

python library for OpenDocument format (ODF)
Apache License 2.0
48 stars 11 forks source link

Output option of odfdo-styles script not working #12

Closed keestux closed 3 years ago

keestux commented 3 years ago

The script odfdo-styles.py has a few problems. The -o is not working, there is a typo in a variable name, and with Python3 opening a file with wb requires bytes not str.

Anyway, here is a git-diff of the proposed changes (too lazy for a PullRequest right now):

diff --git a/scripts/odfdo-styles.py b/scripts/odfdo-styles.py
index 17db262..155895d 100755
--- a/scripts/odfdo-styles.py
+++ b/scripts/odfdo-styles.py
@@ -38,15 +38,16 @@ def show_styles(document,
                 properties=False):
     """Show the different styles of a document and their properties.
     """
-    output =         document.show_styles(
+    output = document.show_styles(
             automatic=automatic, common=common, properties=properties)
     # Print the output
     if target is None:
-        print(output)
+        print(output, end='')
         return
     target.write(output)
     target.flush()
-    tatget.close()
+    target.close()
+

 def delete_styles(document, target, pretty=True):
     n = document.delete_styles()
@@ -182,9 +183,8 @@ if __name__ == '__main__':
         if not automatic ^ common:
             automatic, common = True, True
         target = options.output
-        target = None
         if target is not None:
-            target = open(target, 'wb')
+            target = open(target, 'w')
         show_styles(
             document,
             target,
jdum commented 3 years ago

fixed, thanks