annotate tar.py @ 7:1581c2d80588

Uploaded
author da-intersect
date Thu, 11 Apr 2013 01:28:30 -0400
parents
children 3cff57242c39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
1 import data, logging, binascii
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
2 from galaxy.datatypes.metadata import MetadataElement
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
3 from galaxy.datatypes import metadata
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
4 from galaxy.datatypes.sniff import *
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
5 from galaxy import eggs
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
6 import pkg_resources
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
7 pkg_resources.require( "bx-python" )
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
8 from urllib import urlencode, quote_plus
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
9 import zipfile, gzip
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
10 import os, subprocess, tempfile, tarfile
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
11 import struct
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
12
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
13 class Tar( Binary ):
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
14 """Class describing a BAM binary file"""
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
15 file_ext = "tar"
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
16 def sniff( self, filename ):
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
17 try:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
18 if tarfile.is_tarfile(filename):
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
19 return True
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
20 except:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
21 return False
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
22
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
23 def set_peek( self, dataset, is_multi_byte=False ):
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
24 if not dataset.dataset.purged:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
25 dataset.peek = "Tar file"
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
26 dataset.blurb = data.nice_size( dataset.get_size() )
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
27 else:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
28 dataset.peek = 'file does not exist'
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
29 dataset.blurb = 'file purged from disk'
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
30
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
31 def display_peek( self, dataset ):
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
32 try:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
33 return dataset.peek
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
34 except:
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
35 return "Tar file (%s)" % ( data.nice_size( dataset.get_size() ) )
1581c2d80588 Uploaded
da-intersect
parents:
diff changeset
36