MCPcopy Index your code
hub / github.com/nodejs/node / main

Function main

deps/inspector_protocol/concatenate_protocols.py:17–62  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

15import pdl
16
17def main(argv):
18 cmdline_parser = argparse.ArgumentParser()
19 cmdline_parser.add_argument('filename', nargs='*')
20 cmdline_parser.add_argument("--depfile", required=False)
21 cmdline_parser.add_argument("--stamp", required=False)
22 arg_options = cmdline_parser.parse_args()
23
24 if bool(arg_options.depfile) != bool(arg_options.stamp):
25 raise Exception("--depfile requires --stamp and vice versa")
26
27 if len(arg_options.filename) < 1:
28 sys.stderr.write(
29 "Usage: %s <protocol-1> [<protocol-2> [, <protocol-3>...]] "
30 "<output-file>\n" % sys.argv[0])
31 return 1
32
33 filenames = arg_options.filename
34 deps_filename = arg_options.depfile
35 stamp_filename = arg_options.stamp
36 domains = []
37 source_set = set()
38 version = None
39 for protocol in filenames[:-1]:
40 file_name = os.path.normpath(protocol)
41 if not os.path.isfile(file_name):
42 sys.stderr.write("Cannot find %s\n" % file_name)
43 return 1
44 input_file = open(file_name, "r")
45 parsed_json = pdl.loads(input_file.read(), file_name, False, source_set)
46 domains += parsed_json["domains"]
47 version = parsed_json["version"]
48
49 if stamp_filename:
50 with open(stamp_filename, "w"):
51 pass
52
53 output_file = open(argv[-1], "w")
54 json.dump({"version": version, "domains": domains}, output_file,
55 indent=4, sort_keys=False, separators=(',', ': '))
56 output_file.close()
57
58 if deps_filename:
59 assert stamp_filename
60 with open(deps_filename, "w") as deps_file:
61 deps_file.write("%s: %s\n" % (
62 stamp_filename, " ".join(sorted(source_set))))
63
64
65if __name__ == '__main__':

Callers 1

Calls 10

sortedFunction · 0.85
closeMethod · 0.65
setFunction · 0.50
openFunction · 0.50
add_argumentMethod · 0.45
parse_argsMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
dumpMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…