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

Function parse

deps/v8/third_party/inspector_protocol/pdl.py:53–191  ·  view source on GitHub ↗
(data, file_name, map_binary_to_string, source_set)

Source from the content-addressed store, hash-verified

51
52
53def parse(data, file_name, map_binary_to_string, source_set):
54 assert source_set is None or isinstance(source_set, set)
55 protocol = collections.OrderedDict()
56 protocol['version'] = collections.OrderedDict()
57 protocol['domains'] = []
58 domain = None
59 item = None
60 subitems = None
61 nukeDescription = False
62 if source_set is not None:
63 source_set.add(file_name)
64 global description
65 lines = data.split('\n')
66 for i in range(0, len(lines)):
67 if nukeDescription:
68 description = ''
69 nukeDescription = False
70 line = lines[i]
71 trimLine = line.strip()
72
73 if trimLine.startswith('#'):
74 if len(description):
75 description += '\n'
76 description += trimLine[2:]
77 continue
78 else:
79 nukeDescription = True
80
81 if len(trimLine) == 0:
82 continue
83
84 match = re.compile(
85 r'^(experimental )?(deprecated )?domain (.*)').match(line)
86 if match:
87 domain = createItem({'domain' : match.group(3)}, match.group(1),
88 match.group(2))
89 protocol['domains'].append(domain)
90 continue
91
92 match = re.compile(r'^include (.*)').match(line)
93 if match:
94 included_filename = match.group(1)
95 if os.path.isabs(included_filename):
96 raise Exception("Only relative paths are supported in includes")
97 resolved_path = os.path.normpath(
98 os.path.join(os.path.dirname(file_name), included_filename))
99 with open(resolved_path, 'r') as file:
100 included_data = parse(file.read(), resolved_path, map_binary_to_string,
101 source_set)
102 protocol['domains'].extend(included_data['domains'])
103 continue
104
105 match = re.compile(r'^ depends on ([^\s]+)').match(line)
106 if match:
107 if 'dependencies' not in domain:
108 domain['dependencies'] = []
109 domain['dependencies'].append(match.group(1))
110 continue

Callers 2

loadsFunction · 0.70
parse_tupleMethod · 0.50

Calls 14

createItemFunction · 0.70
assignTypeFunction · 0.70
addMethod · 0.65
matchMethod · 0.65
rangeFunction · 0.50
openFunction · 0.50
printFunction · 0.50
splitMethod · 0.45
compileMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected