]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Pull flags out of regular expressions 462/head
authorDavid Baumgold <david@davidbaumgold.com>
Thu, 29 Dec 2016 05:00:23 +0000 (00:00 -0500)
committerDavid Baumgold <david@davidbaumgold.com>
Thu, 29 Dec 2016 05:00:23 +0000 (00:00 -0500)
babel/localtime/_unix.py
babel/messages/catalog.py
babel/messages/jslexer.py
babel/plural.py
scripts/make-release.py

index 91f03bc993ada70caf9a85f408a8dbe1ad947336..e0b54fb28633c0a956c6fc4e69a4795851d43289 100644 (file)
@@ -5,7 +5,7 @@ import sys
 import pytz
 import subprocess
 
-_systemconfig_tz = re.compile(r'^Time Zone: (.*)$(?m)')
+_systemconfig_tz = re.compile(r'^Time Zone: (.*)$', re.MULTILINE)
 
 
 def _tz_from_env(tzenv):
index 9a474a8453b9d6224eaaedb3f8072ef978e8375f..018094ca4d4157d0cc395a475ece145b548749a7 100644 (file)
@@ -28,7 +28,7 @@ from babel._compat import string_types, number_types, PY2, cmp
 __all__ = ['Message', 'Catalog', 'TranslationError']
 
 
-PYTHON_FORMAT = re.compile(r'''(?x)
+PYTHON_FORMAT = re.compile(r'''
     \%
         (?:\(([\w]*)\))?
         (
@@ -37,7 +37,7 @@ PYTHON_FORMAT = re.compile(r'''(?x)
             [hlL]?
         )
         ([diouxXeEfFgGcrs%])
-''')
+''', re.VERBOSE)
 
 
 def _parse_datetime_header(value):
index a9bab2f2bbd60e110ce40301a8430f9268077dbf..30d6e5405b55b718c2c1e6b14138f2a777131b4c 100644 (file)
@@ -25,7 +25,7 @@ escapes = {'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t'}
 name_re = re.compile(r'[\w$_][\w\d$_]*', re.UNICODE)
 dotted_name_re = re.compile(r'[\w$_][\w\d$_.]*[\w\d$_.]', re.UNICODE)
 division_re = re.compile(r'/=?')
-regex_re = re.compile(r'/(?:[^/\\]*(?:\\.[^/\\]*)*)/[a-zA-Z]*(?s)')
+regex_re = re.compile(r'/(?:[^/\\]*(?:\\.[^/\\]*)*)/[a-zA-Z]*', re.DOTALL)
 line_re = re.compile(r'(\r\n|\n|\r)')
 line_join_re = re.compile(r'\\' + line_re.pattern)
 uni_escape_re = re.compile(r'[a-fA-F0-9]{1,4}')
@@ -33,25 +33,25 @@ uni_escape_re = re.compile(r'[a-fA-F0-9]{1,4}')
 Token = namedtuple('Token', 'type value lineno')
 
 _rules = [
-    (None, re.compile(r'\s+(?u)')),
+    (None, re.compile(r'\s+', re.UNICODE)),
     (None, re.compile(r'<!--.*')),
     ('linecomment', re.compile(r'//.*')),
-    ('multilinecomment', re.compile(r'/\*.*?\*/(?us)')),
+    ('multilinecomment', re.compile(r'/\*.*?\*/', re.UNICODE | re.DOTALL)),
     ('dotted_name', dotted_name_re),
     ('name', name_re),
-    ('number', re.compile(r'''(?x)(
+    ('number', re.compile(r'''(
         (?:0|[1-9]\d*)
         (\.\d+)?
         ([eE][-+]?\d+)? |
         (0x[a-fA-F0-9]+)
-    )''')),
+    )''', re.VERBOSE)),
     ('jsx_tag', re.compile(r'(?:</?[^>\s]+|/>)', re.I)),  # May be mangled in `get_rules`
     ('operator', re.compile(r'(%s)' % '|'.join(map(re.escape, operators)))),
     ('template_string', re.compile(r'''`(?:[^`\\]*(?:\\.[^`\\]*)*)`''', re.UNICODE)),
-    ('string', re.compile(r'''(?xs)(
+    ('string', re.compile(r'''(
         '(?:[^'\\]*(?:\\.[^'\\]*)*)'  |
         "(?:[^"\\]*(?:\\.[^"\\]*)*)"
-    )'''))
+    )''', re.VERBOSE | re.DOTALL))
 ]
 
 
index 99e9a650678deed24f82c5a992104f207d9fc46c..a23f8b53fd53cf8c31796e6a67939532f552a582 100644 (file)
@@ -321,7 +321,7 @@ class RuleError(Exception):
 _VARS = 'nivwft'
 
 _RULES = [
-    (None, re.compile(r'\s+(?u)')),
+    (None, re.compile(r'\s+', re.UNICODE)),
     ('word', re.compile(r'\b(and|or|is|(?:with)?in|not|mod|[{0}])\b'
                         .format(_VARS))),
     ('value', re.compile(r'\d+')),
index 7477ad387d2aff83f4e984faa92145e39e2518de..dc9bb31e6f8f3bca5a602d5acafa1b30064c7acc 100755 (executable)
@@ -35,7 +35,8 @@ def parse_changelog():
                     break
 
             match = re.search(r'released on (\w+\s+\d+\w+\s+\d+)'
-                              r'(?:, codename (.*))?(?i)', change_info)
+                              r'(?:, codename (.*))?', change_info,
+                              flags=re.IGNORECASE)
             if match is None:
                 continue
 
@@ -68,8 +69,9 @@ def set_filename_version(filename, version_number, pattern):
         changed.append(True)
         return before + version_number + after
     with open(filename) as f:
-        contents = re.sub(r"^(\s*%s\s*=\s*')(.+?)(')(?sm)" % pattern,
-                          inject_version, f.read())
+        contents = re.sub(r"^(\s*%s\s*=\s*')(.+?)(')" % pattern,
+                          inject_version, f.read(),
+                          flags=re.DOTALL | re.MULTILINE)
 
     if not changed:
         fail('Could not find %s in %s', pattern, filename)