mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-04 17:52:25 +01:00
test/contrib: Fix invalid escapes in regex strings
Flagged by flake8 v3.6.0, as W605, plus a few others identified incidentally, e.g. 59ffecf66cf4d08c4b431e457b083878d66a3fd6. Note that r"\n" matches to "\n" under re.match/search.
This commit is contained in:
@@ -48,13 +48,13 @@ def process_commands(fname):
|
||||
for line in f:
|
||||
line = line.rstrip()
|
||||
if not in_rpcs:
|
||||
if re.match("static const CRPCCommand .*\[\] =", line):
|
||||
if re.match(r"static const CRPCCommand .*\[\] =", line):
|
||||
in_rpcs = True
|
||||
else:
|
||||
if line.startswith('};'):
|
||||
in_rpcs = False
|
||||
elif '{' in line and '"' in line:
|
||||
m = re.search('{ *("[^"]*"), *("[^"]*"), *&([^,]*), *{([^}]*)} *},', line)
|
||||
m = re.search(r'{ *("[^"]*"), *("[^"]*"), *&([^,]*), *{([^}]*)} *},', line)
|
||||
assert m, 'No match to table expression: %s' % line
|
||||
name = parse_string(m.group(2))
|
||||
args_str = m.group(4).strip()
|
||||
@@ -80,7 +80,7 @@ def process_mapping(fname):
|
||||
if line.startswith('};'):
|
||||
in_rpcs = False
|
||||
elif '{' in line and '"' in line:
|
||||
m = re.search('{ *("[^"]*"), *([0-9]+) *, *("[^"]*") *},', line)
|
||||
m = re.search(r'{ *("[^"]*"), *([0-9]+) *, *("[^"]*") *},', line)
|
||||
assert m, 'No match to table expression: %s' % line
|
||||
name = parse_string(m.group(1))
|
||||
idx = int(m.group(2))
|
||||
|
||||
Reference in New Issue
Block a user