Changeset View
Changeset View
Standalone View
Standalone View
test/lint/check-rpc-mappings.py
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
def process_commands(fname): | def process_commands(fname): | ||||
"""Find and parse dispatch table in implementation file `fname`.""" | """Find and parse dispatch table in implementation file `fname`.""" | ||||
cmds = [] | cmds = [] | ||||
in_rpcs = False | in_rpcs = False | ||||
with open(fname, "r", encoding="utf8") as f: | with open(fname, "r", encoding="utf8") as f: | ||||
for line in f: | for line in f: | ||||
line = line.rstrip() | line = line.rstrip() | ||||
if not in_rpcs: | if not in_rpcs: | ||||
if re.match(r"static const ContextFreeRPCCommand .*\[\] =", line): | if re.match( | ||||
r"static const ContextFreeRPCCommand .*\[\] =", line): | |||||
in_rpcs = True | in_rpcs = True | ||||
else: | else: | ||||
if line.startswith('};'): | if line.startswith('};'): | ||||
in_rpcs = False | in_rpcs = False | ||||
elif '{' in line and '"' in line: | elif '{' in line and '"' in line: | ||||
m = re.search( | m = re.search( | ||||
'{ *("[^"]*"), *("[^"]*"), *([^,]*), *{([^}]*)} *},', line) | '{ *("[^"]*"), *("[^"]*"), *([^,]*), *{([^}]*)} *},', line) | ||||
assert m, 'No match to table expression: {}'.format(line) | assert m, 'No match to table expression: {}'.format(line) | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |