Updaate regexp escaping syntax to please pep8
authorMagnus Hagander <magnus@hagander.net>
Thu, 16 Jul 2020 13:47:14 +0000 (15:47 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 11 Aug 2020 10:19:47 +0000 (12:19 +0200)
django/archives/mailarchives/templatetags/pgfilters.py
loader/generate_mbox.py
loader/lib/parser.py

index 83bb47735e391f8ca691bc0214e2578e8a6e85fb..2f1d6302bdf42559836878dff50b485d0f8cfa14 100644 (file)
@@ -28,7 +28,7 @@ def hidemail(value):
 #
 # Those are not email addresses, so ignore them. The links won't work if they
 # are mangled.
-_re_mail = re.compile('(/m(essage-id)?/)?[^()<>@,;:\/\s"\'&|]+@[^()<>@,;:\/\s"\'&|]+')
+_re_mail = re.compile(r'(/m(essage-id)?/)?[^()<>@,;:\/\s"\'&|]+@[^()<>@,;:\/\s"\'&|]+')
 
 
 def _rewrite_email_match(match):
index 76ce946a6704e6201f16d160c2d17432ee86126e..189d8a47b22893c8044d9ce5fa0fa200fb3182d5 100755 (executable)
@@ -96,7 +96,7 @@ if __name__ == "__main__":
                                      os.path.join(fullpath, "{0}.{0:04d}{1:02d}".format(year, month)))
     else:
         # Parse year and month
-        m = re.match('^(\d{4})-(\d{2})$', args.month)
+        m = re.match(r'^(\d{4})-(\d{2})$', args.month)
         if not m:
             print("Month must be specified on format YYYY-MM, not {0}".format(args.month))
             sys.exit(1)
index 5a02cb477d2536b277aff45867d3543e6388cd19..171f197849f3076f9f23691dd90007f9fdec3f11 100644 (file)
@@ -13,7 +13,7 @@ import io
 from lib.exception import IgnorableException
 from lib.log import log
 
-_re_received = re.compile('^from .*;([^(]+)(\s*\(envelope-from.*)?', re.I | re.DOTALL)
+_re_received = re.compile(r'^from .*;([^(]+)(\s*\(envelope-from.*)?', re.I | re.DOTALL)
 
 
 class ArchivesParser(object):
@@ -176,7 +176,7 @@ class ArchivesParser(object):
 
     # Regular expression matching the PostgreSQL custom mail footer that
     # is appended to all emails.
-    _re_footer = re.compile('(.*)--\s+\nSent via [^\s]+ mailing list \([^\)]+\)\nTo make changes to your subscription:\nhttp://www\.postgresql\.org/mailpref/[^\s]+\s*$', re.DOTALL)
+    _re_footer = re.compile(r'(.*)--\s+\nSent via [^\s]+ mailing list \([^\)]+\)\nTo make changes to your subscription:\nhttp://www\.postgresql\.org/mailpref/[^\s]+\s*$', re.DOTALL)
 
     def get_body(self):
         b = self._get_body()
@@ -403,7 +403,7 @@ class ArchivesParser(object):
             self.attachments_found_first_plaintext = True
             # No name, and text/plain, so ignore it
 
-    re_msgid = re.compile('^\s*<(.*)>\s*')
+    re_msgid = re.compile(r'^\s*<(.*)>\s*')
 
     def clean_messageid(self, messageid, ignorebroken=False):
         m = self.re_msgid.match(messageid)
@@ -416,10 +416,10 @@ class ArchivesParser(object):
 
 #    _date_multi_re = re.compile(' \((\w+\s\w+(\s+\w+)*|)\)$')
     # Now using [^\s] instead of \w, to work with japanese chars
-    _date_multi_re = re.compile(' \(([^\s]+\s[^\s]+(\s+[^\s]+)*|)\)$')
-    _date_multi_re2 = re.compile(' ([\+-]\d{4}) \([^)]+\)$')
-    _date_multiminus_re = re.compile(' -(-\d+)$')
-    _date_offsetnoplus_re = re.compile(' (\d{4})$')
+    _date_multi_re = re.compile(r' \(([^\s]+\s[^\s]+(\s+[^\s]+)*|)\)$')
+    _date_multi_re2 = re.compile(r' ([\+-]\d{4}) \([^)]+\)$')
+    _date_multiminus_re = re.compile(r' -(-\d+)$')
+    _date_offsetnoplus_re = re.compile(r' (\d{4})$')
 
     def forgiving_date_decode(self, d):
         if d.strip() == '':
@@ -503,7 +503,7 @@ class ArchivesParser(object):
         return str(s, charset and self.clean_charset(charset) or 'us-ascii', errors='ignore').strip(' ')
 
     # Workaround for broken quoting in some MUAs (see below)
-    _re_mailworkaround = re.compile('"(=\?[^\?]+\?[QB]\?[^\?]+\?=)"', re.IGNORECASE)
+    _re_mailworkaround = re.compile(r'"(=\?[^\?]+\?[QB]\?[^\?]+\?=)"', re.IGNORECASE)
 
     def _decode_mime_header(self, hdr, email_workaround):
         if hdr is None: