Bug 1427210: Fix flake8 errors in check-sync-dirs.py; r?Fallen draft
authorTom Prince <mozilla@hocat.ca>
Tue, 26 Dec 2017 22:02:07 -0700
changeset 23598 b9832b8e7d39815d0913806978603879520ff883
parent 23597 2cf483e70c05b19b77c9c8633a9b2581e1864411
child 23599 e0f20346bb506e6e0ec788aca58d0b98292add79
child 23604 34fc1163a375b842a4d0547b5af3f9c3977f2e41
push id191
push userbmo:mozilla@hocat.ca
push dateWed, 27 Dec 2017 22:04:27 +0000
Bug 1427210: Fix flake8 errors in check-sync-dirs.py; r?Fallen There are some remaning line-to-long errors, but they will be cleaned up later in this series. MozReview-Commit-ID: 1SwslxPV0IE
--- a/mail/check-sync-dirs.py
+++ b/mail/check-sync-dirs.py
@@ -5,17 +5,17 @@
 # check-sync-dirs.py --- check that one directory is an exact subset of another
 # Usage: python check-sync-dirs.py COPY ORIGINAL
 # Check that the files present in the directory tree COPY are exact
 # copies of their counterparts in the directory tree ORIGINAL.  COPY
 # need not have all the files in ORIGINAL, but COPY may not have files
 # absent from ORIGINAL.
 # Each directory in COPY may have a file named
 # 'check-sync-exceptions', which lists files in COPY that need not be
 # the same as the corresponding file in ORIGINAL, or exist at all in
 # ORIGINAL.  (The 'check-sync-exceptions' file itself is always
 # treated as exceptional.)  Blank lines and '#' comments in the file
 # are ignored.
 import sys
@@ -27,45 +27,48 @@ import fnmatch
 if len(sys.argv) != 3:
     print >> sys.stderr, 'TEST-UNEXPECTED-FAIL | check-sync-dirs.py | Usage: %s COPY ORIGINAL' % sys.argv[0]
 copy = os.path.abspath(sys.argv[1])
 original = os.path.abspath(sys.argv[2])
 # Return the contents of FILENAME, a 'check-sync-exceptions' file, as
 # a dictionary whose keys are exactly the list of filenames, along
 # with the basename of FILENAME itself.  If FILENAME does not exist,
 # return the empty dictionary.
 def read_exceptions(filename):
     if (os.path.exists(filename)):
         f = file(filename)
         exceptions = {}
         for line in f:
             line = line.strip()
             if line != '' and line[0] != '#':
                 exceptions[line] = None
-        exceptions[os.path.basename (filename)] = None
+        exceptions[os.path.basename(filename)] = None
         return exceptions
         return {}
 # Return true if FILENAME matches any pattern in the list of filename
 # patterns PATTERNS.
 def fnmatch_any(filename, patterns):
     for pattern in patterns:
         if fnmatch.fnmatch(filename, pattern):
             return True
     return False
 # Check the contents of the directory tree COPY against ORIGINAL.  For each
 # file that differs, apply REPORT to COPY, ORIGINAL, and the file's
-# relative path.  COPY and ORIGINAL should be absolute.  Ignore files 
+# relative path.  COPY and ORIGINAL should be absolute.  Ignore files
 # that match patterns given in the list IGNORE.
 def check(copy, original):
     for (dirpath, dirnames, filenames) in os.walk('.'):
         exceptions = read_exceptions(join(dirpath, 'check-sync-exceptions'))
         for dirname in dirnames:
             if fnmatch_any(dirname, exceptions):
@@ -75,30 +78,33 @@ def check(copy, original):
             relative_name = join(dirpath, filename)
             original_name = join(original, relative_name)
             if (os.path.exists(original_name)
                 and filecmp.cmp(relative_name, original_name, False)):
             report(copy, original, relative_name)
 differences_found = False
 # Print an error message for DIFFERING, which was found to differ
 # between COPY and ORIGINAL.  Set the global variable differences_found.
 def report(copy, original, differing):
     global differences_found
     if not differences_found:
         print >> sys.stderr, 'TEST-UNEXPECTED-FAIL | check-sync-dirs.py | build file copies are not in sync\n' \
                              'TEST-INFO | check-sync-dirs.py | file(s) found in:               %s\n' \
                              'TEST-INFO | check-sync-dirs.py | differ from their originals in: %s' \
                              % (copy, original)
     print >> sys.stderr, 'TEST-INFO | check-sync-dirs.py | differing file:                 %s' % differing
     differences_found = True
 check(copy, original)
 if differences_found:
     msg = '''In general, the files in '%s' should always be exact copies of
 originals in '%s'.  A change made to one should also be made to the
 other.  See 'check-sync-dirs.py' for more details.''' \
          % (copy, original)
     print >> sys.stderr, textwrap.fill(msg, 75)
--- a/taskcluster/ci/source-test/mozlint.yml
+++ b/taskcluster/ci/source-test/mozlint.yml
@@ -64,15 +64,15 @@ yaml:
             - '**/.ymllint'
     description: flake8 run over the thunderbird codebase
     platform: lint/opt
         symbol: f8
-        mach: lint -f treeherder -l flake8 -n comm/taskcluster
+        mach: lint -f treeherder -l flake8 -n comm/taskcluster comm/mail/check-sync-dirs.py
             - '**/*.py'
             - '**/.flake8'
             # moz.configure files are also Python files.
             - '**/*.configure'