Merge ~cjwatson/launchpad:py3only-scandir into launchpad:master
- Git
- lp:~cjwatson/launchpad
- py3only-scandir
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | bd40ffed732d70beeb73eee14afc67a1bd14fc44 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:py3only-scandir |
Merge into: | launchpad:master |
Diff against target: |
942 lines (+50/-99) 41 files modified
configs/development/gunicorn.conf.py (+1/-3) lib/lp/archivepublisher/customupload.py (+2/-3) lib/lp/archivepublisher/model/ftparchive.py (+1/-2) lib/lp/archivepublisher/publishing.py (+4/-5) lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+1/-2) lib/lp/archivepublisher/signing.py (+1/-2) lib/lp/archivepublisher/tests/test_publisher.py (+1/-2) lib/lp/archivepublisher/tests/test_signing.py (+1/-2) lib/lp/archiveuploader/charmrecipeupload.py (+1/-2) lib/lp/archiveuploader/dscfile.py (+1/-2) lib/lp/archiveuploader/livefsupload.py (+1/-2) lib/lp/archiveuploader/ocirecipeupload.py (+1/-2) lib/lp/archiveuploader/snapupload.py (+1/-2) lib/lp/archiveuploader/uploadprocessor.py (+2/-3) lib/lp/bugs/tests/test_doc.py (+1/-3) lib/lp/registry/model/codeofconduct.py (+1/-2) lib/lp/registry/scripts/productreleasefinder/walker.py (+4/-4) lib/lp/scripts/utilities/js/jsbuild.py (+3/-4) lib/lp/services/config/fixture.py (+1/-2) lib/lp/services/config/tests/test_config.py (+1/-2) lib/lp/services/librarianserver/librariangc.py (+2/-3) lib/lp/services/librarianserver/swift.py (+1/-3) lib/lp/services/mail/mailbox.py (+1/-2) lib/lp/services/scripts/tests/__init__.py (+1/-3) lib/lp/services/testing/__init__.py (+1/-3) lib/lp/services/webservice/tests/test_wadllib.py (+1/-2) lib/lp/soyuz/doc/soyuz-set-of-uploads.txt (+1/-3) lib/lp/soyuz/doc/soyuz-upload.txt (+1/-2) lib/lp/soyuz/scripts/gina/packages.py (+1/-2) lib/lp/soyuz/tests/fakepackager.py (+1/-2) lib/lp/soyuz/tests/test_doc.py (+1/-2) lib/lp/soyuz/tests/test_publishing.py (+1/-2) lib/lp/testing/__init__.py (+1/-2) lib/lp/testing/gpgkeys/__init__.py (+1/-2) lib/lp/testing/yuixhr.py (+1/-2) lib/lp/testopenid/stories/tests.py (+1/-3) lib/lp/tests/test_opensource.py (+1/-2) lib/lp/translations/tests/test_doc.py (+1/-3) requirements/launchpad.txt (+0/-1) scripts/migrate-librarian-content-md5.py (+1/-3) setup.py (+0/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cristian Gonzalez (community) | Approve | ||
Review via email: mp+407246@code.launchpad.net |
Commit message
Use os.scandir and os.walk directly
Description of the change
The separate `scandir` module was a backport of the same code to Python versions earlier than 3.5, and is no longer needed.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/configs/development/gunicorn.conf.py b/configs/development/gunicorn.conf.py |
2 | index 0576e0d..2c914aa 100644 |
3 | --- a/configs/development/gunicorn.conf.py |
4 | +++ b/configs/development/gunicorn.conf.py |
5 | @@ -1,8 +1,6 @@ |
6 | from fnmatch import fnmatch |
7 | import os |
8 | |
9 | -import scandir |
10 | - |
11 | |
12 | BASE_DIR = os.path.realpath( |
13 | os.path.join(os.path.dirname(__file__), '..', '..')) |
14 | @@ -13,7 +11,7 @@ def find_files(directory, pattern): |
15 | """Find files in `directory` matching `pattern`. |
16 | """ |
17 | result = [] |
18 | - for root, dirs, files in scandir.walk(directory): |
19 | + for root, dirs, files in os.walk(directory): |
20 | for basename in files: |
21 | matches = fnmatch(basename, pattern) |
22 | if matches: |
23 | diff --git a/lib/lp/archivepublisher/customupload.py b/lib/lp/archivepublisher/customupload.py |
24 | index 741211a..42dfea3 100644 |
25 | --- a/lib/lp/archivepublisher/customupload.py |
26 | +++ b/lib/lp/archivepublisher/customupload.py |
27 | @@ -20,7 +20,6 @@ import shutil |
28 | import tarfile |
29 | import tempfile |
30 | |
31 | -import scandir |
32 | from zope.interface import implementer |
33 | |
34 | from lp.archivepublisher.debversion import ( |
35 | @@ -290,7 +289,7 @@ class CustomUpload: |
36 | """Install the files from the custom upload to the archive.""" |
37 | assert self.tmpdir is not None, "Must extract tarfile first" |
38 | extracted = False |
39 | - for dirpath, dirnames, filenames in scandir.walk(self.tmpdir): |
40 | + for dirpath, dirnames, filenames in os.walk(self.tmpdir): |
41 | |
42 | # Create symbolic links to directories. |
43 | for dirname in dirnames: |
44 | @@ -359,7 +358,7 @@ class CustomUpload: |
45 | # now present in the target. Deliberately skip 'broken' versions |
46 | # because they can't be sorted anyway. |
47 | versions = [] |
48 | - for entry in scandir.scandir(self.targetdir): |
49 | + for entry in os.scandir(self.targetdir): |
50 | # Skip the symlink. |
51 | if entry.name == 'current': |
52 | continue |
53 | diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py |
54 | index 624aebf..d56b881 100644 |
55 | --- a/lib/lp/archivepublisher/model/ftparchive.py |
56 | +++ b/lib/lp/archivepublisher/model/ftparchive.py |
57 | @@ -6,7 +6,6 @@ import os |
58 | import re |
59 | import time |
60 | |
61 | -import scandir |
62 | import six |
63 | from storm.expr import ( |
64 | Desc, |
65 | @@ -61,7 +60,7 @@ def make_clean_dir(path, clean_pattern=".*"): |
66 | If omitted, all files are removed. |
67 | """ |
68 | if os.path.isdir(path): |
69 | - for entry in list(scandir.scandir(path)): |
70 | + for entry in list(os.scandir(path)): |
71 | if (entry.name == "by-hash" or |
72 | not re.match(clean_pattern, entry.name)): |
73 | # Ignore existing by-hash directories; they will be cleaned |
74 | diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py |
75 | index 0975176..daea42c 100644 |
76 | --- a/lib/lp/archivepublisher/publishing.py |
77 | +++ b/lib/lp/archivepublisher/publishing.py |
78 | @@ -36,7 +36,6 @@ from debian.deb822 import ( |
79 | _multivalued, |
80 | Release, |
81 | ) |
82 | -import scandir |
83 | import six |
84 | from storm.expr import Desc |
85 | from zope.component import getUtility |
86 | @@ -358,7 +357,7 @@ class ByHash: |
87 | hash_path = os.path.join(self.path, archive_hash.apt_name) |
88 | if os.path.exists(hash_path): |
89 | prune_hash_directory = True |
90 | - for entry in list(scandir.scandir(hash_path)): |
91 | + for entry in list(os.scandir(hash_path)): |
92 | if entry.name not in self.known_digests[ |
93 | archive_hash.apt_name]: |
94 | self.log.debug( |
95 | @@ -1189,7 +1188,7 @@ class Publisher(object): |
96 | distroseries, pocket, component, core_files) |
97 | dep11_dir = os.path.join(suite_dir, component, "dep11") |
98 | try: |
99 | - for entry in scandir.scandir(dep11_dir): |
100 | + for entry in os.scandir(dep11_dir): |
101 | if (entry.name.startswith("Components-") or |
102 | entry.name.startswith("icons-")): |
103 | dep11_path = os.path.join( |
104 | @@ -1355,7 +1354,7 @@ class Publisher(object): |
105 | i18n_dir = os.path.join(self._config.distsroot, suite, i18n_subpath) |
106 | i18n_files = set() |
107 | try: |
108 | - for entry in scandir.scandir(i18n_dir): |
109 | + for entry in os.scandir(i18n_dir): |
110 | if not entry.name.startswith('Translation-'): |
111 | continue |
112 | i18n_files.add(remove_suffix(entry.name)) |
113 | @@ -1556,7 +1555,7 @@ class DirectoryHash: |
114 | |
115 | def add_dir(self, path): |
116 | """Recursively add a directory path to be checksummed.""" |
117 | - for dirpath, dirnames, filenames in scandir.walk(path): |
118 | + for dirpath, dirnames, filenames in os.walk(path): |
119 | for filename in filenames: |
120 | self.add(os.path.join(dirpath, filename)) |
121 | |
122 | diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py |
123 | index 5326141..25c7a21 100644 |
124 | --- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py |
125 | +++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py |
126 | @@ -14,7 +14,6 @@ import os |
127 | import shutil |
128 | |
129 | from pytz import utc |
130 | -import scandir |
131 | import six |
132 | from zope.component import getUtility |
133 | |
134 | @@ -471,7 +470,7 @@ class PublishFTPMaster(LaunchpadCronScript): |
135 | backup_top = os.path.join(get_backup_dists(archive_config), suite) |
136 | staging_top = os.path.join(archive_config.stagingroot, suite) |
137 | updated = False |
138 | - for staging_dir, _, filenames in scandir.walk(staging_top): |
139 | + for staging_dir, _, filenames in os.walk(staging_top): |
140 | rel_dir = os.path.relpath(staging_dir, staging_top) |
141 | backup_dir = os.path.join(backup_top, rel_dir) |
142 | for filename in filenames: |
143 | diff --git a/lib/lp/archivepublisher/signing.py b/lib/lp/archivepublisher/signing.py |
144 | index ec61b95..2a2f08d 100644 |
145 | --- a/lib/lp/archivepublisher/signing.py |
146 | +++ b/lib/lp/archivepublisher/signing.py |
147 | @@ -27,7 +27,6 @@ import tempfile |
148 | import textwrap |
149 | |
150 | from pytz import utc |
151 | -import scandir |
152 | from zope.component import getUtility |
153 | |
154 | from lp.archivepublisher.config import getPubConfig |
155 | @@ -282,7 +281,7 @@ class SigningUpload(CustomUpload): |
156 | SigningKeyType.FIT: self.signFit, |
157 | } |
158 | |
159 | - for dirpath, dirnames, filenames in scandir.walk(self.tmpdir): |
160 | + for dirpath, dirnames, filenames in os.walk(self.tmpdir): |
161 | for filename in filenames: |
162 | file_path = os.path.join(dirpath, filename) |
163 | if filename.endswith(".efi"): |
164 | diff --git a/lib/lp/archivepublisher/tests/test_publisher.py b/lib/lp/archivepublisher/tests/test_publisher.py |
165 | index f2c62cf..9000e9d 100644 |
166 | --- a/lib/lp/archivepublisher/tests/test_publisher.py |
167 | +++ b/lib/lp/archivepublisher/tests/test_publisher.py |
168 | @@ -32,7 +32,6 @@ from unittest import mock |
169 | from debian.deb822 import Release |
170 | from fixtures import MonkeyPatch |
171 | import pytz |
172 | -import scandir |
173 | import six |
174 | from testscenarios import ( |
175 | load_tests_apply_scenarios, |
176 | @@ -512,7 +511,7 @@ class ByHashesHaveContents(Matcher): |
177 | |
178 | def match(self, root): |
179 | children = set() |
180 | - for dirpath, dirnames, _ in scandir.walk(root): |
181 | + for dirpath, dirnames, _ in os.walk(root): |
182 | if "by-hash" in dirnames: |
183 | children.add(os.path.relpath(dirpath, root)) |
184 | mismatch = MatchesSetwise( |
185 | diff --git a/lib/lp/archivepublisher/tests/test_signing.py b/lib/lp/archivepublisher/tests/test_signing.py |
186 | index 95e314a..20ba90e 100644 |
187 | --- a/lib/lp/archivepublisher/tests/test_signing.py |
188 | +++ b/lib/lp/archivepublisher/tests/test_signing.py |
189 | @@ -18,7 +18,6 @@ from fixtures import ( |
190 | MonkeyPatch, |
191 | ) |
192 | from pytz import utc |
193 | -import scandir |
194 | import six |
195 | from testtools.matchers import ( |
196 | Contains, |
197 | @@ -79,7 +78,7 @@ class SignedMatches(Matcher): |
198 | |
199 | def match(self, base): |
200 | content = [] |
201 | - for root, dirs, files in scandir.walk(base): |
202 | + for root, dirs, files in os.walk(base): |
203 | content.extend( |
204 | [os.path.relpath(os.path.join(root, f), base) for f in files]) |
205 | |
206 | diff --git a/lib/lp/archiveuploader/charmrecipeupload.py b/lib/lp/archiveuploader/charmrecipeupload.py |
207 | index d31e8f1..e4da3e7 100644 |
208 | --- a/lib/lp/archiveuploader/charmrecipeupload.py |
209 | +++ b/lib/lp/archiveuploader/charmrecipeupload.py |
210 | @@ -10,7 +10,6 @@ __all__ = [ |
211 | |
212 | import os |
213 | |
214 | -import scandir |
215 | from zope.component import getUtility |
216 | |
217 | from lp.archiveuploader.utils import UploadError |
218 | @@ -39,7 +38,7 @@ class CharmRecipeUpload: |
219 | |
220 | found_charm = False |
221 | charm_paths = [] |
222 | - for dirpath, _, filenames in scandir.walk(self.upload_path): |
223 | + for dirpath, _, filenames in os.walk(self.upload_path): |
224 | if dirpath == self.upload_path: |
225 | # All relevant files will be in a subdirectory. |
226 | continue |
227 | diff --git a/lib/lp/archiveuploader/dscfile.py b/lib/lp/archiveuploader/dscfile.py |
228 | index ba47bd3..7efbc85 100644 |
229 | --- a/lib/lp/archiveuploader/dscfile.py |
230 | +++ b/lib/lp/archiveuploader/dscfile.py |
231 | @@ -30,7 +30,6 @@ from debian.deb822 import ( |
232 | Deb822Dict, |
233 | PkgRelation, |
234 | ) |
235 | -import scandir |
236 | import six |
237 | from zope.component import getUtility |
238 | |
239 | @@ -617,7 +616,7 @@ class DSCFile(SourceUploadFile, SignableTagFile): |
240 | |
241 | # Check if 'dpkg-source' created only one directory. |
242 | temp_directories = [ |
243 | - entry.name for entry in scandir.scandir(unpacked_dir) |
244 | + entry.name for entry in os.scandir(unpacked_dir) |
245 | if entry.is_dir()] |
246 | if len(temp_directories) > 1: |
247 | yield UploadError( |
248 | diff --git a/lib/lp/archiveuploader/livefsupload.py b/lib/lp/archiveuploader/livefsupload.py |
249 | index 4034db4..7eedbe3 100644 |
250 | --- a/lib/lp/archiveuploader/livefsupload.py |
251 | +++ b/lib/lp/archiveuploader/livefsupload.py |
252 | @@ -7,7 +7,6 @@ __metaclass__ = type |
253 | |
254 | import os |
255 | |
256 | -import scandir |
257 | from zope.component import getUtility |
258 | |
259 | from lp.buildmaster.enums import BuildStatus |
260 | @@ -37,7 +36,7 @@ class LiveFSUpload: |
261 | """Process this upload, loading it into the database.""" |
262 | self.logger.debug("Beginning processing.") |
263 | |
264 | - for dirpath, _, filenames in scandir.walk(self.upload_path): |
265 | + for dirpath, _, filenames in os.walk(self.upload_path): |
266 | if dirpath == self.upload_path: |
267 | # All relevant files will be in a subdirectory. |
268 | continue |
269 | diff --git a/lib/lp/archiveuploader/ocirecipeupload.py b/lib/lp/archiveuploader/ocirecipeupload.py |
270 | index cd99962..516ef90 100644 |
271 | --- a/lib/lp/archiveuploader/ocirecipeupload.py |
272 | +++ b/lib/lp/archiveuploader/ocirecipeupload.py |
273 | @@ -10,7 +10,6 @@ __all__ = ['OCIRecipeUpload'] |
274 | import json |
275 | import os |
276 | |
277 | -import scandir |
278 | from zope.component import getUtility |
279 | |
280 | from lp.archiveuploader.utils import UploadError |
281 | @@ -39,7 +38,7 @@ class OCIRecipeUpload: |
282 | self.logger.debug("Beginning processing.") |
283 | |
284 | # Find digest file |
285 | - for dirpath, _, filenames in scandir.walk(self.upload_path): |
286 | + for dirpath, _, filenames in os.walk(self.upload_path): |
287 | if dirpath == self.upload_path: |
288 | # All relevant files will be in a subdirectory. |
289 | continue |
290 | diff --git a/lib/lp/archiveuploader/snapupload.py b/lib/lp/archiveuploader/snapupload.py |
291 | index e8b7bff..a2b4059 100644 |
292 | --- a/lib/lp/archiveuploader/snapupload.py |
293 | +++ b/lib/lp/archiveuploader/snapupload.py |
294 | @@ -7,7 +7,6 @@ __metaclass__ = type |
295 | |
296 | import os |
297 | |
298 | -import scandir |
299 | from zope.component import getUtility |
300 | |
301 | from lp.archiveuploader.utils import UploadError |
302 | @@ -40,7 +39,7 @@ class SnapUpload: |
303 | |
304 | found_snap = False |
305 | snap_paths = [] |
306 | - for dirpath, _, filenames in scandir.walk(self.upload_path): |
307 | + for dirpath, _, filenames in os.walk(self.upload_path): |
308 | if dirpath == self.upload_path: |
309 | # All relevant files will be in a subdirectory. |
310 | continue |
311 | diff --git a/lib/lp/archiveuploader/uploadprocessor.py b/lib/lp/archiveuploader/uploadprocessor.py |
312 | index 54510c7..0c8911b 100644 |
313 | --- a/lib/lp/archiveuploader/uploadprocessor.py |
314 | +++ b/lib/lp/archiveuploader/uploadprocessor.py |
315 | @@ -51,7 +51,6 @@ import os |
316 | import shutil |
317 | import sys |
318 | |
319 | -import scandir |
320 | from sqlobject import SQLObjectNotFound |
321 | from zope.component import getUtility |
322 | |
323 | @@ -215,7 +214,7 @@ class UploadProcessor: |
324 | alphabetically sorted. |
325 | """ |
326 | return sorted( |
327 | - entry.name for entry in scandir.scandir(fsroot) if entry.is_dir()) |
328 | + entry.name for entry in os.scandir(fsroot) if entry.is_dir()) |
329 | |
330 | |
331 | class UploadHandler: |
332 | @@ -262,7 +261,7 @@ class UploadHandler: |
333 | """ |
334 | changes_files = [] |
335 | |
336 | - for dirpath, dirnames, filenames in scandir.walk(self.upload_path): |
337 | + for dirpath, dirnames, filenames in os.walk(self.upload_path): |
338 | relative_path = dirpath[len(self.upload_path) + 1:] |
339 | for filename in filenames: |
340 | if filename.endswith(".changes"): |
341 | diff --git a/lib/lp/bugs/tests/test_doc.py b/lib/lp/bugs/tests/test_doc.py |
342 | index 627025b..78f8cbf 100644 |
343 | --- a/lib/lp/bugs/tests/test_doc.py |
344 | +++ b/lib/lp/bugs/tests/test_doc.py |
345 | @@ -9,8 +9,6 @@ import logging |
346 | import os |
347 | import unittest |
348 | |
349 | -import scandir |
350 | - |
351 | from lp.code.tests.test_doc import branchscannerSetUp |
352 | from lp.services.config import config |
353 | from lp.services.features.testing import FeatureFixture |
354 | @@ -484,7 +482,7 @@ def test_suite(): |
355 | stories_dir = os.path.join(os.path.pardir, 'stories') |
356 | suite.addTest(PageTestSuite(stories_dir)) |
357 | stories_path = os.path.join(here, stories_dir) |
358 | - for story_entry in scandir.scandir(stories_path): |
359 | + for story_entry in os.scandir(stories_path): |
360 | if not story_entry.is_dir(): |
361 | continue |
362 | story_path = os.path.join(stories_dir, story_entry.name) |
363 | diff --git a/lib/lp/registry/model/codeofconduct.py b/lib/lp/registry/model/codeofconduct.py |
364 | index 7fae872..f4eca01 100644 |
365 | --- a/lib/lp/registry/model/codeofconduct.py |
366 | +++ b/lib/lp/registry/model/codeofconduct.py |
367 | @@ -14,7 +14,6 @@ from datetime import datetime |
368 | import os |
369 | |
370 | import pytz |
371 | -import scandir |
372 | import six |
373 | from storm.locals import ( |
374 | Bool, |
375 | @@ -154,7 +153,7 @@ class CodeOfConductSet: |
376 | cocs_path = getUtility(ICodeOfConductConf).path |
377 | |
378 | # iter through files and store the CoC Object |
379 | - for entry in scandir.scandir(cocs_path): |
380 | + for entry in os.scandir(cocs_path): |
381 | # Select the correct filenames |
382 | if entry.name.endswith('.txt'): |
383 | # Extract the version from filename |
384 | diff --git a/lib/lp/registry/scripts/productreleasefinder/walker.py b/lib/lp/registry/scripts/productreleasefinder/walker.py |
385 | index 6dff7de..9dfbbf0 100644 |
386 | --- a/lib/lp/registry/scripts/productreleasefinder/walker.py |
387 | +++ b/lib/lp/registry/scripts/productreleasefinder/walker.py |
388 | @@ -13,6 +13,7 @@ __all__ = [ |
389 | ] |
390 | |
391 | import ftplib |
392 | +import os |
393 | import socket |
394 | |
395 | from lazr.uri import ( |
396 | @@ -20,7 +21,6 @@ from lazr.uri import ( |
397 | URI, |
398 | ) |
399 | import requests |
400 | -import scandir |
401 | from six.moves.urllib.parse import ( |
402 | unquote_plus, |
403 | urljoin, |
404 | @@ -55,7 +55,7 @@ class WalkerBase: |
405 | """Base class for URL walkers. |
406 | |
407 | This class is a base class for those wishing to implement protocol |
408 | - specific walkers. Walkers behave much like the scandir.walk() function, |
409 | + specific walkers. Walkers behave much like the os.walk() function, |
410 | but taking a URL and working remotely. |
411 | |
412 | A typical usage would be: |
413 | @@ -108,7 +108,7 @@ class WalkerBase: |
414 | """Walk through the URL. |
415 | |
416 | Yields (dirpath, dirnames, filenames) for each path under the base; |
417 | - dirnames can be modified as with scandir.walk. |
418 | + dirnames can be modified as with os.walk. |
419 | """ |
420 | try: |
421 | self.open() |
422 | @@ -384,7 +384,7 @@ def walk(url, log_parent=None): |
423 | elif scheme in ["http", "https"]: |
424 | return HTTPWalker(url, log_parent) |
425 | elif scheme in ["file"]: |
426 | - return scandir.walk(path) |
427 | + return os.walk(path) |
428 | else: |
429 | raise WalkerError("Unknown scheme: %s" % scheme) |
430 | |
431 | diff --git a/lib/lp/scripts/utilities/js/jsbuild.py b/lib/lp/scripts/utilities/js/jsbuild.py |
432 | index 5b7bde8..77ce702 100644 |
433 | --- a/lib/lp/scripts/utilities/js/jsbuild.py |
434 | +++ b/lib/lp/scripts/utilities/js/jsbuild.py |
435 | @@ -16,7 +16,6 @@ import sys |
436 | |
437 | import cssutils |
438 | from cssutils import settings |
439 | -import scandir |
440 | |
441 | |
442 | HERE = os.path.dirname(__file__) |
443 | @@ -256,7 +255,7 @@ class Builder: |
444 | return |
445 | |
446 | # Process sub-skins. |
447 | - for entry in scandir.scandir(src_skins_dir): |
448 | + for entry in os.scandir(src_skins_dir): |
449 | self.build_skin(component_name, entry.name) |
450 | |
451 | def link_directory_content(self, src_dir, target_dir, link_filter=None): |
452 | @@ -269,7 +268,7 @@ class Builder: |
453 | If the filter returns False, no symlink will be created. By |
454 | default a symlink is created for everything. |
455 | """ |
456 | - for entry in scandir.scandir(src_dir): |
457 | + for entry in os.scandir(src_dir): |
458 | if entry.name.endswith('~'): |
459 | continue |
460 | if link_filter and not link_filter(entry.path): |
461 | @@ -334,7 +333,7 @@ class Builder: |
462 | def do_build(self): |
463 | # We need this to be both repeatable and in the desired order |
464 | dir_list = sorted( |
465 | - scandir.scandir(self.src_dir), |
466 | + os.scandir(self.src_dir), |
467 | key=lambda x: x.name.lower(), |
468 | reverse=True) |
469 | for entry in dir_list: |
470 | diff --git a/lib/lp/services/config/fixture.py b/lib/lp/services/config/fixture.py |
471 | index 9be9e0b..698ceea 100644 |
472 | --- a/lib/lp/services/config/fixture.py |
473 | +++ b/lib/lp/services/config/fixture.py |
474 | @@ -18,7 +18,6 @@ import shutil |
475 | from textwrap import dedent |
476 | |
477 | from fixtures import Fixture |
478 | -import scandir |
479 | |
480 | from lp.services.config import config |
481 | |
482 | @@ -125,7 +124,7 @@ class ConfigFixture(Fixture): |
483 | self.absroot = os.path.abspath(root) |
484 | self.addCleanup(shutil.rmtree, self.absroot) |
485 | source = os.path.join(config.root, 'configs', self.copy_from_instance) |
486 | - for entry in scandir.scandir(source): |
487 | + for entry in os.scandir(source): |
488 | if entry.name == 'launchpad-lazr.conf': |
489 | self.add_section(self._extend_str % self.copy_from_instance) |
490 | continue |
491 | diff --git a/lib/lp/services/config/tests/test_config.py b/lib/lp/services/config/tests/test_config.py |
492 | index 519d634..2906e4b 100644 |
493 | --- a/lib/lp/services/config/tests/test_config.py |
494 | +++ b/lib/lp/services/config/tests/test_config.py |
495 | @@ -18,7 +18,6 @@ import unittest |
496 | from fixtures import TempDir |
497 | from lazr.config import ConfigSchema |
498 | from lazr.config.interfaces import ConfigErrors |
499 | -import scandir |
500 | import testtools |
501 | |
502 | import lp.services.config |
503 | @@ -136,7 +135,7 @@ def test_suite(): |
504 | load_testcase = unittest.defaultTestLoader.loadTestsFromTestCase |
505 | # Add a test for every launchpad[.lazr].conf file in our tree. |
506 | for config_dir in lp.services.config.CONFIG_ROOT_DIRS: |
507 | - for dirpath, dirnames, filenames in scandir.walk(config_dir): |
508 | + for dirpath, dirnames, filenames in os.walk(config_dir): |
509 | if os.path.basename(dirpath) in EXCLUDED_CONFIGS: |
510 | del dirnames[:] # Don't look in subdirectories. |
511 | continue |
512 | diff --git a/lib/lp/services/librarianserver/librariangc.py b/lib/lp/services/librarianserver/librariangc.py |
513 | index 71c3355..936ef3a 100644 |
514 | --- a/lib/lp/services/librarianserver/librariangc.py |
515 | +++ b/lib/lp/services/librarianserver/librariangc.py |
516 | @@ -20,7 +20,6 @@ from time import time |
517 | |
518 | import iso8601 |
519 | import pytz |
520 | -import scandir |
521 | import six |
522 | from swiftclient import client as swiftclient |
523 | from zope.interface import implementer |
524 | @@ -662,8 +661,8 @@ def delete_unwanted_disk_files(con): |
525 | hex_content_id_re = re.compile(r'^([0-9a-f]{8})(\.migrated)?$') |
526 | ONE_DAY = 24 * 60 * 60 |
527 | |
528 | - for dirpath, dirnames, filenames in scandir.walk( |
529 | - get_storage_root(), followlinks=True): |
530 | + for dirpath, dirnames, filenames in os.walk( |
531 | + get_storage_root(), followlinks=True): |
532 | |
533 | # Ignore known and harmless noise in the Librarian storage area. |
534 | if 'incoming' in dirnames: |
535 | diff --git a/lib/lp/services/librarianserver/swift.py b/lib/lp/services/librarianserver/swift.py |
536 | index 3f0c6eb..5460448 100644 |
537 | --- a/lib/lp/services/librarianserver/swift.py |
538 | +++ b/lib/lp/services/librarianserver/swift.py |
539 | @@ -21,7 +21,6 @@ import os.path |
540 | import re |
541 | import time |
542 | |
543 | -import scandir |
544 | import six |
545 | from six.moves.urllib.parse import quote |
546 | from swiftclient import client as swiftclient |
547 | @@ -90,8 +89,7 @@ def to_swift(log, start_lfc_id=None, end_lfc_id=None, |
548 | # Walk the Librarian on disk file store, searching for matching |
549 | # files that may need to be copied into Swift. We need to follow |
550 | # symlinks as they are being used span disk partitions. |
551 | - for dirpath, dirnames, filenames in scandir.walk( |
552 | - fs_root, followlinks=True): |
553 | + for dirpath, dirnames, filenames in os.walk(fs_root, followlinks=True): |
554 | |
555 | # Don't recurse if we know this directory contains no matching |
556 | # files. |
557 | diff --git a/lib/lp/services/mail/mailbox.py b/lib/lp/services/mail/mailbox.py |
558 | index 5ec49fe..2118176 100644 |
559 | --- a/lib/lp/services/mail/mailbox.py |
560 | +++ b/lib/lp/services/mail/mailbox.py |
561 | @@ -16,7 +16,6 @@ import poplib |
562 | import socket |
563 | import threading |
564 | |
565 | -import scandir |
566 | from zope.interface import ( |
567 | implementer, |
568 | Interface, |
569 | @@ -170,7 +169,7 @@ class DirectoryMailBox: |
570 | |
571 | def items(self): |
572 | """See IMailBox.""" |
573 | - for entry in scandir.scandir(self.mail_dir): |
574 | + for entry in os.scandir(self.mail_dir): |
575 | if entry.is_file(): |
576 | with open(entry.path, "rb") as mail_file: |
577 | yield (entry.path, mail_file.read()) |
578 | diff --git a/lib/lp/services/scripts/tests/__init__.py b/lib/lp/services/scripts/tests/__init__.py |
579 | index 8ca2036..3bd81ba 100644 |
580 | --- a/lib/lp/services/scripts/tests/__init__.py |
581 | +++ b/lib/lp/services/scripts/tests/__init__.py |
582 | @@ -10,8 +10,6 @@ __all__ = [ |
583 | import os |
584 | import subprocess |
585 | |
586 | -import scandir |
587 | - |
588 | import lp |
589 | from lp.services.config import config |
590 | |
591 | @@ -34,7 +32,7 @@ def find_lp_scripts(): |
592 | scripts = [] |
593 | for script_location in SCRIPT_LOCATIONS: |
594 | location = os.path.join(LP_TREE, script_location) |
595 | - for path, dirs, filenames in scandir.walk(location): |
596 | + for path, dirs, filenames in os.walk(location): |
597 | for filename in filenames: |
598 | script_path = os.path.join(path, filename) |
599 | if (filename.startswith('_') or |
600 | diff --git a/lib/lp/services/testing/__init__.py b/lib/lp/services/testing/__init__.py |
601 | index 0cc4713..41ede34 100644 |
602 | --- a/lib/lp/services/testing/__init__.py |
603 | +++ b/lib/lp/services/testing/__init__.py |
604 | @@ -21,8 +21,6 @@ import logging |
605 | import os |
606 | import unittest |
607 | |
608 | -import scandir |
609 | - |
610 | from lp.testing.systemdocs import ( |
611 | LayeredDocFileSuite, |
612 | setUp, |
613 | @@ -100,7 +98,7 @@ def build_test_suite(base_dir, special_tests={}, |
614 | if os.path.exists(stories_path): |
615 | suite.addTest(PageTestSuite( |
616 | stories_dir, package, setUp=pageTestsSetUp)) |
617 | - for story_entry in scandir.scandir(stories_path): |
618 | + for story_entry in os.scandir(stories_path): |
619 | if not story_entry.is_dir(): |
620 | continue |
621 | story_path = os.path.join(stories_dir, story_entry.name) |
622 | diff --git a/lib/lp/services/webservice/tests/test_wadllib.py b/lib/lp/services/webservice/tests/test_wadllib.py |
623 | index bda0f27..382942c 100644 |
624 | --- a/lib/lp/services/webservice/tests/test_wadllib.py |
625 | +++ b/lib/lp/services/webservice/tests/test_wadllib.py |
626 | @@ -9,7 +9,6 @@ __all__ = ['test_suite'] |
627 | import os |
628 | import unittest |
629 | |
630 | -import scandir |
631 | import wadllib |
632 | |
633 | from lp.testing.systemdocs import LayeredDocFileSuite |
634 | @@ -23,7 +22,7 @@ def test_suite(): |
635 | |
636 | # Find all the doctests in wadllib. |
637 | packages = [] |
638 | - for dirpath, dirnames, filenames in scandir.walk(topdir): |
639 | + for dirpath, dirnames, filenames in os.walk(topdir): |
640 | if 'docs' in dirnames: |
641 | docsdir = os.path.join(dirpath, 'docs')[len(topdir) + 1:] |
642 | packages.append(docsdir) |
643 | diff --git a/lib/lp/soyuz/doc/soyuz-set-of-uploads.txt b/lib/lp/soyuz/doc/soyuz-set-of-uploads.txt |
644 | index 5dcf121..92a08af 100644 |
645 | --- a/lib/lp/soyuz/doc/soyuz-set-of-uploads.txt |
646 | +++ b/lib/lp/soyuz/doc/soyuz-set-of-uploads.txt |
647 | @@ -116,12 +116,11 @@ Firstly, we need a way to copy a test upload into the queue (but skip |
648 | lock files, which have names starting with a dot). |
649 | |
650 | >>> import shutil |
651 | - >>> import scandir |
652 | >>> from lp.archiveuploader.tests import datadir |
653 | >>> def punt_upload_into_queue(leaf, distro): |
654 | ... inc_dir = os.path.join(incoming_dir, leaf, distro) |
655 | ... os.makedirs(inc_dir) |
656 | - ... for entry in scandir.scandir(datadir(os.path.join("suite", leaf))): |
657 | + ... for entry in os.scandir(datadir(os.path.join("suite", leaf))): |
658 | ... shutil.copy(entry.path, inc_dir) |
659 | |
660 | We need a way to count the items in a queue directory |
661 | @@ -614,7 +613,6 @@ release files in the way bug-54039 infected code would. |
662 | |
663 | First a couple helpers. |
664 | |
665 | - >>> import os |
666 | >>> import stat |
667 | >>> from lp.testing.script import run_script |
668 | |
669 | diff --git a/lib/lp/soyuz/doc/soyuz-upload.txt b/lib/lp/soyuz/doc/soyuz-upload.txt |
670 | index bace025..6f049e9 100644 |
671 | --- a/lib/lp/soyuz/doc/soyuz-upload.txt |
672 | +++ b/lib/lp/soyuz/doc/soyuz-upload.txt |
673 | @@ -101,10 +101,9 @@ files match the uploaded ones. |
674 | ... with open(filename, 'rb') as f: |
675 | ... return hashlib.md5(f.read()).digest() |
676 | |
677 | - >>> import scandir |
678 | >>> def get_upload_dir(num, dir=incoming_dir): |
679 | ... """Return the path to the upload, if found in the dir.""" |
680 | - ... for upload_entry in scandir.scandir(dir): |
681 | + ... for upload_entry in os.scandir(dir): |
682 | ... if upload_entry.name.endswith("%06d" % num): |
683 | ... return upload_entry.path |
684 | ... return None |
685 | diff --git a/lib/lp/soyuz/scripts/gina/packages.py b/lib/lp/soyuz/scripts/gina/packages.py |
686 | index 5feb27c..646b060 100644 |
687 | --- a/lib/lp/soyuz/scripts/gina/packages.py |
688 | +++ b/lib/lp/soyuz/scripts/gina/packages.py |
689 | @@ -28,7 +28,6 @@ import re |
690 | import shutil |
691 | import tempfile |
692 | |
693 | -import scandir |
694 | import six |
695 | |
696 | from lp.app.validators.version import valid_debian_version |
697 | @@ -92,7 +91,7 @@ def get_dsc_path(name, version, component, archive_root): |
698 | return filename, fullpath, component |
699 | |
700 | # Do a second pass, scrubbing through all components in the pool. |
701 | - for alt_component_entry in scandir.scandir(pool_root): |
702 | + for alt_component_entry in os.scandir(pool_root): |
703 | if not alt_component_entry.is_dir(): |
704 | continue |
705 | pool_dir = poolify(name, alt_component_entry.name) |
706 | diff --git a/lib/lp/soyuz/tests/fakepackager.py b/lib/lp/soyuz/tests/fakepackager.py |
707 | index 8106d50..9500ac8 100644 |
708 | --- a/lib/lp/soyuz/tests/fakepackager.py |
709 | +++ b/lib/lp/soyuz/tests/fakepackager.py |
710 | @@ -18,7 +18,6 @@ import tarfile |
711 | import tempfile |
712 | import time |
713 | |
714 | -import scandir |
715 | from zope.component import getUtility |
716 | |
717 | from lp.archiveuploader.nascentupload import NascentUpload |
718 | @@ -377,7 +376,7 @@ class FakePackager: |
719 | |
720 | def listAvailableUploads(self): |
721 | """Return the path for all available changesfiles.""" |
722 | - changes = [entry.path for entry in scandir.scandir(self.sandbox_path) |
723 | + changes = [entry.path for entry in os.scandir(self.sandbox_path) |
724 | if entry.name.endswith('.changes')] |
725 | |
726 | return sorted(changes) |
727 | diff --git a/lib/lp/soyuz/tests/test_doc.py b/lib/lp/soyuz/tests/test_doc.py |
728 | index 0096084..dc1b5eb 100644 |
729 | --- a/lib/lp/soyuz/tests/test_doc.py |
730 | +++ b/lib/lp/soyuz/tests/test_doc.py |
731 | @@ -9,7 +9,6 @@ import logging |
732 | import os |
733 | import unittest |
734 | |
735 | -import scandir |
736 | import transaction |
737 | |
738 | from lp.services.config import config |
739 | @@ -167,7 +166,7 @@ def test_suite(): |
740 | stories_dir = os.path.join(os.path.pardir, 'stories') |
741 | suite.addTest(PageTestSuite(stories_dir)) |
742 | stories_path = os.path.join(here, stories_dir) |
743 | - for story_entry in scandir.scandir(stories_path): |
744 | + for story_entry in os.scandir(stories_path): |
745 | if not story_entry.is_dir(): |
746 | continue |
747 | story_path = os.path.join(stories_dir, story_entry.name) |
748 | diff --git a/lib/lp/soyuz/tests/test_publishing.py b/lib/lp/soyuz/tests/test_publishing.py |
749 | index 1d4a1b5..d3d085e 100644 |
750 | --- a/lib/lp/soyuz/tests/test_publishing.py |
751 | +++ b/lib/lp/soyuz/tests/test_publishing.py |
752 | @@ -11,7 +11,6 @@ import shutil |
753 | import tempfile |
754 | |
755 | import pytz |
756 | -import scandir |
757 | from storm.store import Store |
758 | from testtools.matchers import Equals |
759 | import transaction |
760 | @@ -501,7 +500,7 @@ class SoyuzTestPublisher: |
761 | |
762 | def _findChangesFile(self, top, name_fragment): |
763 | """File with given name fragment in directory tree starting at top.""" |
764 | - for root, dirs, files in scandir.walk(top, topdown=False): |
765 | + for root, dirs, files in os.walk(top, topdown=False): |
766 | for name in files: |
767 | if (name.endswith('.changes') and |
768 | name.find(name_fragment) > -1): |
769 | diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py |
770 | index 8fbd261..b74f3b9 100644 |
771 | --- a/lib/lp/testing/__init__.py |
772 | +++ b/lib/lp/testing/__init__.py |
773 | @@ -82,7 +82,6 @@ from lazr.restful.testing.webservice import FakeRequest |
774 | import lp_sitecustomize |
775 | import oops_datedir_repo.serializer_rfc822 |
776 | import pytz |
777 | -import scandir |
778 | import simplejson |
779 | import six |
780 | from storm.store import Store |
781 | @@ -1162,7 +1161,7 @@ def build_yui_unittest_suite(app_testing_path, yui_test_class): |
782 | |
783 | |
784 | def _harvest_yui_test_files(file_path): |
785 | - for dirpath, dirnames, filenames in scandir.walk(file_path): |
786 | + for dirpath, dirnames, filenames in os.walk(file_path): |
787 | for filename in filenames: |
788 | if fnmatchcase(filename, "test_*.html"): |
789 | yield os.path.join(dirpath, filename) |
790 | diff --git a/lib/lp/testing/gpgkeys/__init__.py b/lib/lp/testing/gpgkeys/__init__.py |
791 | index a1d0378..8387e33 100644 |
792 | --- a/lib/lp/testing/gpgkeys/__init__.py |
793 | +++ b/lib/lp/testing/gpgkeys/__init__.py |
794 | @@ -23,7 +23,6 @@ from io import BytesIO |
795 | import os |
796 | |
797 | import gpgme |
798 | -import scandir |
799 | import six |
800 | from zope.component import getUtility |
801 | |
802 | @@ -113,7 +112,7 @@ def test_pubkey_from_email(email_addr): |
803 | |
804 | def test_keyrings(): |
805 | """Iterate over the filenames for test keyrings.""" |
806 | - for entry in scandir.scandir(gpgkeysdir): |
807 | + for entry in os.scandir(gpgkeysdir): |
808 | if entry.name.endswith('.gpg'): |
809 | yield entry.path |
810 | |
811 | diff --git a/lib/lp/testing/yuixhr.py b/lib/lp/testing/yuixhr.py |
812 | index f66295b..beb8c07 100644 |
813 | --- a/lib/lp/testing/yuixhr.py |
814 | +++ b/lib/lp/testing/yuixhr.py |
815 | @@ -20,7 +20,6 @@ import unittest |
816 | |
817 | from lazr.restful import ResourceJSONEncoder |
818 | from lazr.restful.utils import get_current_browser_request |
819 | -import scandir |
820 | import simplejson |
821 | from six.moves import reload_module |
822 | from zope.component import getUtility |
823 | @@ -451,7 +450,7 @@ class YUITestFixtureControllerView(LaunchpadView): |
824 | |
825 | |
826 | def find_tests(root): |
827 | - for dirpath, dirnames, filenames in scandir.walk(root): |
828 | + for dirpath, dirnames, filenames in os.walk(root): |
829 | dirpath = os.path.relpath(dirpath, root) |
830 | for filename in filenames: |
831 | if fnmatchcase(filename, 'test_*.js'): |
832 | diff --git a/lib/lp/testopenid/stories/tests.py b/lib/lp/testopenid/stories/tests.py |
833 | index 0c0d88e..88034e9 100644 |
834 | --- a/lib/lp/testopenid/stories/tests.py |
835 | +++ b/lib/lp/testopenid/stories/tests.py |
836 | @@ -4,8 +4,6 @@ |
837 | import os |
838 | import unittest |
839 | |
840 | -import scandir |
841 | - |
842 | from lp.testing.pages import PageTestSuite |
843 | |
844 | |
845 | @@ -14,7 +12,7 @@ here = os.path.dirname(os.path.realpath(__file__)) |
846 | |
847 | def test_suite(): |
848 | stories = sorted( |
849 | - entry.name for entry in scandir.scandir(here) |
850 | + entry.name for entry in os.scandir(here) |
851 | if not entry.name.startswith('.') and entry.is_dir()) |
852 | |
853 | suite = unittest.TestSuite() |
854 | diff --git a/lib/lp/tests/test_opensource.py b/lib/lp/tests/test_opensource.py |
855 | index 11fefc5..a3d67ef 100644 |
856 | --- a/lib/lp/tests/test_opensource.py |
857 | +++ b/lib/lp/tests/test_opensource.py |
858 | @@ -21,7 +21,6 @@ import os |
859 | import unittest |
860 | |
861 | import launchpadlib |
862 | -import scandir |
863 | import wadllib |
864 | |
865 | from lp.testing.layers import AppServerLayer |
866 | @@ -33,7 +32,7 @@ def add_testable_opensource_package(suite, package): |
867 | topdir = os.path.dirname(package.__file__) |
868 | |
869 | packages = [] |
870 | - for dirpath, dirnames, filenames in scandir.walk(topdir): |
871 | + for dirpath, dirnames, filenames in os.walk(topdir): |
872 | if 'docs' in dirnames: |
873 | docsdir = os.path.join(dirpath, 'docs')[len(topdir) + 1:] |
874 | packages.append(docsdir) |
875 | diff --git a/lib/lp/translations/tests/test_doc.py b/lib/lp/translations/tests/test_doc.py |
876 | index 9229590..2ec46ee 100644 |
877 | --- a/lib/lp/translations/tests/test_doc.py |
878 | +++ b/lib/lp/translations/tests/test_doc.py |
879 | @@ -9,8 +9,6 @@ import logging |
880 | import os |
881 | import unittest |
882 | |
883 | -import scandir |
884 | - |
885 | from lp.testing.layers import ( |
886 | LaunchpadFunctionalLayer, |
887 | LaunchpadZopelessLayer, |
888 | @@ -62,7 +60,7 @@ def test_suite(): |
889 | stories_dir = os.path.join(os.path.pardir, 'stories') |
890 | suite.addTest(PageTestSuite(stories_dir)) |
891 | stories_path = os.path.join(here, stories_dir) |
892 | - for story_entry in scandir.scandir(stories_path): |
893 | + for story_entry in os.scandir(stories_path): |
894 | if not story_entry.is_dir(): |
895 | continue |
896 | story_path = os.path.join(stories_dir, story_entry.name) |
897 | diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt |
898 | index e05a33f..12a04b1 100644 |
899 | --- a/requirements/launchpad.txt |
900 | +++ b/requirements/launchpad.txt |
901 | @@ -128,7 +128,6 @@ requests-file==1.4.3 |
902 | requests-toolbelt==0.9.1 |
903 | responses==0.9.0 |
904 | s3transfer==0.3.6 |
905 | -scandir==1.7 |
906 | secure-cookie==0.1.0 |
907 | service-identity==18.1.0 |
908 | setproctitle==1.1.7 |
909 | diff --git a/scripts/migrate-librarian-content-md5.py b/scripts/migrate-librarian-content-md5.py |
910 | index 9caaf62..0031a73 100755 |
911 | --- a/scripts/migrate-librarian-content-md5.py |
912 | +++ b/scripts/migrate-librarian-content-md5.py |
913 | @@ -13,8 +13,6 @@ import os |
914 | import subprocess |
915 | import sys |
916 | |
917 | -import scandir |
918 | - |
919 | |
920 | SQL = "UPDATE LibraryFileContent SET md5 = '%s' WHERE id = %d;" |
921 | |
922 | @@ -23,7 +21,7 @@ def main(path, minimumID=0): |
923 | if not path.endswith('/'): |
924 | path += '/' |
925 | |
926 | - for dirpath, dirname, filenames in scandir.walk(path): |
927 | + for dirpath, dirname, filenames in os.walk(path): |
928 | dirname.sort() |
929 | databaseID = dirpath[len(path):] |
930 | if not len(databaseID) == 8: # "xx/xx/xx" |
931 | diff --git a/setup.py b/setup.py |
932 | index c10e833..6e945a8 100644 |
933 | --- a/setup.py |
934 | +++ b/setup.py |
935 | @@ -214,7 +214,6 @@ setup( |
936 | 'requests-file', |
937 | 'requests-toolbelt', |
938 | 'responses', |
939 | - 'scandir', |
940 | 'secure-cookie', |
941 | 'setproctitle', |
942 | 'setuptools', |
Looks good!