[diffoscope] 03/03: Also add auto recognition for RE_FILE_EXTENSION
Mattia Rizzolo
mattia at debian.org
Sat Jan 14 12:01:58 CET 2017
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch wip/auto-recognize
in repository diffoscope.
commit e7de593d6a933d624eae3c19c7d91ba9673bc44e
Author: Mattia Rizzolo <mattia at debian.org>
Date: Sat Jan 14 11:43:28 2017 +0100
Also add auto recognition for RE_FILE_EXTENSION
---
diffoscope/comparators/debian_fallback.py | 12 ------------
diffoscope/comparators/ipk.py | 4 ----
diffoscope/comparators/javascript.py | 4 ----
diffoscope/comparators/utils/specialize.py | 2 ++
4 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/diffoscope/comparators/debian_fallback.py b/diffoscope/comparators/debian_fallback.py
index 71ea392..a52f133 100644
--- a/diffoscope/comparators/debian_fallback.py
+++ b/diffoscope/comparators/debian_fallback.py
@@ -25,10 +25,6 @@ from .text import TextFile
class DotChangesFile(TextFile):
RE_FILE_EXTENSION = re.compile(r'\.changes$')
- @staticmethod
- def recognizes(file):
- return DotChangesFile.RE_FILE_EXTENSION.search(file.name)
-
def compare(self, other, source=None):
difference = super().compare(other)
if not difference:
@@ -39,10 +35,6 @@ class DotChangesFile(TextFile):
class DotDscFile(TextFile):
RE_FILE_EXTENSION = re.compile(r'\.dsc$')
- @staticmethod
- def recognizes(file):
- return DotDscFile.RE_FILE_EXTENSION.search(file.name)
-
def compare(self, other, source=None):
difference = super().compare(other)
if not difference:
@@ -53,10 +45,6 @@ class DotDscFile(TextFile):
class DotBuildinfoFile(TextFile):
RE_FILE_EXTENSION = re.compile(r'\.buildinfo$')
- @staticmethod
- def recognizes(file):
- return DotBuildinfoFile.RE_FILE_EXTENSION.search(file.name)
-
def compare(self, other, source=None):
difference = super().compare(other)
if not difference:
diff --git a/diffoscope/comparators/ipk.py b/diffoscope/comparators/ipk.py
index 785ee5d..3131dcc 100644
--- a/diffoscope/comparators/ipk.py
+++ b/diffoscope/comparators/ipk.py
@@ -25,7 +25,3 @@ from .gzip import GzipFile
class IpkFile(GzipFile):
RE_FILE_EXTENSION = re.compile('\.ipk$')
-
- @staticmethod
- def recognizes(file):
- return IpkFile.RE_FILE_EXTENSION.search(file.name)
diff --git a/diffoscope/comparators/javascript.py b/diffoscope/comparators/javascript.py
index 645dc9b..1cdc865 100644
--- a/diffoscope/comparators/javascript.py
+++ b/diffoscope/comparators/javascript.py
@@ -34,10 +34,6 @@ class JavaScriptBeautify(Command):
class JavaScriptFile(File):
RE_FILE_EXTENSION = re.compile(r'\.js$')
- @staticmethod
- def recognizes(file):
- return JavaScriptFile.RE_FILE_EXTENSION.search(file.name)
-
def compare_details(self, other, source=None):
return [Difference.from_command(JavaScriptBeautify, self.path, other.path)]
diff --git a/diffoscope/comparators/utils/specialize.py b/diffoscope/comparators/utils/specialize.py
index 0a18eb2..57230da 100644
--- a/diffoscope/comparators/utils/specialize.py
+++ b/diffoscope/comparators/utils/specialize.py
@@ -39,6 +39,8 @@ def specialize(file):
# No recognizes() method specified, try an auto recognition
if hasattr(cls, 'RE_FILE_TYPE'):
ret = cls.RE_FILE_TYPE.search(file.magic_file_type)
+ elif hasattr(cls, 'RE_FILE_EXTENSION'):
+ ret = cls.RE_FILE_EXTENSION.search(file.name)
if ret:
logger.debug("Using %s for %s", cls.__name__, file.name)
new_cls = type(cls.__name__, (cls, type(file)), {})
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list