def main(): try: args, kythe_args, options = parse_args.parse_args(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) if options.timeout is not None: signal.alarm(options.timeout) try: ix = indexer.process_file(options, generate_callgraphs=True) except indexer.PytypeError as e: print(e.args[0], file=sys.stderr) if args.debug: traceback.print_exc() else: print("Run with --debug to see a traceback.") sys.exit(1) if args.debug: debug.show_index(ix) else: kythe_graph = kythe.generate_graph(ix, kythe_args) output.output_kythe_graph(kythe_graph)
def main(): try: args, kythe_args, options = parse_args.parse_args(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) try: ix, _ = indexer.process_file(options, kythe_args=kythe_args, keep_pytype_data=args.debug) except indexer.PytypeError as e: print(e.args[0], file=sys.stderr) if args.debug: traceback.print_exc() else: print("Run with --debug to see a traceback.") sys.exit(1) if args.debug: debug.show_index(ix, keep_pytype_data=True) else: output.output_kythe_graph(ix)
def test_kythe_args(self): _, kythe_args, _ = parse_args.parse_args([ "a.py", "--kythe_corpus", "foo", "--kythe_root", "bar", "--kythe_path", "baz" ]) self.assertEqual(kythe_args.corpus, "foo") self.assertEqual(kythe_args.root, "bar") self.assertEqual(kythe_args.path, "baz")
def test_imports_info(self): # The code reads and validates an import map within pytype's setup, so we # need to provide a syntactically valid one as a file. with file_utils.Tempdir() as d: pyi_file = d.create_file("baz.pyi") imports_info = d.create_file("foo", "bar %s" % pyi_file) args, _, opts = parse_args.parse_args( ["a.py", "--imports_info", imports_info]) self.assertEqual(args.imports_info, imports_info) self.assertEqual(opts.imports_map, {"bar": pyi_file}) self.assertTrue(opts.use_pickled_files)
def main(): try: args, kythe_args, options = parse_args.parse_args(sys.argv[1:]) except utils.UsageError as e: print(str(e), file=sys.stderr) sys.exit(1) node.SetCheckPreconditions(options.check_preconditions) if options.timeout is not None: signal.alarm(options.timeout) ix = indexer.process_file(options, kythe_args=kythe_args) if args.debug: debug.show_index(ix) else: output.output_kythe_graph(ix)
def test_parse_filename(self): args, _, _ = parse_args.parse_args(["a.py"]) self.assertEqual(args.inputs, ["a.py"])
def test_parse_no_filename(self): with self.assertRaises(SystemExit): parse_args.parse_args([])