Mercurial > repos > cropgeeks > flapjack
diff flapjack.py @ 35:414aa590a1de draft
Uploaded
author | cropgeeks |
---|---|
date | Thu, 02 Mar 2017 05:40:54 -0500 |
parents | 591567e072f1 |
children | 927533e85a6a |
line wrap: on
line diff
--- a/flapjack.py Tue Feb 28 05:01:03 2017 -0500 +++ b/flapjack.py Thu Mar 02 05:40:54 2017 -0500 @@ -1,8 +1,26 @@ from galaxy.datatypes.data import Text from galaxy.datatypes.tabular import Tabular +from galaxy.datatypes.binary import SQlite -class FlapjackFormat(Text): +class FlapjackFormat(SQlite): file_ext = "flapjack" + + def sniff(self, filename): + if super(FlapjackFormat, self).sniff(filename): + fj_table_names = ["objects", "project"] + try: + conn = sqlite.connect( filename ) + c = conn.cursor() + tables_query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name" + result = c.execute(tables_query).fetchall() + result = [_[0] for _ in result] + for table_name in fj_table_names: + if table_name not in result: + return False + return True + except Exception as e: + log.warning( '%s, sniff Exception: %s', self, e ) + return False class FlapjackMapFormat(Tabular): file_ext = "fjmap"