def parse(filename): """ Parse the given file and write the result of conversion into output (default to stdout) """ # read source file with open(filename, "r") as pyfile: source = pyfile.read() # Build the abstract syntax tree tree = compile(source, filename, "exec", ast.PyCF_ONLY_AST) formatter = CodeFormatter() generator = CodeGenerator(formatter) generator.visit(tree) generator.printIncludes() formatter.flush()