[Reproducible-commits] [debbindiff] 01/01: Recognize text/plain files

Jérémy Bobbio lunar at moszumanska.debian.org
Sun Jan 18 21:54:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository debbindiff.

commit 8c51dfbb48b4b2de54473d28e2c786a5a9df5417
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sun Jan 18 21:51:40 2015 +0000

    Recognize text/plain files
    
    In order to properly read text files, we need to get the encoding.
    As they are identified by libmagic, we simply need to pass what appears
    in the MIME type to the comparator function. We do so by capturing
    part of the regex using named group, and passing the resulting dictionary
    to the comparison function.
---
 debbindiff/comparators/__init__.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/debbindiff/comparators/__init__.py b/debbindiff/comparators/__init__.py
index e68ebb2..11d20bc 100644
--- a/debbindiff/comparators/__init__.py
+++ b/debbindiff/comparators/__init__.py
@@ -81,6 +81,7 @@ COMPARATORS = [
     (r'^application/(x-font-ttf|vnd.ms-opentype)(;|$)', r'\.(ttf|otf)$', compare_ttf_files),
     (r'^image/png(;|$)', r'\.png$', compare_png_files),
     (r'^application/pdf(;|$)', r'\.pdf$', compare_pdf_files),
+    (r'^text/plain; charset=(?P<encoding>[a-z0-9-]+)$', r'\.txt$', compare_text_files),
     (None, r'\.a$', compare_static_lib_files),
     ]
 
@@ -108,7 +109,8 @@ def compare_files(path1, path2, source=None):
            and re.search(filename_regex, path2):
             return comparator(path1, path2, source)
         if mime_type_regex:
-            if re.search(mime_type_regex, mime_type1) and \
-               re.search(mime_type_regex, mime_type2):
-                return comparator(path1, path2, source)
+            match1 = re.search(mime_type_regex, mime_type1)
+            match2 = re.search(mime_type_regex, mime_type2)
+            if match1 and match2 and match1.groupdict() == match2.groupdict():
+                return comparator(path1, path2, source=source, **match1.groupdict())
     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