[diffoscope] [PATCH] fix sqlite3 magic recognition when using file >= 5.27

anthraxx levente at leventepolyak.net
Mon Jun 6 20:27:31 CEST 2016

this fixes the recognition problems of sqlite3 as newer
file versions add additional information to the magic
The new string is like:
  SQLite 3.x database, last written using SQLite version 3008011

To be compatible with both, newer and older file versions we
check if the magic_file_type has any value and starts with the expected
recognition string.
 diffoscope/comparators/sqlite.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/diffoscope/comparators/sqlite.py b/diffoscope/comparators/sqlite.py
index e361dea..16706d7 100644
--- a/diffoscope/comparators/sqlite.py
+++ b/diffoscope/comparators/sqlite.py
@@ -32,7 +32,7 @@ class Sqlite3Dump(Command):
 class Sqlite3Database(File):
     def recognizes(file):
-        return file.magic_file_type == 'SQLite 3.x database'
+        return file.magic_file_type and file.magic_file_type.startswith('SQLite 3.x database')
     def compare_details(self, other, source=None):
         return [Difference.from_command(Sqlite3Dump, self.path, other.path)]

More information about the diffoscope mailing list