[diffoscope] 01/02: comparators.sqlite: Simplify file detection by rewriting manual `recognizes` call with a `Sqlite3Database.RE_FILE_TYPE` definition.

Chris Lamb chris at chris-lamb.co.uk
Tue Jul 18 23:10:07 CEST 2017


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 812416fc1bb9ffc95e341092a79c32d946c81691
Author: Chris Lamb <lamby at debian.org>
Date:   Tue Jul 18 22:03:53 2017 +0100

    comparators.sqlite: Simplify file detection by rewriting manual `recognizes` call with a `Sqlite3Database.RE_FILE_TYPE` definition.
---
 diffoscope/comparators/sqlite.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/diffoscope/comparators/sqlite.py b/diffoscope/comparators/sqlite.py
index d49f7f7..f057605 100644
--- a/diffoscope/comparators/sqlite.py
+++ b/diffoscope/comparators/sqlite.py
@@ -17,6 +17,8 @@
 # You should have received a copy of the GNU General Public License
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
+import re
+
 from diffoscope.tools import tool_required
 from diffoscope.difference import Difference
 
@@ -31,10 +33,7 @@ class Sqlite3Dump(Command):
 
 
 class Sqlite3Database(File):
-    @staticmethod
-    def recognizes(file):
-        return file.magic_file_type and file.magic_file_type.startswith('SQLite 3.x database')
+    RE_FILE_TYPE = re.compile(r'^SQLite 3.x database')
 
     def compare_details(self, other, source=None):
         return [Difference.from_command(Sqlite3Dump, self.path, other.path)]
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list