From e68e348781b7c9a7e44482ce50dd60c62255f002 Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Wed, 24 Oct 2018 16:27:10 -0500 Subject: [PATCH 1/3] flake8: ignore W504. --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index ea7bc083..20c9d9c2 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] exclude = .open-build-service/, abichecker, openqa, openqa-maintenance.py max-line-length = 100 -ignore = E501,F401,E302,E228,E128,E251,E201,E202,E203,E305,F841,E265,E261,E266,E712,E401,E126,E502,E222,E241,E711,E226,E125,E123,W293,W391,E731,E101,E227,E713,E225,E124,E221,E127,E701,E714,W503,E129,E303,E741,E722 +ignore = E501,F401,E302,E228,E128,E251,E201,E202,E203,E305,F841,E265,E261,E266,E712,E401,E126,E502,E222,E241,E711,E226,E125,E123,W293,W391,E731,E101,E227,E713,E225,E124,E221,E127,E701,E714,W503,W504,E129,E303,E741,E722 From 4c8ade1a93dc7d028e9e7d6793272b7716b13a57 Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Wed, 24 Oct 2018 16:29:15 -0500 Subject: [PATCH 2/3] flake8: utilize raw strings to avoid invalid escape character warnings. --- factory-package-news/announcer.py | 2 +- leaper.py | 2 +- metrics.py | 8 ++++---- osclib/cache.py | 28 ++++++++++++++-------------- osclib/core.py | 2 +- osclib/stagingapi.py | 2 +- pkglistgen.py | 2 +- tests/obs.py | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/factory-package-news/announcer.py b/factory-package-news/announcer.py index 3984027d..d51ab516 100755 --- a/factory-package-news/announcer.py +++ b/factory-package-news/announcer.py @@ -99,7 +99,7 @@ if not options.version: if loc is None: raise Exception("empty location!") - m = re.search('(?:Snapshot|Build)([\d.]+)-Media', loc) + m = re.search(r'(?:Snapshot|Build)([\d.]+)-Media', loc) if m is None: raise Exception("failed to parse %s"%loc) diff --git a/leaper.py b/leaper.py index e84c03c4..094bea8c 100755 --- a/leaper.py +++ b/leaper.py @@ -164,7 +164,7 @@ class Leaper(ReviewBot.ReviewBot): if review_result == None: other_projects_to_check = [] - m = re.match('SUSE:SLE-(\d+)(?:-SP(\d+)):', target_project) + m = re.match(r'SUSE:SLE-(\d+)(?:-SP(\d+)):', target_project) if m: sle_version = int(m.group(1)) sp_version = int(m.group(2)) diff --git a/metrics.py b/metrics.py index 0a48facd..16886a6c 100755 --- a/metrics.py +++ b/metrics.py @@ -331,7 +331,7 @@ def ingest_release_schedule(project): # Extract Factory "release schedule" from Tumbleweed snapshot list. command = 'rsync rsync.opensuse.org::opensuse-full/opensuse/tumbleweed/iso/Changes.* | ' \ - 'grep -oP "Changes\.\K\d{5,}"' + 'grep -oP "' + r'Changes\.\K\d{5,}' + '"' snapshots = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).communicate()[0] for date in snapshots.split(): release_schedule[datetime.strptime(date, '%Y%m%d')] = 'Snapshot {}'.format(date) @@ -547,9 +547,9 @@ def main(args): if args.wipe_cache: Cache.delete_all() if args.heavy_cache: - Cache.PATTERNS['/search/request'] = sys.maxint - Cache.PATTERNS['/source/[^/]+/{}/_history'.format(package)] = sys.maxint - Cache.PATTERNS['/source/[^/]+/{}/[^/]+\?rev=.*'.format(package)] = sys.maxint + Cache.PATTERNS[r'/search/request'] = sys.maxint + Cache.PATTERNS[r'/source/[^/]+/{}/_history'.format(package)] = sys.maxint + Cache.PATTERNS[r'/source/[^/]+/{}/[^/]+\?rev=.*'.format(package)] = sys.maxint Cache.init('metrics') Config(apiurl, args.project) diff --git a/osclib/cache.py b/osclib/cache.py index 71508124..621a54ea 100644 --- a/osclib/cache.py +++ b/osclib/cache.py @@ -71,32 +71,32 @@ class Cache(object): TTL_SHORT = 5 * 60 TTL_DUPLICATE = 3 PATTERNS = { - '/build/[^/]+/_result': TTL_DUPLICATE, + r'/build/[^/]+/_result': TTL_DUPLICATE, # For cycles when run via repo-checker cache non-stagings. - '/build/(?:[^/](?!:Staging:))+/[^/]+/[^/]+/_builddepinfo$': TTL_MEDIUM, + r'/build/(?:[^/](?!:Staging:))+/[^/]+/[^/]+/_builddepinfo$': TTL_MEDIUM, # Group members cannot be guaranteed, but change rarely. - '/group/[^/?]+$': TTL_SHORT, + r'/group/[^/?]+$': TTL_SHORT, # Clear target project cache upon request acceptance. - '/request/(\d+)\?.*newstate=accepted': TTL_DUPLICATE, - "/search/package\?match=\[@project='([^']+)'\]$": TTL_LONG, + r'/request/(\d+)\?.*newstate=accepted': TTL_DUPLICATE, + r"/search/package\?match=\[@project='([^']+)'\]$": TTL_LONG, # Potentially expire the latest_updated since it will be the only way to # tell after an adi staging is removed. For now just cache the calls # that occur in rapid succession. - "/search/project/id\?match=starts-with\(@name,'([^']+)\:'\)$": TTL_DUPLICATE, + r"/search/project/id\?match=starts-with\(@name,'([^']+)\:'\)$": TTL_DUPLICATE, # List of all projects may change, but relevant ones rarely. - '/source$': TTL_LONG, + r'/source$': TTL_LONG, # Sources will be expired with project, could be done on package level. - '/source/([^/?]+)(?:\?.*)?$': TTL_LONG, + r'/source/([^/?]+)(?:\?.*)?$': TTL_LONG, # Project will be marked changed when packages are added/removed. - '/source/([^/]+)/_meta$': TTL_LONG, - '/source/([^/]+)/(?:[^/]+)/(?:_meta|_link)$': TTL_LONG, - '/source/([^/]+)/dashboard/[^/]+': TTL_LONG, - '/source/([^/]+)/_attribute/[^/]+': TTL_MEDIUM, + r'/source/([^/]+)/_meta$': TTL_LONG, + r'/source/([^/]+)/(?:[^/]+)/(?:_meta|_link)$': TTL_LONG, + r'/source/([^/]+)/dashboard/[^/]+': TTL_LONG, + r'/source/([^/]+)/_attribute/[^/]+': TTL_MEDIUM, # Handles clearing local cache on package deletes. Lots of queries like # updating project info, comment, and package additions. - '/source/([^/]+)/(?:[^/?]+)(?:\?[^/]+)?$': TTL_LONG, + r'/source/([^/]+)/(?:[^/?]+)(?:\?[^/]+)?$': TTL_LONG, # Presumably users are not interweaving in short windows. - '/statistics/latest_updated': TTL_SHORT, + r'/statistics/latest_updated': TTL_SHORT, } last_updated = {} diff --git a/osclib/core.py b/osclib/core.py index 6396eeeb..430e3bda 100644 --- a/osclib/core.py +++ b/osclib/core.py @@ -28,7 +28,7 @@ from osclib.conf import Config from osclib.memoize import memoize BINARY_REGEX = r'(?:.*::)?(?P(?P.*)-(?P[^-]+)-(?P[^-]+)\.(?P[^-\.]+))' -RPM_REGEX = BINARY_REGEX + '\.rpm' +RPM_REGEX = BINARY_REGEX + r'\.rpm' BinaryParsed = namedtuple('BinaryParsed', ('package', 'filename', 'name', 'arch')) @memoize(session=True) diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index a927aaf0..ae610462 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -265,7 +265,7 @@ class StagingAPI(object): return package_info def extract_specfile_short(self, filelist): - packages = [spec[:-5] for spec in filelist if re.search('\.spec$', spec)] + packages = [spec[:-5] for spec in filelist if re.search(r'\.spec$', spec)] return packages diff --git a/pkglistgen.py b/pkglistgen.py index 25dcb57e..446c5d2f 100755 --- a/pkglistgen.py +++ b/pkglistgen.py @@ -487,7 +487,7 @@ class PkgListGen(ToolBase.ToolBase): # only comment first time comment = None x = ET.tostring(x, pretty_print=True) - x = re.sub('\s*