Changeset View
Changeset View
Standalone View
Standalone View
test/lint/check-rpc-mappings.py
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def parse_string(s): | ||||
assert s[-1] == '"' | assert s[-1] == '"' | ||||
return s[1:-1] | return s[1:-1] | ||||
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") 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 | ||||
Show All 12 Lines | def process_commands(fname): | ||||
assert not in_rpcs and cmds, "Something went wrong with parsing the C++ file: update the regexps" | assert not in_rpcs and cmds, "Something went wrong with parsing the C++ file: update the regexps" | ||||
return cmds | return cmds | ||||
def process_mapping(fname): | def process_mapping(fname): | ||||
"""Find and parse conversion table in implementation file `fname`.""" | """Find and parse conversion table in implementation file `fname`.""" | ||||
cmds = [] | cmds = [] | ||||
in_rpcs = False | in_rpcs = False | ||||
with open(fname, "r") 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 line == 'static const CRPCConvertParam vRPCConvertParams[] = {': | if line == 'static const CRPCConvertParam vRPCConvertParams[] = {': | ||||
in_rpcs = True | in_rpcs = True | ||||
else: | else: | ||||
if line.startswith('};'): | if line.startswith('};'): | ||||
in_rpcs = False | in_rpcs = False | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |