commit:     e7b20e89546857635e28cc05cc7cb4ab8cbd6ee7
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 26 15:06:24 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sun Jan 26 15:09:41 2020 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e7b20e89

Pass raw strings for regexp to fix DeprecationWarnings

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 pym/gentoolkit/cpv.py                     | 8 ++++----
 pym/gentoolkit/eclean/exclude.py          | 4 ++--
 pym/gentoolkit/equery/meta.py             | 2 +-
 pym/gentoolkit/helpers.py                 | 4 ++--
 pym/gentoolkit/metadata.py                | 2 +-
 pym/gentoolkit/revdep_rebuild/analyse.py  | 4 ++--
 pym/gentoolkit/revdep_rebuild/assign.py   | 2 +-
 pym/gentoolkit/revdep_rebuild/collect.py  | 2 +-
 pym/gentoolkit/revdep_rebuild/settings.py | 6 +++---
 pym/gentoolkit/test/eclean/distsupport.py | 2 +-
 pym/gentoolkit/test/eclean/test_search.py | 2 +-
 pym/gentoolkit/textwrap_.py               | 2 +-
 12 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/pym/gentoolkit/cpv.py b/pym/gentoolkit/cpv.py
index 6e272f1..169c833 100644
--- a/pym/gentoolkit/cpv.py
+++ b/pym/gentoolkit/cpv.py
@@ -28,10 +28,10 @@ from gentoolkit import errors
 # Globals
 # =======
 
-isvalid_version_re = re.compile("^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?"
-       "(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$")
-isvalid_cat_re = re.compile("^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$")
-_pkg_re = re.compile("^[a-zA-Z0-9+._]+$")
+isvalid_version_re = re.compile(r"^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?"
+       r"(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$")
+isvalid_cat_re = re.compile(r"^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$")
+_pkg_re = re.compile(r"^[a-zA-Z0-9+._]+$")
 # Prefix specific revision is of the form -r0<digit>+.<digit>+
 isvalid_rev_re = re.compile(r'(\d+|0\d+\.\d+)')
 

diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py
index 0d2d0c4..c734493 100644
--- a/pym/gentoolkit/eclean/exclude.py
+++ b/pym/gentoolkit/eclean/exclude.py
@@ -90,8 +90,8 @@ def parseExcludeFile(filepath, output):
                        filepath)
        filecontents = file_.readlines()
        file_.close()
-       cat_re = re.compile('^(?P<cat>[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$')
-       cp_re = re.compile('^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
+       cat_re = re.compile(r'^(?P<cat>[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$')
+       cp_re = re.compile(r'^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$')
        # used to output the line number for exception error reporting
        linenum = 0
        for line in filecontents:

diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py
index d08ab23..2e8f91e 100644
--- a/pym/gentoolkit/equery/meta.py
+++ b/pym/gentoolkit/equery/meta.py
@@ -428,7 +428,7 @@ def format_line(line, first="", subsequent="", 
force_quiet=False):
                twrap = TextWrapper(width=CONFIG['termWidth'], 
expand_tabs=False,
                        initial_indent=first, subsequent_indent=subsequent)
                line = " ".join(line)
-               line = re.sub("\s+", " ", line)
+               line = re.sub(r"\s+", " ", line)
                line = line.lstrip()
                result = twrap.fill(line)
        else:

diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index 40235d5..a551550 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -257,7 +257,7 @@ class FileOwner(object):
                        raise errors.GentoolkitInvalidRegex(err)
 
                use_match = False
-               if ((self.is_regex or query_re_string.startswith('^\/'))
+               if ((self.is_regex or query_re_string.startswith(r'^\/'))
                        and '|' not in query_re_string ):
                        # If we were passed a regex or a single path starting 
with root,
                        # we can use re.match, else use re.search.
@@ -350,7 +350,7 @@ class FileOwner(object):
                else:
                        result = []
                        # Trim trailing and multiple slashes from queries
-                       slashes = re.compile('/+')
+                       slashes = re.compile(r'/+')
                        queries = self.expand_abspaths(queries)
                        queries = self.extend_realpaths(queries)
                        for query in queries:

diff --git a/pym/gentoolkit/metadata.py b/pym/gentoolkit/metadata.py
index 7828bae..22c249e 100644
--- a/pym/gentoolkit/metadata.py
+++ b/pym/gentoolkit/metadata.py
@@ -105,7 +105,7 @@ class _Useflag(object):
                        _desc += child.text if child.text else ''
                        _desc += child.tail if child.tail else ''
                # This takes care of tabs and newlines left from the file
-               self.description = re.sub('\s+', ' ', _desc)
+               self.description = re.sub(r'\s+', ' ', _desc)
 
        def __repr__(self):
                return "<%s %r>" % (self.__class__.__name__, self.name)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py 
b/pym/gentoolkit/revdep_rebuild/analyse.py
index 7ddd5e9..6ca3f10 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -76,7 +76,7 @@ def extract_dependencies_from_la(la, libraries, to_check, 
logger):
 
        libnames = []
        for lib in libraries:
-               match = re.match('.+\/(.+)\.(so|la|a)(\..+)?', lib)
+               match = re.match(r'.+\/(.+)\.(so|la|a)(\..+)?', lib)
                if match is not None:
                        libname = match.group(1)
                        if libname not in libnames:
@@ -90,7 +90,7 @@ def extract_dependencies_from_la(la, libraries, to_check, 
logger):
                        encoding=_encodings['content']).readlines():
                        line = line.strip()
                        if line.startswith('dependency_libs='):
-                               match = re.match("dependency_libs='([^']+)'", 
line)
+                               match = re.match(r"dependency_libs='([^']+)'", 
line)
                                if match is not None:
                                        for el in match.group(1).split(' '):
                                                el = el.strip()

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py 
b/pym/gentoolkit/revdep_rebuild/assign.py
index 84bd59f..48c8c93 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -94,7 +94,7 @@ def assign_packages(broken, logger, settings):
                                try:
                                        with io.open(f, 'r', encoding='utf_8') 
as cnt:
                                                for line in cnt.readlines():
-                                                       m = re.match('^obj (/[^ 
]+)', line)
+                                                       m = re.match(r'^obj 
(/[^ ]+)', line)
                                                        if m is not None:
                                                                
contents_matcher.add(m.group(1))
                                except Exception as e:

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py 
b/pym/gentoolkit/revdep_rebuild/collect.py
index 9b81183..cbac878 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -84,7 +84,7 @@ def prepare_search_dirs(logger, settings):
                encoding=_encodings['content']) as _file:
                for line in _file.readlines():
                        line = line.strip()
-                       match = re.match("^export (ROOT)?PATH='([^']+)'", line)
+                       match = re.match(r"^export (ROOT)?PATH='([^']+)'", line)
                        if match is not None:
                                bin_dirs.update(set(match.group(2).split(':')))
        #except EnvironmentError:

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py 
b/pym/gentoolkit/revdep_rebuild/settings.py
index 7438594..ca8d5fa 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -151,15 +151,15 @@ def parse_revdep_config(revdep_confdir):
                        line = line.strip()
                        #first check for comment, we do not want to regex all 
lines
                        if not line.startswith('#'):
-                               match = 
re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+                               match = 
re.match(r'LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
                                if match is not None:
                                        masked_files += ' ' + match.group(1)
                                        continue
-                               match = 
re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+                               match = 
re.match(r'SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
                                if match is not None:
                                        masked_dirs += ' ' + match.group(1)
                                        continue
-                               match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', 
line)
+                               match = re.match(r'SEARCH_DIRS=\\"([^"]+)\\"', 
line)
                                if match is not None:
                                        search_dirs += ' ' + match.group(1)
                                        continue

diff --git a/pym/gentoolkit/test/eclean/distsupport.py 
b/pym/gentoolkit/test/eclean/distsupport.py
index 7b444d2..78016ba 100644
--- a/pym/gentoolkit/test/eclean/distsupport.py
+++ b/pym/gentoolkit/test/eclean/distsupport.py
@@ -328,7 +328,7 @@ Exclude= {'packages': {
        'categories': {'app-portage': None,
                'app-portage/gentoolkit': None
                },
-       'filenames': {'sys-auth/consolekit-0.4.1': 
re.compile('sys-auth/consolekit-0.4.1')
+       'filenames': {'sys-auth/consolekit-0.4.1': 
re.compile(r'sys-auth/consolekit-0\.4\.1')
                }
        }
 

diff --git a/pym/gentoolkit/test/eclean/test_search.py 
b/pym/gentoolkit/test/eclean/test_search.py
index 1720688..4533909 100755
--- a/pym/gentoolkit/test/eclean/test_search.py
+++ b/pym/gentoolkit/test/eclean/test_search.py
@@ -54,7 +54,7 @@ class TestCheckLimits(unittest.TestCase):
        test_excludes = {
                'blank': {},
                'filenames': {
-                       'filenames': {'help2man-1.37.1.tar.gz': 
re.compile('help2man-1.37.1.tar.gz')}
+                       'filenames': {'help2man-1.37.1.tar.gz': 
re.compile(r'help2man-1\.37\.1\.tar\.gz')}
                        }
                }
 

diff --git a/pym/gentoolkit/textwrap_.py b/pym/gentoolkit/textwrap_.py
index 845ae9d..07c0831 100644
--- a/pym/gentoolkit/textwrap_.py
+++ b/pym/gentoolkit/textwrap_.py
@@ -43,7 +43,7 @@ class TextWrapper(textwrap.TextWrapper):
 
                # Regex to strip ANSI escape codes. It's only used for the
                # length calculations of indent and each chuck.
-               ansi_re = re.compile('\x1b\[[0-9;]*m')
+               ansi_re = re.compile(r'\x1b\[[0-9;]*m')
 
                while chunks:
 

Reply via email to