chiark / gitweb /
Escape: Add missing r in regexp literals ('...' => r'...') [6]
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 14 Oct 2018 12:58:04 +0000 (13:58 +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/deb/policy.py
gbp/deb/pristinetar.py
gbp/scripts/dch.py
gbp/scripts/export_orig.py
gbp/scripts/pq.py

index d9b27ac05b248220d59d59551133d5451c628531..89a4c6ddce917cfee70454dc4c90fad4f47a3ee1 100644 (file)
@@ -43,7 +43,7 @@ class DebianPkgPolicy(PkgPolicy):
     # must consist only of lower case letters (a-z), digits (0-9), plus (+)
     # and minus (-) signs, and periods (.). They must be at least two
     # characters long and must start with an alphanumeric character."
-    packagename_re = re.compile("^[a-zA-Z0-9][a-zA-Z0-9\.\+\-~]+$")
+    packagename_re = re.compile(r"^[a-zA-Z0-9][a-zA-Z0-9\.\+\-~]+$")
     packagename_msg = """Package names must be at least two characters long, start with an
     alphanumeric and can only containg letters (a-z,A-Z), digits
     (0-9), plus signs (+), minus signs (-), periods (.) and hyphens (~)"""
@@ -55,7 +55,7 @@ class DebianPkgPolicy(PkgPolicy):
     # are not allowed; if there is no epoch then colons are not allowed."
     # Since we don't know about any epochs and debian revisions yet, the
     # last two conditions are not checked.
-    upstreamversion_re = re.compile("^[0-9][a-zA-Z0-9\.\+\-\:\~]*$")
+    upstreamversion_re = re.compile(r"^[0-9][a-zA-Z0-9\.\+\-\:\~]*$")
     upstreamversion_msg = """Upstream version numbers must start with a digit and can only containg lower case
     letters (a-z), digits (0-9), full stops (.), plus signs (+), minus signs
     (-), colons (:) and tildes (~)"""
index 2f52f3ac8c2bfca88dda42a66f7cf2365aa5c9c1..843e52e96fe166f8c41abe33c645e499fb120121 100644 (file)
@@ -36,11 +36,11 @@ class DebianPristineTar(PristineTar):
         @type comp_type: C{str}
         """
         if not comp_type:
-            ext = '\w\+'
+            ext = r'\w\+'
         else:
             ext = Compressor.Exts[comp_type]
 
-        name_regexp = '%s_%s\.orig\.tar\.%s' % (package, version, ext)
+        name_regexp = r'%s_%s\.orig\.tar\.%s' % (package, version, ext)
 
         return super(DebianPristineTar, self).has_commit(name_regexp)
 
index 6297d2d7aadbd0831a0df1b8a51e9a4ef4410096..2584eff0ab7204e0b4ae9b9b34c043f6ef43ae76 100644 (file)
@@ -34,7 +34,7 @@ from gbp.scripts.common import ExitCodes, maybe_debug_raise
 from gbp.scripts.common.hook import Hook
 
 user_customizations = {}
-snapshot_re = re.compile("\s*\*\* SNAPSHOT build @(?P<commit>[a-z0-9]+)\s+\*\*")
+snapshot_re = re.compile(r"\s*\*\* SNAPSHOT build @(?P<commit>[a-z0-9]+)\s+\*\*")
 
 
 def guess_version_from_upstream(repo, upstream_tag_format, upstream_branch, cp=None):
index ea6c8870d595d47248a5134f2cd1b8cedb243aea..1afbe6dbd904b722eca98fb2c6a201534935a5f1 100755 (executable)
@@ -235,7 +235,7 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
 
     if comp_type == 'auto':
         if repo and repo.has_pristine_tar_branch():
-            regex = 'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
+            regex = r'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
             commits = repo.grep_log(regex, repo.pristine_tar_branch, merges=False)
             if commits:
                 commit = commits[-1]
index 7bf7736f2d61f49c65933c524f769e77b5336306..babff1c51307c18cb07df9e6a4d8d2074943e0da 100755 (executable)
@@ -48,7 +48,7 @@ def parse_old_style_topic(commit_info):
     """Parse 'gbp-pq-topic:' line(s) from commit info"""
 
     commit = commit_info['id']
-    topic_regex = 'gbp-pq-topic:\s*(?P<topic>\S.*)'
+    topic_regex = r'gbp-pq-topic:\s*(?P<topic>\S.*)'
     mangled_body = ''
     topic = ''
     # Parse and filter commit message body