summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/support/optexcount/optexcount.py
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/support/optexcount/optexcount.py')
-rwxr-xr-xMaster/texmf-dist/source/support/optexcount/optexcount.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/support/optexcount/optexcount.py b/Master/texmf-dist/source/support/optexcount/optexcount.py
new file mode 100755
index 00000000000..2f1310f53ba
--- /dev/null
+++ b/Master/texmf-dist/source/support/optexcount/optexcount.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+
+"""
+The main file for entire optexcount utility
+Author: Richard Hartmann
+Version: 1.1
+"""
+
+
+import argparse
+import counter
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Word counter of OpTeX documents")
+ parser.add_argument('filename', help='filename of our OpTeX file', type=argparse.FileType('r'))
+ parser.add_argument("-v", "--verbose", help="activate verbose mode", action="store_true")
+ parser.add_argument('-s', '--set-verbchar', help='set implicit inline verbatim character', nargs=1)
+ parser.add_argument('--version', action='version', version='Version 1.1')
+ args = parser.parse_args()
+ if args.set_verbchar:
+ if len(args.set_verbchar[0]) != 1:
+ parser.error("SET_VERBCHAR must be a character")
+ raise argparse.ArgumentTypeError("SET_VERBCHAR must be a character")
+ else:
+ args.set_verbchar = args.set_verbchar[0]
+
+ try:
+ c = counter.Counter(args.filename.name, args.verbose, args.set_verbchar)
+ c.run()
+ c.print_result()
+ except Exception as err:
+ print()
+ print("Problem occurred!")
+ print(err)
+
+
+if __name__ == "__main__":
+ main()