chiark / gitweb /
Escape: Add missing r in regexp literals ('...' => r'...') [7]
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Oct 2018 13:11:49 +0000 (14:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Oct 2018 14:17:27 +0000 (15:17 +0100)
Detected by flake8, eg
 ./gbp/deb/git.py:35:6: W605 invalid escape sequence '\)'

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
gbp/rpm/__init__.py
gbp/scripts/common/pq.py

index b37dfdabeeae5423f8e63524844add61fe7a0b50..0048af490ea72a04ac9b762bcd20cd8bc7d09f69 100644 (file)
@@ -115,11 +115,11 @@ class SrcRpmFile(object):
 class SpecFile(object):
     """Class for parsing/modifying spec files"""
     tag_re = re.compile(r'^(?P<name>[a-z]+)(?P<num>[0-9]+)?\s*:\s*'
-                        '(?P<value>\S(.*\S)?)\s*$', flags=re.I)
+                        r'(?P<value>\S(.*\S)?)\s*$', flags=re.I)
     directive_re = re.compile(r'^%(?P<name>[a-z]+)(?P<num>[0-9]+)?'
-                              '(\s+(?P<args>.*))?$', flags=re.I)
+                              r'(\s+(?P<args>.*))?$', flags=re.I)
     gbptag_re = re.compile(r'^\s*#\s*gbp-(?P<name>[a-z-]+)'
-                           '(\s*:\s*(?P<args>\S.*))?$', flags=re.I)
+                           r'(\s*:\s*(?P<args>\S.*))?$', flags=re.I)
     # Here "sections" stand for all scripts, scriptlets and other directives,
     # but not macros
     section_identifiers = ('package', 'description', 'prep', 'build', 'install',
index b6033a2830601dede3f059de210ef04dbe9ef0c9..73d419c563669100905cd56bfd0f32f2f2ac420f 100644 (file)
@@ -152,7 +152,7 @@ def write_patch_file(filename, commit_info, diff):
             name = commit_info['author']['name']
             email = commit_info['author']['email']
             # Git compat: put name in quotes if special characters found
-            if re.search("[,.@()\[\]\\\:;]", name):
+            if re.search(r"[,.@()\[\]\\\:;]", name):
                 name = '"%s"' % name
             from_header = Header(header_name='from')
             try:
@@ -216,7 +216,7 @@ def format_patch(outdir, repo, commit_info, series, abbrev, numbered=True,
         if renumber:
             # Remove any existing numeric prefix if the patch
             # should be renumbered
-            name = re.sub('^\d+[-_]*', '', name)
+            name = re.sub(r'^\d+[-_]*', '', name)
         else:
             # Otherwise, clear proposed prefix
             num_prefix = ''