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)