2021-05-10 22:12:15 +02:00
|
|
|
from sys import argv
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
import FSA
|
|
|
|
import Graph
|
|
|
|
import Truthtable
|
2021-05-17 00:33:41 +02:00
|
|
|
import Relations
|
2021-05-17 22:06:10 +02:00
|
|
|
import InclusionExclusion
|
|
|
|
import Python
|
|
|
|
|
2021-05-17 00:33:41 +02:00
|
|
|
from common import printerr
|
2021-05-11 22:21:15 +02:00
|
|
|
|
2021-05-10 22:12:15 +02:00
|
|
|
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)
|
2021-05-17 18:39:28 +02:00
|
|
|
|
|
|
|
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)
|
2021-05-17 22:06:10 +02:00
|
|
|
elif contentType == 'InclusionExclusion':
|
|
|
|
result = InclusionExclusion.processFileContent(content)
|
|
|
|
elif contentType == 'Python':
|
|
|
|
result = Python.processFileContent(content)
|
2021-05-17 18:39:28 +02:00
|
|
|
else:
|
|
|
|
printerr('DIDN\'T RECOGNIZE FILE TYPE')
|
|
|
|
exit(1)
|
|
|
|
|
2021-05-10 22:12:15 +02:00
|
|
|
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)
|