[Reproducible-commits] [debbindiff] 09/10: Avoid calling libmagic if we recognize files by filename
Jérémy Bobbio
lunar at moszumanska.debian.org
Mon Sep 29 18:29:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit 158816bdf2b73e2d3124c6d0638f12be24a789f7
Author: Jérémy Bobbio <lunar at debian.org>
Date: Mon Sep 29 19:26:33 2014 +0200
Avoid calling libmagic if we recognize files by filename
libmagic tends to be costly when called on so many files
---
debbindiff/comparators/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/debbindiff/comparators/__init__.py b/debbindiff/comparators/__init__.py
index e689827..7cf749d 100644
--- a/debbindiff/comparators/__init__.py
+++ b/debbindiff/comparators/__init__.py
@@ -69,11 +69,11 @@ def compare_files(path1, path2, source=None):
logger.critical("%s is not a file" % path2)
sys.exit(2)
for mime_type_regex, filename_regex, comparator in COMPARATORS:
+ if filename_regex and re.search(filename_regex, path1) and re.search(filename_regex, path2):
+ return comparator(path1, path2, source)
if mime_type_regex:
mime_type1 = guess_mime_type(path1)
mime_type2 = guess_mime_type(path2)
if re.search(mime_type_regex, mime_type1) and re.search(mime_type_regex, mime_type2):
return comparator(path1, path2, source)
- if filename_regex and re.search(filename_regex, path1) and re.search(filename_regex, path2):
- return comparator(path1, path2, source)
return compare_unknown(path1, path2, source)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list