|
16 | 16 | parser = argparse.ArgumentParser()
|
17 | 17 | parser.add_argument('--type-info', default='type_info.json', metavar="FILE",
|
18 | 18 | help="JSON input file (default type_info.json)")
|
| 19 | +parser.add_argument('--uses-signature', action='store_true', |
| 20 | + help="JSON input uses a signature format") |
19 | 21 | parser.add_argument('-p', '--print-function', action='store_true',
|
20 | 22 | help="Assume print is a function")
|
21 | 23 | parser.add_argument('-w', '--write', action='store_true',
|
@@ -108,14 +110,18 @@ def main(args_override=None):
|
108 | 110 | else:
|
109 | 111 | # Produce nice error message if type_info.json not found.
|
110 | 112 | try:
|
111 |
| - open(args.type_info).close() |
| 113 | + with open(args.type_info) as f: |
| 114 | + contents = f.read() |
112 | 115 | except IOError as err:
|
113 | 116 | sys.exit("Can't open type info file: %s" % err)
|
114 | 117 |
|
115 | 118 | # Run pass 2 with output into a variable.
|
116 |
| - data = generate_annotations_json_string( |
117 |
| - args.type_info, |
118 |
| - only_simple=args.only_simple) # type: List[Any] |
| 119 | + if args.uses_signature: |
| 120 | + data = json.loads(contents) # type: List[Any] |
| 121 | + else: |
| 122 | + data = generate_annotations_json_string( |
| 123 | + args.type_info, |
| 124 | + only_simple=args.only_simple) |
119 | 125 |
|
120 | 126 | # Run pass 3 with input from that variable.
|
121 | 127 | FixAnnotateJson.init_stub_json_from_data(data, args.files[0])
|
|
0 commit comments