]> wagnertech.de Git - mDoc.git/blobdiff - python/mDoc/mdoc_extract.py
antix19
[mDoc.git] / python / mDoc / mdoc_extract.py
diff --git a/python/mDoc/mdoc_extract.py b/python/mDoc/mdoc_extract.py
new file mode 100755 (executable)
index 0000000..6226d79
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/python3
+'''
+Created on 26.03.2021
+
+@author: antix19
+'''
+import sys
+from mdoc import extractor
+import re
+
+usage = 'mdoc-extract <source> <class>'
+
+def command_dispatch(args):
+    
+    # check runtime parameters
+    if len(args) < 2:
+        raise RuntimeError("mdoc-extract needs 2 arguments.")
+    
+    file = args[0]
+    classs = args[1]
+    target = re.sub(r'\..*', '.tex', file)
+    
+    return extractor.extract(file, classs, target)
+    
+
+# evaulate runtime parameters
+if __name__ == '__main__':
+    try:
+        ret = command_dispatch(sys.argv[1:])
+        if ret != 0:
+            print ("Operation returned: "+str(ret)) 
+        exit (ret)
+    except Exception as e:
+        print (e)
+        print (usage)
+        raise
\ No newline at end of file