Mercurial > repos > fgiacomoni > xseekerpreparator
view galaxy/lib/galaxy/datatypes/text.py @ 0:1660665c081e draft
#issue9 branch Updating - - Fxx
author | fgiacomoni |
---|---|
date | Thu, 19 Nov 2020 14:28:46 +0000 |
parents | |
children |
line wrap: on
line source
@build_sniff_from_prefix class SQL(Text): """Class describing an html file""" file_ext = "sql" def set_peek(self, dataset, is_multi_byte=False): if not dataset.dataset.purged: dataset.peek = "SQL file" dataset.blurb = nice_size(dataset.get_size()) else: dataset.peek = "file does not exist" dataset.blurb = "file purged from disk" def get_mime(self): """Returns the mime type of the datatype""" return "application/sql" def sniff_prefix(self, file_prefix): """ Uses some patterns usualy encountered in sql files to guess it's type """ start = file_prefix.string_io().read(42).strip() return any( header in start for header in ( "CREATE DATABASE", "INSERT INTO", "CREATE TABLE", "BEGIN TRANSACTION" ) )