[diffoscope] 01/02: specialize: Only profile the calls to 'recognizes'
Chris Lamb
chris at chris-lamb.co.uk
Sun Jan 15 13:01:10 CET 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit a2be28a56c33e5d7b777641eadf39343f1f8c8d6
Author: Chris Lamb <lamby at debian.org>
Date: Sun Jan 15 22:55:13 2017 +1100
specialize: Only profile the calls to 'recognizes'
Signed-off-by: Chris Lamb <lamby at debian.org>
---
diffoscope/comparators/utils/specialize.py | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/diffoscope/comparators/utils/specialize.py b/diffoscope/comparators/utils/specialize.py
index 57230da..49f1811 100644
--- a/diffoscope/comparators/utils/specialize.py
+++ b/diffoscope/comparators/utils/specialize.py
@@ -31,21 +31,21 @@ def specialize(file):
for cls in FILE_CLASSES:
if isinstance(file, cls):
return file
- with profile('recognizes', file):
- ret = False
- if hasattr(cls, 'recognizes'):
+ ret = False
+ if hasattr(cls, 'recognizes'):
+ with profile('recognizes', file):
ret = cls.recognizes(file)
- else:
- # 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)), {})
- file.__class__ = new_cls
- return file
+ else:
+ # 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)), {})
+ file.__class__ = new_cls
+ return file
logger.debug('Unidentified file. Magic says: %s', file.magic_file_type)
return 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