Files
.gitlab
exam
exam_template
.vscode
python
tex_templates
FSA.py
Graph.py
InclusionExclusion.py
Powerset.py
Python.py
Relations.py
Truthtable.py
common.py
run.py
Makefile
main.tex
exam_template_graphics
exercise1
exercise10
exercise11
exercise12
exercise2
exercise3
exercise4
exercise5
exercise6
exercise7
exercise8
exercise9
tools
.gitignore
.gitlab-ci.yml
README.md
generate_pdfs.sh

48 lines
1.3 KiB
Python

from sys import argv
from pathlib import Path
import FSA
import Graph
import Truthtable
import Relations
import InclusionExclusion
import Python
from common import printerr
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)
if contentType == 'FSA':
result = FSA.processFileContent(content)
elif contentType == 'Graph':
result = Graph.processFileContent('toGraph\n\n' + content)
elif contentType == 'Matrix':
result = Graph.processFileContent('toMatrix\n\n' + content)
elif contentType == 'Relations':
result = Relations.processFileContent(content)
elif contentType == 'Truthtable':
result = Truthtable.processFileContent(content)
elif contentType == 'InclusionExclusion':
result = InclusionExclusion.processFileContent(content)
elif contentType == 'Python':
result = Python.processFileContent(content)
else:
printerr('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)