author Emin Mastizada <>
Sat, 27 May 2017 05:22:51 +0300
changeset 585516 8cc969aa0d37a0688b8bbf2c52050ab1844473d2
parent 466600 8d9a2e5cbc2c76b469f2f406a781c8e060cdd513
permissions -rwxr-xr-x
bug 1368216: [flake8] Python code in browser should follow flake8 convention MozReview-Commit-ID: Jc1y2KHD9ap

# 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

def test(mod, path, entity=None):
    import re
    # ignore anything but Firefox
    if mod not in ("netwerk", "dom", "toolkit", "security/manager",
                   "devtools/client", "devtools/shared",
        return "ignore"
    if mod not in ("browser", "extensions/spellcheck"):
        # we only have exceptions for browser and extensions/spellcheck
        return "error"
    if not entity:
        # the only files to ignore are spell checkers
        if mod == "extensions/spellcheck":
            return "ignore"
        return "error"
    if mod == "extensions/spellcheck":
        # l10n ships en-US dictionary or something, do compare
        return "error"
    if path == "":
        return "ignore" if entity == "MOZ_LANGPACK_CONTRIBUTORS" else "error"

    if mod == "browser" and path == "chrome/browser-region/":
        # only exceptions remain, compare all others
        return ("ignore"
                if (re.match(r"browser\.search\.order\.[1-9]", entity) or
                    re.match(r"browser\.contentHandlers\.types\.[0-5]", entity) or
                    re.match(r"gecko\.handlerService\.schemes\.", entity) or
                    re.match(r"gecko\.handlerService\.defaultHandlersVersion", entity))
                else "error")
    return "error"