[Libreoffice-commits] dev-tools.git: qa/document_analyser.py
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 24 09:08:23 UTC 2021
qa/document_analyser.py | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 256a04c605be389441a29486799435c9ced77520
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Sep 24 11:05:39 2021 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Sep 24 11:07:31 2021 +0200
document_analyser: use arguments instead of input
Change-Id: I3a4033904df2967a12d00b349dfbfb9b38ead766
diff --git a/qa/document_analyser.py b/qa/document_analyser.py
index 206c573..c97ae59 100755
--- a/qa/document_analyser.py
+++ b/qa/document_analyser.py
@@ -19,17 +19,28 @@ syllable count, table count, textbox count, word count, and paragraph styles.
"""
+import sys
+import os
import odf
from odf.namespaces import TEXTNS
from odf.element import Element
from odf.opendocument import load
from odf import text,meta,office,draw
+def usage():
+ message = "usage: {program} FILENAME"
+ print(message.format(program = os.path.basename(sys.argv[0])))
-print("Enter filename: ")
-filename=input()
+if len(sys.argv) != 2:
+ usage()
+ sys.exit(1)
-doc=load(filename)
+arg1 = sys.argv[1]
+if arg1 == '-h' or arg1 == "--help":
+ usage()
+ sys.exit(1)
+
+doc=load(arg1)
#--------------------document statistics from the odf.meta module--------------------
print("\nDOCUMENT STATISTICS\n")
More information about the Libreoffice-commits
mailing list