Exemplo n.º 1
0
def main():
    """Read source from stdin, parse and export the AST as JSON"""
    parser = create_parser()
    args = parser.parse_args()
    if args.version:
        print("{} version {}".format(__prog_name__, __version__))
        return
    source = "".join(fileinput.input(args.input))
    tree = parse(source)
    json = export_json(tree, args.pretty)
    print(json)
Exemplo n.º 2
0
def main():
    """Read source from stdin, parse and export the AST as JSON"""
    parser = create_parser()
    args = parser.parse_args()
    if args.version:
        print("{} version {}".format(__prog_name__, __version__))
        return
    source = "".join(fileinput.input(args.input))
    tree = parse(source)
    json = export_json(tree, args.pretty)
    print(json)
Exemplo n.º 3
0
 def test_export_json(self):
     for i, test in enumerate(self.tests):
         with self.subTest(test=i):
             result = json.loads(export_json(test.input))
             expected = test.output
             self.assertEqual(result, expected)