35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
|
from sys import argv
|
||
|
from pathlib import Path
|
||
|
|
||
|
import FSA
|
||
|
import Graph
|
||
|
import Hasse
|
||
|
import Truthtable
|
||
|
|
||
|
def fetchContentType(content):
|
||
|
new_content = content.split('\n')
|
||
|
contentType = new_content.pop(0)[2:]
|
||
|
return (contentType, '\n'.join(new_content))
|
||
|
|
||
|
def processContent(content):
|
||
|
contentType, content = fetchContentType(content)
|
||
|
with open(str(Path(__file__).parent.absolute()) + f'/tex_templates/{contentType}.tex') as template:
|
||
|
if contentType == 'Hasse':
|
||
|
result = Hasse.processFileContent(content, template.read())
|
||
|
elif contentType == 'FSA':
|
||
|
result = FSA.processFileContent(content, template.read())
|
||
|
elif contentType == 'Truthtable':
|
||
|
result = Truthtable.processFileContent(content, template.read())
|
||
|
else:
|
||
|
print('DIDN\'T RECOGNIZE FILE TYPE')
|
||
|
exit(1)
|
||
|
return result
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
filename = argv[1]
|
||
|
|
||
|
with open(filename) as file:
|
||
|
content = processContent(file.read())
|
||
|
|
||
|
with open(argv[2], 'w') as destination_file:
|
||
|
destination_file.write(content)
|