コード例 #1
0
ファイル: node_test.py プロジェクト: ukulili/pytype
 def testPrecondition(self):
   class MyNode(node.Node("s: str")):
     pass
   MyNode("a")  # OK.
   try:
     node.SetCheckPreconditions(False)
     MyNode(1)  # Preconditions are ignored.
   finally:
     # Restore preconditions (not part of the public API, but ensures the
     # test doesn't have a surprising side effect).
     node.SetCheckPreconditions(True)
コード例 #2
0
ファイル: main.py プロジェクト: ukulili/pytype
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)
コード例 #3
0
def main():
    try:
        options = config.Options(sys.argv[1:], command_line=True)
    except utils.UsageError as e:
        print(str(e), file=sys.stderr)
        sys.exit(1)

    if options.show_config:
        print(options)
        sys.exit(0)

    if options.version:
        print(io.get_pytype_version())
        sys.exit(0)

    node.SetCheckPreconditions(options.check_preconditions)

    if options.timeout is not None:
        signal.alarm(options.timeout)

    with _ProfileContext(options.profile):
        with metrics.MetricsContext(options.metrics, options.open_function):
            with metrics.StopWatch("total_time"):
                with metrics.Snapshot("memory",
                                      enabled=options.memory_snapshots):
                    return _run_pytype(options)
コード例 #4
0
ファイル: main.py プロジェクト: yoavtzelnick/pytype
def main():
    try:
        options = config.Options(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)

    return process_file(options)
コード例 #5
0
ファイル: main.py プロジェクト: stevenmburns/pytype
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)
コード例 #6
0
ファイル: main.py プロジェクト: shivapbhusal/pytype
def main():
  try:
    options = config.Options(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)

  v = indexer.process_file(options)
  output.show_defs(v)
  print()
  print("--------------------")
  print()
  output.show_refs(v)