qa/document_analyser.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
New commits: commit 256a04c605be389441a29486799435c9ced77520 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Sep 24 11:05:39 2021 +0200 Commit: Xisco Fauli <xiscofa...@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")