Bug 1509962: [mozrelease] Add mozrelease to in-tree lint config; r=mtabara
authorTom Prince <mozilla@hocat.ca>
Mon, 03 Dec 2018 06:44:08 +0000
changeset 508407 9be51673e21f4e33ade4f897dc4e606f1d0568a4
parent 508406 fe7c1bcf044acc3644adbba6e7b9039d1ce78eb4
child 508408 3ed6bf5ca77217e5884de76be8e66d8cf880b251
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmtabara
bugs1509962
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509962: [mozrelease] Add mozrelease to in-tree lint config; r=mtabara Differential Revision: https://phabricator.services.mozilla.com/D12975
python/mozrelease/mozrelease/chunking.py
python/mozrelease/mozrelease/paths.py
python/mozrelease/mozrelease/platforms.py
python/mozrelease/mozrelease/update_verify.py
python/mozrelease/test/test_buglist_creator.py
python/mozrelease/test/test_update_verify.py
tools/lint/flake8.yml
--- a/python/mozrelease/mozrelease/chunking.py
+++ b/python/mozrelease/mozrelease/chunking.py
@@ -5,17 +5,17 @@ from copy import copy
 
 class ChunkingError(Exception):
     pass
 
 
 def getChunk(things, chunks, thisChunk):
     if thisChunk > chunks:
         raise ChunkingError("thisChunk (%d) is greater than total chunks (%d)" %
-                           (thisChunk, chunks))
+                            (thisChunk, chunks))
     possibleThings = copy(things)
     nThings = len(possibleThings)
     for c in range(1, chunks + 1):
         n = nThings / chunks
         # If our things aren't evenly divisible by the number of chunks
         # we need to append one more onto some of them
         if c <= (nThings % chunks):
             n += 1
--- a/python/mozrelease/mozrelease/paths.py
+++ b/python/mozrelease/mozrelease/paths.py
@@ -1,27 +1,28 @@
 from __future__ import absolute_import
 
 from urlparse import urlunsplit
 
 product_ftp_map = {
     "fennec": "mobile",
 }
 
+
 def product2ftp(product):
     return product_ftp_map.get(product, product)
 
 
 def getCandidatesDir(product, version, buildNumber, protocol=None, server=None):
     if protocol:
         assert server is not None, "server is required with protocol"
 
     product = product2ftp(product)
     directory = "/{}/candidates/{}-candidates/build{}".format(
-        product, str(version), str(buildNumber)
+        product, str(version), str(buildNumber),
     )
 
     if protocol:
         return urlunsplit((protocol, server, directory, None, None))
     else:
         return directory
 
 
--- a/python/mozrelease/mozrelease/platforms.py
+++ b/python/mozrelease/mozrelease/platforms.py
@@ -34,25 +34,29 @@ sl_platform_map = {
 info_file_platform_map = {
     "linux-i686": "linux",
     "linux-x86_64": "linux64",
     "mac": "macosx64",
     "win32": "win32",
     "win64": "win64",
 }
 
+
 def ftp2updatePlatforms(platform):
     return update_platform_map.get(platform, platform)
 
+
 def ftp2shippedLocales(platform):
     return sl_platform_map.get(platform, platform)
 
+
 def shippedLocales2ftp(platform):
     matches = []
     try:
         [matches.append(
             k) for k, v in sl_platform_map.iteritems() if v == platform][0]
         return matches
     except IndexError:
         return [platform]
 
+
 def ftp2infoFile(platform):
     return info_file_platform_map.get(platform, platform)
--- a/python/mozrelease/mozrelease/update_verify.py
+++ b/python/mozrelease/mozrelease/update_verify.py
@@ -1,9 +1,14 @@
-from __future__ import absolute_import
+# -*- coding: utf-8 -*-
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function
 
 import os
 import re
 
 from .chunking import getChunk
 
 
 class UpdateVerifyError(Exception):
@@ -45,25 +50,26 @@ class UpdateVerifyConfig(object):
         other_list = [getattr(other, attr) for attr in self.compare_attrs]
         return self_list == other_list
 
     def __ne__(self, other):
         return not self.__eq__(other)
 
     def _parseLine(self, line):
         entry = {}
-        items = re.findall("\w+=[\"'][^\"']*[\"']", line)
+        items = re.findall(r"\w+=[\"'][^\"']*[\"']", line)
         for i in items:
             m = re.search(
-                "(?P<key>\w+)=[\"'](?P<value>.+)[\"']", i).groupdict()
+                r"(?P<key>\w+)=[\"'](?P<value>.+)[\"']", i).groupdict()
             if m["key"] not in self.global_keys and m["key"] not in self.release_keys:
                 raise UpdateVerifyError(
                     "Unknown key '%s' found on line:\n%s" % (m["key"], line))
             if m["key"] in entry:
-                raise UpdateVerifyError("Multiple values found for key '%s' on line:\n%s" % (m["key"], line))
+                raise UpdateVerifyError(
+                    "Multiple values found for key '%s' on line:\n%s" % (m["key"], line))
             entry[m["key"]] = m["value"]
         if not entry:
             raise UpdateVerifyError("No parseable data in line '%s'" % line)
         return entry
 
     def _addEntry(self, entry, first):
         releaseKeys = {}
         for k, v in entry.items():
@@ -114,17 +120,19 @@ class UpdateVerifyConfig(object):
     def addRelease(self, release=None, build_id=None, locales=[],
                    patch_types=['complete'], from_path=None,
                    ftp_server_from=None, ftp_server_to=None,
                    mar_channel_IDs=None, platform=None, updater_package=None):
         """Locales and patch_types can be passed as either a string or a list.
            If a string is passed, they will be converted to a list for internal
            storage"""
         if self.getRelease(build_id, from_path):
-            raise UpdateVerifyError("Couldn't add release identified by build_id '%s' and from_path '%s': already exists in config" % (build_id, from_path))
+            raise UpdateVerifyError(
+                "Couldn't add release identified by build_id '%s' and from_path '%s': "
+                "already exists in config" % (build_id, from_path))
         if isinstance(locales, basestring):
             locales = sorted(list(locales.split()))
         if isinstance(patch_types, basestring):
             patch_types = list(patch_types.split())
         self.releases.append({
             "release": release,
             "build_id": build_id,
             "locales": locales,
@@ -135,17 +143,19 @@ class UpdateVerifyConfig(object):
             "mar_channel_IDs": mar_channel_IDs,
             "platform": platform,
             "updater_package": updater_package,
         })
 
     def addLocaleToRelease(self, build_id, locale, from_path=None):
         r = self.getRelease(build_id, from_path)
         if not r:
-            raise UpdateVerifyError("Couldn't add '%s' to release identified by build_id '%s' and from_path '%s': '%s' doesn't exist in this config." % (locale, build_id, from_path, build_id))
+            raise UpdateVerifyError(
+                "Couldn't add '%s' to release identified by build_id '%s' and from_path '%s': "
+                "'%s' doesn't exist in this config." % (locale, build_id, from_path, build_id))
         r["locales"].append(locale)
         r["locales"] = sorted(r["locales"])
 
     def getRelease(self, build_id, from_path):
         for r in self.releases:
             if r["build_id"] == build_id and r["from"] == from_path:
                 return r
         return {}
--- a/python/mozrelease/test/test_buglist_creator.py
+++ b/python/mozrelease/test/test_buglist_creator.py
@@ -1,8 +1,13 @@
+# -*- coding: utf-8 -*-
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
 # -*- coding: utf-8 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function
 
 import json
@@ -105,17 +110,17 @@ def test_get_previous_tag_version(versio
         u'FIREFOX_48_0b1_BUILD2',
         u'FIREFOX_AURORA_48_END',
         u'FIREFOX_BETA_48_BASE',
         u'FIREFOX_AURORA_48_BASE',
     ]
 
     mock_hg_json = {
         'tags': [
-            {'tag': tag} for tag in ff_48_tags
+            {'tag': ff_48_tag} for ff_48_tag in ff_48_tags
         ],
     }
 
     assert get_previous_tag_version(product, version, tag, mock_hg_json) == previous_tag
 
 
 def test_get_bugs_in_changeset():
     with DATA_PATH.joinpath("buglist_changesets.json").open("r") as fp:
--- a/python/mozrelease/test/test_update_verify.py
+++ b/python/mozrelease/test/test_update_verify.py
@@ -1,13 +1,15 @@
 # -*- coding: utf-8 -*-
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+from __future__ import absolute_import, print_function
+
 from md5 import md5
 import os
 from tempfile import mkstemp
 import unittest
 from pathlib2 import Path
 
 from mozrelease.update_verify import UpdateVerifyConfig, UpdateVerifyError
 
--- a/tools/lint/flake8.yml
+++ b/tools/lint/flake8.yml
@@ -17,16 +17,17 @@ flake8:
         - mobile/
         - mozglue/
         - layout/tools/reftest
         - python/mach
         - python/mach_commands.py
         - python/mozboot
         - python/mozbuild/mozpack/path.py
         - python/mozlint
+        - python/mozrelease
         - python/mozterm
         - python/mozversioncontrol
         - python/safety
         - security/
         - security/manager
         - taskcluster
         - testing/firefox-ui
         - testing/mach_commands.py