Bug 1427210: Since we are using python 2.7, we can use a set instead of simulating it with a dictionary; r?Fallen
MozReview-Commit-ID: I3daw8OZjFa
--- a/mail/check-sync-dirs.py
+++ b/mail/check-sync-dirs.py
@@ -28,33 +28,35 @@ import fnmatch
if len(sys.argv) != 3:
print >> sys.stderr, 'TEST-UNEXPECTED-FAIL | check-sync-dirs.py | Usage: %s COPY ORIGINAL' % sys.argv[0]
sys.exit(1)
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):
+ """
+ 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.
+ """
if (os.path.exists(filename)):
f = file(filename)
- exceptions = {}
+ exceptions = set()
for line in f:
line = line.strip()
if line != '' and line[0] != '#':
- exceptions[line] = None
- exceptions[os.path.basename(filename)] = None
+ exceptions.add(line)
+ exceptions.add(os.path.basename(filename))
f.close()
return exceptions
else:
- return {}
+ return set()
# 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