MCPcopy Create free account
hub / github.com/ActiveState/code / main

Function main

recipes/Python/533146_AST_Pretty_Printer/recipe-533146.py:47–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45
46
47def main():
48 import optparse
49 parser = optparse.OptionParser(__doc__.strip())
50 opts, args = parser.parse_args()
51
52 if not args:
53 parser.error("You need to specify the name of Python files to print out.")
54
55 import compiler, traceback
56 for fn in args:
57 print '\n\n%s:\n' % fn
58 try:
59 printAst(compiler.parseFile(fn), initlevel=1)
60 except SyntaxError, e:
61 traceback.print_exc()
62
63if __name__ == '__main__':
64 main()

Callers 1

recipe-533146.pyFile · 0.70

Calls 5

printAstFunction · 0.85
parseFileMethod · 0.80
stripMethod · 0.45
parse_argsMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected