Merge pull request #9595 from lecorguille/patch-2

Sniffer for multi-member zip archives
This commit is contained in:
Nicola Soranzo
2020-04-11 22:21:32 +01:00
committed by GitHub
2 changed files with 12 additions and 0 deletions
@@ -843,6 +843,8 @@
<sniffer type="galaxy.datatypes.binary:Cpt"/>
<sniffer type="galaxy.datatypes.binary:Edr"/>
<sniffer type="galaxy.datatypes.binary:Vel"/>
<sniffer type="galaxy.datatypes.binary:Xlsx"/>
<sniffer type="galaxy.datatypes.binary:CompressedZipArchive"/>
<sniffer type="galaxy.datatypes.annotation:Augustus"/>
<sniffer type="galaxy.datatypes.triples:Rdf"/>
<sniffer type="galaxy.datatypes.blast:BlastXml"/>
+10
View File
@@ -249,6 +249,16 @@ class CompressedZipArchive(CompressedArchive):
except Exception:
return "Compressed zip file (%s)" % (nice_size(dataset.get_size()))
def sniff(self, filename):
with zipfile.ZipFile(filename) as zf:
zf_files = zf.infolist()
count = 0
for f in zf_files:
if f.file_size > 0 and not f.filename.startswith('__MACOSX/') and not f.filename.endswith('.DS_Store'):
count += 1
if count > 1:
return True
class GenericAsn1Binary(Binary):
"""Class for generic ASN.1 binary format"""