]> wagnertech.de Git - mDoc.git/blob - python/mDoc/mdoc_extract.py
antix19
[mDoc.git] / python / mDoc / mdoc_extract.py
1 #!/usr/bin/python3
2 '''
3 Created on 26.03.2021
4
5 @author: antix19
6 '''
7 import sys
8 from mdoc import extractor
9 import re
10
11 usage = 'mdoc-extract <source> <class>'
12
13 def command_dispatch(args):
14     
15     # check runtime parameters
16     if len(args) < 2:
17         raise RuntimeError("mdoc-extract needs 2 arguments.")
18     
19     file = args[0]
20     classs = args[1]
21     target = re.sub(r'\..*', '.tex', file)
22     
23     return extractor.extract(file, classs, target)
24     
25
26 # evaulate runtime parameters
27 if __name__ == '__main__':
28     try:
29         ret = command_dispatch(sys.argv[1:])
30         if ret != 0:
31             print ("Operation returned: "+str(ret)) 
32         exit (ret)
33     except Exception as e:
34         print (e)
35         print (usage)
36         raise