changeset 39:c8c40cbe2945 draft

Uploaded
author cropgeeks
date Thu, 02 Mar 2017 08:16:25 -0500
parents 7ae1bb322c6f
children 4a0f069c98e0
files flapjack.py
diffstat 1 files changed, 11 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flapjack.py	Thu Mar 02 08:01:45 2017 -0500
+++ b/flapjack.py	Thu Mar 02 08:16:25 2017 -0500
@@ -1,14 +1,17 @@
 from galaxy.datatypes.data import Text
 from galaxy.datatypes.tabular import Tabular
-from galaxy.datatypes.binary import SQlite
+from galaxy.datatypes.binary import Binary
 
-class FlapjackFormat(SQlite):
+class FlapjackFormat(Binary):
     file_ext = "flapjack"
 	
 	def sniff(self, filename):
-        if super(FlapjackFormat, self).sniff(filename):
-			fj_table_names = ["objects", "project"]
-            try:
+        # The first 16 bytes of any SQLite3 database file is 'SQLite format 3\0', and the file is binary. For details
+        # about the format, see http://www.sqlite.org/fileformat.html
+        try:
+            header = open(filename, 'rb').read(16)
+            if header == b'SQLite format 3\0':
+                fj_table_names = ["objects", "project"]
                 conn = sqlite.connect(filename)
                 c = conn.cursor()
                 tables_query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
@@ -18,9 +21,9 @@
                     if table_name not in result:
                         return False
                 return True
-            except Exception as e:
-                log.warning('%s, sniff Exception: %s', self, e)
-        return False
+            return False
+        except:
+            return False
         
 Binary.register_sniffable_binary_format( "flapjack", "flapjack", FlapjackFormat)