Skip to content

Commit

Permalink
Merge pull request #4559 from mvdbeek/use_bzip2file
Browse files Browse the repository at this point in the history
Allow working with pbzip2 compressed files
  • Loading branch information
nsoranzo committed Sep 6, 2017
2 parents 3aacbdf + 8c4716e commit 486f436
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
6 changes: 5 additions & 1 deletion lib/galaxy/datatypes/sniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import absolute_import

import bz2
import codecs
import gzip
import logging
Expand All @@ -30,6 +29,11 @@
is_gzip
)

if sys.version_info < (3, 3):
import bz2file as bz2
else:
import bz2

log = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/dependencies/pinned-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ uWSGI==2.0.15
#python_lzo==1.8

# pure Python packages
bz2file==0.98; python_version < '3.3'
Paste==2.0.2
PasteDeploy==1.5.2
docutils==0.12
Expand Down Expand Up @@ -77,4 +78,4 @@ ecdsa==0.13
pysam==0.8.4+gx5

# GenomeSpace dependencies
python-genomespaceclient==0.1.8
python-genomespaceclient==0.1.8
1 change: 1 addition & 0 deletions lib/galaxy/dependencies/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pycrypto
#python_lzo

# pure Python packages
bz2file; python_version < '3.3'
Paste
PasteDeploy
docutils
Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/util/checkers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import bz2
import gzip
import re
import sys
import zipfile

from six import StringIO

from galaxy import util
from galaxy.util.image_util import image_type

if sys.version_info < (3, 3):
import bz2file as bz2
else:
import bz2

HTML_CHECK_LINES = 100


Expand Down
7 changes: 6 additions & 1 deletion lib/galaxy/util/compression_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import bz2
import gzip
import sys
import zipfile

from .checkers import (
is_bz2,
is_gzip
)

if sys.version_info < (3, 3):
import bz2file as bz2
else:
import bz2


def get_fileobj(filename, mode="r", gzip_only=False, bz2_only=False, zip_only=False):
"""
Expand Down
7 changes: 6 additions & 1 deletion lib/tool_shed/util/commit_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import bz2
import gzip
import json
import logging
import os
import shutil
import sys
import tempfile
from collections import namedtuple

Expand All @@ -14,6 +14,11 @@
from tool_shed.tools import data_table_manager
from tool_shed.util import basic_util, hg_util, shed_util_common as suc

if sys.version_info < (3, 3):
import bz2file as bz2
else:
import bz2

log = logging.getLogger(__name__)

UNDESIRABLE_DIRS = ['.hg', '.svn', '.git', '.cvs']
Expand Down
10 changes: 5 additions & 5 deletions tools/data_source/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
from galaxy.util.image_util import get_image_ext


try:
if sys.version_info < (3, 3):
import bz2file as bz2
else:
import bz2
except:
bz2 = None

assert sys.version_info[:2] >= (2, 4)
assert sys.version_info[:2] >= (2, 7)


def stop_err(msg, ret=1):
Expand Down Expand Up @@ -165,7 +165,7 @@ def add_file(dataset, registry, json_file, output_path):
os.chmod(dataset.path, 0o644)
dataset.name = dataset.name.rstrip('.gz')
data_type = 'gzip'
if not data_type and bz2 is not None:
if not data_type:
# See if we have a bz2 file, much like gzip
is_bzipped, is_valid = check_bz2(dataset.path, check_content)
if is_bzipped and not is_valid:
Expand Down

0 comments on commit 486f436

Please sign in to comment.