mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Refactoring, because it was bugging me.
This commit is contained in:
@@ -8,8 +8,8 @@ from six.moves.urllib.parse import quote_plus
|
||||
from galaxy.datatypes.binary import Binary
|
||||
from galaxy.datatypes.sniff import get_headers
|
||||
from galaxy.datatypes.text import Html as HtmlFromText
|
||||
from galaxy.datatypes.util.image_util import check_image_type
|
||||
from galaxy.util import nice_size
|
||||
from galaxy.util.image_util import check_image_type
|
||||
from . import data
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -15,9 +15,9 @@ from six import PY3
|
||||
from galaxy import util
|
||||
from galaxy.datatypes import metadata
|
||||
from galaxy.util.checkers import is_gzip
|
||||
from galaxy.util.image_util import check_image_type
|
||||
from galaxy.datatypes.metadata import MetadataElement
|
||||
from galaxy.datatypes.sniff import get_headers
|
||||
from galaxy.datatypes.util.image_util import check_image_type
|
||||
from galaxy.util import nice_size
|
||||
from . import data
|
||||
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
import bz2
|
||||
import gzip
|
||||
import imghdr
|
||||
import re
|
||||
import zipfile
|
||||
|
||||
from six import StringIO
|
||||
|
||||
from galaxy import util
|
||||
from galaxy.util.image_util import image_type
|
||||
|
||||
HTML_CHECK_LINES = 100
|
||||
|
||||
|
||||
def check_image( file_path ):
|
||||
if imghdr.what( file_path ) is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def check_html( file_path, chunk=None ):
|
||||
if chunk is None:
|
||||
temp = open( file_path, "U" )
|
||||
@@ -126,6 +120,13 @@ def is_gzip( file_path ):
|
||||
return is_gzipped
|
||||
|
||||
|
||||
def check_image( file_path ):
|
||||
""" Simple wrapper around image_type to yield a True/False verdict """
|
||||
if image_type( file_path ):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
__all__ = [
|
||||
'check_binary',
|
||||
'check_bz2',
|
||||
|
||||
@@ -20,17 +20,10 @@ from galaxy import util
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy.datatypes.binary import Binary
|
||||
from galaxy.datatypes.registry import Registry
|
||||
from galaxy.datatypes.util.image_util import get_image_ext
|
||||
from galaxy.util import multi_byte
|
||||
from galaxy.util.checkers import check_binary, check_bz2, check_gzip, check_html, check_image, check_zip
|
||||
from galaxy.util.checkers import check_binary, check_bz2, check_gzip, check_html, check_zip
|
||||
from galaxy.util.image_util import get_image_ext
|
||||
|
||||
try:
|
||||
import Image as PIL
|
||||
except ImportError:
|
||||
try:
|
||||
from PIL import Image as PIL
|
||||
except:
|
||||
PIL = None
|
||||
|
||||
try:
|
||||
import bz2
|
||||
@@ -116,8 +109,9 @@ def add_file( dataset, registry, json_file, output_path ):
|
||||
except UnicodeDecodeError as e:
|
||||
dataset.is_multi_byte = False
|
||||
# Is dataset an image?
|
||||
if check_image( dataset.path ):
|
||||
ext = get_image_ext( dataset.path )
|
||||
i_ext = get_image_ext( dataset.path )
|
||||
if i_ext:
|
||||
ext = i_ext
|
||||
data_type = ext
|
||||
# Is dataset content multi-byte?
|
||||
elif dataset.is_multi_byte:
|
||||
|
||||
Reference in New Issue
Block a user