mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 18:22:57 +02: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:
@@ -106,7 +106,7 @@ def main():
|
||||
filename = None
|
||||
lines_by_file = {}
|
||||
for line in sys.stdin:
|
||||
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
||||
match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
||||
if match:
|
||||
filename = match.group(2)
|
||||
if filename is None:
|
||||
@@ -119,7 +119,7 @@ def main():
|
||||
if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
|
||||
continue
|
||||
|
||||
match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
|
||||
match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
|
||||
if match:
|
||||
start_line = int(match.group(1))
|
||||
line_count = 1
|
||||
|
||||
@@ -71,7 +71,7 @@ def get_filenames_to_examine(base_directory):
|
||||
################################################################################
|
||||
|
||||
|
||||
COPYRIGHT_WITH_C = 'Copyright \(c\)'
|
||||
COPYRIGHT_WITH_C = r'Copyright \(c\)'
|
||||
COPYRIGHT_WITHOUT_C = 'Copyright'
|
||||
ANY_COPYRIGHT_STYLE = '(%s|%s)' % (COPYRIGHT_WITH_C, COPYRIGHT_WITHOUT_C)
|
||||
|
||||
@@ -85,21 +85,21 @@ ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE = ("%s %s" % (ANY_COPYRIGHT_STYLE,
|
||||
ANY_COPYRIGHT_COMPILED = re.compile(ANY_COPYRIGHT_STYLE_OR_YEAR_STYLE)
|
||||
|
||||
def compile_copyright_regex(copyright_style, year_style, name):
|
||||
return re.compile('%s %s,? %s' % (copyright_style, year_style, name))
|
||||
return re.compile('%s %s,? %s\n' % (copyright_style, year_style, name))
|
||||
|
||||
EXPECTED_HOLDER_NAMES = [
|
||||
"Satoshi Nakamoto\n",
|
||||
"The Bitcoin Core developers\n",
|
||||
"BitPay Inc\.\n",
|
||||
"University of Illinois at Urbana-Champaign\.\n",
|
||||
"Pieter Wuille\n",
|
||||
"Wladimir J. van der Laan\n",
|
||||
"Jeff Garzik\n",
|
||||
"Jan-Klaas Kollhof\n",
|
||||
"ArtForz -- public domain half-a-node\n",
|
||||
"Intel Corporation",
|
||||
"The Zcash developers",
|
||||
"Jeremy Rubin",
|
||||
r"Satoshi Nakamoto",
|
||||
r"The Bitcoin Core developers",
|
||||
r"BitPay Inc\.",
|
||||
r"University of Illinois at Urbana-Champaign\.",
|
||||
r"Pieter Wuille",
|
||||
r"Wladimir J\. van der Laan",
|
||||
r"Jeff Garzik",
|
||||
r"Jan-Klaas Kollhof",
|
||||
r"ArtForz -- public domain half-a-node",
|
||||
r"Intel Corporation ?",
|
||||
r"The Zcash developers",
|
||||
r"Jeremy Rubin",
|
||||
]
|
||||
|
||||
DOMINANT_STYLE_COMPILED = {}
|
||||
@@ -329,7 +329,7 @@ def write_file_lines(filename, file_lines):
|
||||
# update header years execution
|
||||
################################################################################
|
||||
|
||||
COPYRIGHT = 'Copyright \(c\)'
|
||||
COPYRIGHT = r'Copyright \(c\)'
|
||||
YEAR = "20[0-9][0-9]"
|
||||
YEAR_RANGE = '(%s)(-%s)?' % (YEAR, YEAR)
|
||||
HOLDER = 'The Bitcoin Core developers'
|
||||
|
||||
@@ -141,7 +141,7 @@ def read_libraries(filename):
|
||||
for line in stdout.splitlines():
|
||||
tokens = line.split()
|
||||
if len(tokens)>2 and tokens[1] == '(NEEDED)':
|
||||
match = re.match('^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
|
||||
match = re.match(r'^Shared library: \[(.*)\]$', ' '.join(tokens[2:]))
|
||||
if match:
|
||||
libraries.append(match.group(1))
|
||||
else:
|
||||
@@ -171,5 +171,3 @@ if __name__ == '__main__':
|
||||
retval = 1
|
||||
|
||||
sys.exit(retval)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user