1 |
commit: e7b20e89546857635e28cc05cc7cb4ab8cbd6ee7 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 26 15:06:24 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Jan 26 15:09:41 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=e7b20e89 |
7 |
|
8 |
Pass raw strings for regexp to fix DeprecationWarnings |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
pym/gentoolkit/cpv.py | 8 ++++---- |
13 |
pym/gentoolkit/eclean/exclude.py | 4 ++-- |
14 |
pym/gentoolkit/equery/meta.py | 2 +- |
15 |
pym/gentoolkit/helpers.py | 4 ++-- |
16 |
pym/gentoolkit/metadata.py | 2 +- |
17 |
pym/gentoolkit/revdep_rebuild/analyse.py | 4 ++-- |
18 |
pym/gentoolkit/revdep_rebuild/assign.py | 2 +- |
19 |
pym/gentoolkit/revdep_rebuild/collect.py | 2 +- |
20 |
pym/gentoolkit/revdep_rebuild/settings.py | 6 +++--- |
21 |
pym/gentoolkit/test/eclean/distsupport.py | 2 +- |
22 |
pym/gentoolkit/test/eclean/test_search.py | 2 +- |
23 |
pym/gentoolkit/textwrap_.py | 2 +- |
24 |
12 files changed, 20 insertions(+), 20 deletions(-) |
25 |
|
26 |
diff --git a/pym/gentoolkit/cpv.py b/pym/gentoolkit/cpv.py |
27 |
index 6e272f1..169c833 100644 |
28 |
--- a/pym/gentoolkit/cpv.py |
29 |
+++ b/pym/gentoolkit/cpv.py |
30 |
@@ -28,10 +28,10 @@ from gentoolkit import errors |
31 |
# Globals |
32 |
# ======= |
33 |
|
34 |
-isvalid_version_re = re.compile("^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?" |
35 |
- "(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$") |
36 |
-isvalid_cat_re = re.compile("^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$") |
37 |
-_pkg_re = re.compile("^[a-zA-Z0-9+._]+$") |
38 |
+isvalid_version_re = re.compile(r"^(?:cvs\\.)?(?:\\d+)(?:\\.\\d+)*[a-z]?" |
39 |
+ r"(?:_(p(?:re)?|beta|alpha|rc)\\d*)*$") |
40 |
+isvalid_cat_re = re.compile(r"^(?:[a-zA-Z0-9][-a-zA-Z0-9+._]*(?:/(?!$))?)+$") |
41 |
+_pkg_re = re.compile(r"^[a-zA-Z0-9+._]+$") |
42 |
# Prefix specific revision is of the form -r0<digit>+.<digit>+ |
43 |
isvalid_rev_re = re.compile(r'(\d+|0\d+\.\d+)') |
44 |
|
45 |
|
46 |
diff --git a/pym/gentoolkit/eclean/exclude.py b/pym/gentoolkit/eclean/exclude.py |
47 |
index 0d2d0c4..c734493 100644 |
48 |
--- a/pym/gentoolkit/eclean/exclude.py |
49 |
+++ b/pym/gentoolkit/eclean/exclude.py |
50 |
@@ -90,8 +90,8 @@ def parseExcludeFile(filepath, output): |
51 |
filepath) |
52 |
filecontents = file_.readlines() |
53 |
file_.close() |
54 |
- cat_re = re.compile('^(?P<cat>[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$') |
55 |
- cp_re = re.compile('^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$') |
56 |
+ cat_re = re.compile(r'^(?P<cat>[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$') |
57 |
+ cp_re = re.compile(r'^(?P<cp>[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$') |
58 |
# used to output the line number for exception error reporting |
59 |
linenum = 0 |
60 |
for line in filecontents: |
61 |
|
62 |
diff --git a/pym/gentoolkit/equery/meta.py b/pym/gentoolkit/equery/meta.py |
63 |
index d08ab23..2e8f91e 100644 |
64 |
--- a/pym/gentoolkit/equery/meta.py |
65 |
+++ b/pym/gentoolkit/equery/meta.py |
66 |
@@ -428,7 +428,7 @@ def format_line(line, first="", subsequent="", force_quiet=False): |
67 |
twrap = TextWrapper(width=CONFIG['termWidth'], expand_tabs=False, |
68 |
initial_indent=first, subsequent_indent=subsequent) |
69 |
line = " ".join(line) |
70 |
- line = re.sub("\s+", " ", line) |
71 |
+ line = re.sub(r"\s+", " ", line) |
72 |
line = line.lstrip() |
73 |
result = twrap.fill(line) |
74 |
else: |
75 |
|
76 |
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py |
77 |
index 40235d5..a551550 100644 |
78 |
--- a/pym/gentoolkit/helpers.py |
79 |
+++ b/pym/gentoolkit/helpers.py |
80 |
@@ -257,7 +257,7 @@ class FileOwner(object): |
81 |
raise errors.GentoolkitInvalidRegex(err) |
82 |
|
83 |
use_match = False |
84 |
- if ((self.is_regex or query_re_string.startswith('^\/')) |
85 |
+ if ((self.is_regex or query_re_string.startswith(r'^\/')) |
86 |
and '|' not in query_re_string ): |
87 |
# If we were passed a regex or a single path starting with root, |
88 |
# we can use re.match, else use re.search. |
89 |
@@ -350,7 +350,7 @@ class FileOwner(object): |
90 |
else: |
91 |
result = [] |
92 |
# Trim trailing and multiple slashes from queries |
93 |
- slashes = re.compile('/+') |
94 |
+ slashes = re.compile(r'/+') |
95 |
queries = self.expand_abspaths(queries) |
96 |
queries = self.extend_realpaths(queries) |
97 |
for query in queries: |
98 |
|
99 |
diff --git a/pym/gentoolkit/metadata.py b/pym/gentoolkit/metadata.py |
100 |
index 7828bae..22c249e 100644 |
101 |
--- a/pym/gentoolkit/metadata.py |
102 |
+++ b/pym/gentoolkit/metadata.py |
103 |
@@ -105,7 +105,7 @@ class _Useflag(object): |
104 |
_desc += child.text if child.text else '' |
105 |
_desc += child.tail if child.tail else '' |
106 |
# This takes care of tabs and newlines left from the file |
107 |
- self.description = re.sub('\s+', ' ', _desc) |
108 |
+ self.description = re.sub(r'\s+', ' ', _desc) |
109 |
|
110 |
def __repr__(self): |
111 |
return "<%s %r>" % (self.__class__.__name__, self.name) |
112 |
|
113 |
diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py |
114 |
index 7ddd5e9..6ca3f10 100644 |
115 |
--- a/pym/gentoolkit/revdep_rebuild/analyse.py |
116 |
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py |
117 |
@@ -76,7 +76,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger): |
118 |
|
119 |
libnames = [] |
120 |
for lib in libraries: |
121 |
- match = re.match('.+\/(.+)\.(so|la|a)(\..+)?', lib) |
122 |
+ match = re.match(r'.+\/(.+)\.(so|la|a)(\..+)?', lib) |
123 |
if match is not None: |
124 |
libname = match.group(1) |
125 |
if libname not in libnames: |
126 |
@@ -90,7 +90,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger): |
127 |
encoding=_encodings['content']).readlines(): |
128 |
line = line.strip() |
129 |
if line.startswith('dependency_libs='): |
130 |
- match = re.match("dependency_libs='([^']+)'", line) |
131 |
+ match = re.match(r"dependency_libs='([^']+)'", line) |
132 |
if match is not None: |
133 |
for el in match.group(1).split(' '): |
134 |
el = el.strip() |
135 |
|
136 |
diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py |
137 |
index 84bd59f..48c8c93 100644 |
138 |
--- a/pym/gentoolkit/revdep_rebuild/assign.py |
139 |
+++ b/pym/gentoolkit/revdep_rebuild/assign.py |
140 |
@@ -94,7 +94,7 @@ def assign_packages(broken, logger, settings): |
141 |
try: |
142 |
with io.open(f, 'r', encoding='utf_8') as cnt: |
143 |
for line in cnt.readlines(): |
144 |
- m = re.match('^obj (/[^ ]+)', line) |
145 |
+ m = re.match(r'^obj (/[^ ]+)', line) |
146 |
if m is not None: |
147 |
contents_matcher.add(m.group(1)) |
148 |
except Exception as e: |
149 |
|
150 |
diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py |
151 |
index 9b81183..cbac878 100644 |
152 |
--- a/pym/gentoolkit/revdep_rebuild/collect.py |
153 |
+++ b/pym/gentoolkit/revdep_rebuild/collect.py |
154 |
@@ -84,7 +84,7 @@ def prepare_search_dirs(logger, settings): |
155 |
encoding=_encodings['content']) as _file: |
156 |
for line in _file.readlines(): |
157 |
line = line.strip() |
158 |
- match = re.match("^export (ROOT)?PATH='([^']+)'", line) |
159 |
+ match = re.match(r"^export (ROOT)?PATH='([^']+)'", line) |
160 |
if match is not None: |
161 |
bin_dirs.update(set(match.group(2).split(':'))) |
162 |
#except EnvironmentError: |
163 |
|
164 |
diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py |
165 |
index 7438594..ca8d5fa 100644 |
166 |
--- a/pym/gentoolkit/revdep_rebuild/settings.py |
167 |
+++ b/pym/gentoolkit/revdep_rebuild/settings.py |
168 |
@@ -151,15 +151,15 @@ def parse_revdep_config(revdep_confdir): |
169 |
line = line.strip() |
170 |
#first check for comment, we do not want to regex all lines |
171 |
if not line.startswith('#'): |
172 |
- match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line) |
173 |
+ match = re.match(r'LD_LIBRARY_MASK=\\"([^"]+)\\"', line) |
174 |
if match is not None: |
175 |
masked_files += ' ' + match.group(1) |
176 |
continue |
177 |
- match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line) |
178 |
+ match = re.match(r'SEARCH_DIRS_MASK=\\"([^"]+)\\"', line) |
179 |
if match is not None: |
180 |
masked_dirs += ' ' + match.group(1) |
181 |
continue |
182 |
- match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line) |
183 |
+ match = re.match(r'SEARCH_DIRS=\\"([^"]+)\\"', line) |
184 |
if match is not None: |
185 |
search_dirs += ' ' + match.group(1) |
186 |
continue |
187 |
|
188 |
diff --git a/pym/gentoolkit/test/eclean/distsupport.py b/pym/gentoolkit/test/eclean/distsupport.py |
189 |
index 7b444d2..78016ba 100644 |
190 |
--- a/pym/gentoolkit/test/eclean/distsupport.py |
191 |
+++ b/pym/gentoolkit/test/eclean/distsupport.py |
192 |
@@ -328,7 +328,7 @@ Exclude= {'packages': { |
193 |
'categories': {'app-portage': None, |
194 |
'app-portage/gentoolkit': None |
195 |
}, |
196 |
- 'filenames': {'sys-auth/consolekit-0.4.1': re.compile('sys-auth/consolekit-0.4.1') |
197 |
+ 'filenames': {'sys-auth/consolekit-0.4.1': re.compile(r'sys-auth/consolekit-0\.4\.1') |
198 |
} |
199 |
} |
200 |
|
201 |
|
202 |
diff --git a/pym/gentoolkit/test/eclean/test_search.py b/pym/gentoolkit/test/eclean/test_search.py |
203 |
index 1720688..4533909 100755 |
204 |
--- a/pym/gentoolkit/test/eclean/test_search.py |
205 |
+++ b/pym/gentoolkit/test/eclean/test_search.py |
206 |
@@ -54,7 +54,7 @@ class TestCheckLimits(unittest.TestCase): |
207 |
test_excludes = { |
208 |
'blank': {}, |
209 |
'filenames': { |
210 |
- 'filenames': {'help2man-1.37.1.tar.gz': re.compile('help2man-1.37.1.tar.gz')} |
211 |
+ 'filenames': {'help2man-1.37.1.tar.gz': re.compile(r'help2man-1\.37\.1\.tar\.gz')} |
212 |
} |
213 |
} |
214 |
|
215 |
|
216 |
diff --git a/pym/gentoolkit/textwrap_.py b/pym/gentoolkit/textwrap_.py |
217 |
index 845ae9d..07c0831 100644 |
218 |
--- a/pym/gentoolkit/textwrap_.py |
219 |
+++ b/pym/gentoolkit/textwrap_.py |
220 |
@@ -43,7 +43,7 @@ class TextWrapper(textwrap.TextWrapper): |
221 |
|
222 |
# Regex to strip ANSI escape codes. It's only used for the |
223 |
# length calculations of indent and each chuck. |
224 |
- ansi_re = re.compile('\x1b\[[0-9;]*m') |
225 |
+ ansi_re = re.compile(r'\x1b\[[0-9;]*m') |
226 |
|
227 |
while chunks: |