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:
Ben Woosley
2019-02-01 17:00:02 -08:00
parent 6e431296da
commit b21680baf5
14 changed files with 38 additions and 41 deletions

View File

@@ -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'