Mercurial > repos > da-intersect > ap11_test
annotate tar.py @ 5:795f289b64db draft
First complete upload, containing the datatype TAR.
| author | da-intersect |
|---|---|
| date | Wed, 10 Apr 2013 02:41:02 -0400 |
| parents | |
| children |
| rev | line source |
|---|---|
|
5
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
1 from galaxy import eggs |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
2 import pkg_resources |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
3 pkg_resources.require( "bx-python" ) |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
4 |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
5 import logging, os, sys, time, sets, tempfile, shutil |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
6 import data |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
7 from galaxy import util |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
8 from galaxy.datatypes.sniff import * |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
9 from galaxy.datatypes.binary import Binary |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
10 import tarfile |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
11 |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
12 class Tar( Binary ): |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
13 """Class describing a BAM binary file""" |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
14 file_ext = "tar" |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
15 def sniff( self, filename ): |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
16 try: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
17 if tarfile.is_tarfile(filename): |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
18 return True |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
19 return False |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
20 except: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
21 return False |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
22 def set_peek( self, dataset, is_multi_byte=False ): |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
23 if not dataset.dataset.purged: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
24 dataset.peek = "Tar file" |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
25 dataset.blurb = data.nice_size( dataset.get_size() ) |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
26 else: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
27 dataset.peek = 'file does not exist' |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
28 dataset.blurb = 'file purged from disk' |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
29 def display_peek( self, dataset ): |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
30 try: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
31 return dataset.peek |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
32 except: |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
33 return "Tar file (%s)" % ( data.nice_size( dataset.get_size() ) ) |
|
795f289b64db
First complete upload, containing the datatype TAR.
da-intersect
parents:
diff
changeset
|
34 |
