0
|
1 # -*- coding: utf-8 -*-
|
|
2 """
|
|
3 no_unzip_datatypes
|
|
4
|
|
5 A perfect clone of the prims masscomb datatype FileSet
|
|
6 """
|
|
7
|
|
8 import logging
|
|
9 import zipfile
|
|
10 import os,os.path,re
|
|
11 from galaxy.datatypes.data import *
|
|
12 from galaxy.datatypes.xml import *
|
|
13 from galaxy.datatypes.sniff import *
|
|
14 from galaxy.datatypes.binary import *
|
|
15 from galaxy.datatypes.interval import *
|
|
16
|
|
17 log = logging.getLogger(__name__)
|
|
18
|
|
19
|
|
20 class NoUnzip( Binary ):
|
|
21 """FileSet containing N files"""
|
|
22 file_ext = "no_unzip.zip"
|
|
23 blurb = "(zipped) FileSet containing multiple files"
|
|
24
|
|
25 def sniff( self, filename ):
|
|
26 # If the zip file contains multiple files then return true, false otherwise:
|
|
27 zf = zipfile.ZipFile(filename)
|
|
28 if (len(zf.infolist())>1):
|
|
29 return True
|
|
30 else :
|
|
31 return False
|
|
32
|
|
33
|
|
34 # the if is just for backwards compatibility...could remove this at some point
|
|
35 if hasattr(Binary, 'register_sniffable_binary_format'):
|
|
36 Binary.register_sniffable_binary_format('NoUnzip', 'no_unzip.zip', NoUnzip)
|
|
37
|
|
38
|
|
39
|
|
40
|
|
41
|
|
42
|
|
43
|
|
44
|
|
45
|