def check_file_content_for_html_and_images( file_path ): message = '' if checkers.check_html( file_path ): message = 'The file "%s" contains HTML content.\n' % str( file_path ) elif checkers.check_image( file_path ): message = 'The file "%s" contains image content.\n' % str( file_path ) return message
def check_file_content_for_html_and_images(file_path): message = '' if checkers.check_html(file_path): message = 'The file "%s" contains HTML content.\n' % str(file_path) elif checkers.check_image(file_path): message = 'The file "%s" contains image content.\n' % str(file_path) return message
def __check_file_content( self, file_path ): message = '' if checkers.check_html( file_path ): message = 'The file "%s" contains HTML content.\n' % str( file_path ) elif checkers.check_image( file_path ): message = 'The file "%s" contains image content.\n' % str( file_path ) return message
def __check_file_content(self, file_path): message = '' if checkers.check_html(file_path): message = 'The file "%s" contains HTML content.\n' % str(file_path) elif checkers.check_image(file_path): message = 'The file "%s" contains image content.\n' % str( file_path) return message
def is_data_index_sample_file(file_path): """ Attempt to determine if a .sample file is appropriate for copying to ~/tool-data when a tool shed repository is being installed into a Galaxy instance. """ # Currently most data index files are tabular, so check that first. We'll assume that # if the file is tabular, it's ok to copy. if is_column_based(file_path): return True # If the file is any of the following, don't copy it. if checkers.check_html(file_path): return False if checkers.check_image(file_path): return False if checkers.check_binary(name=file_path): return False if checkers.is_bz2(file_path): return False if checkers.is_gzip(file_path): return False if checkers.check_zip(file_path): return False # Default to copying the file if none of the above are true. return True
dataset.path = temp_name # See if we have an empty file if not os.path.exists( dataset.path ): file_err( 'Uploaded temporary file (%s) does not exist.' % dataset.path, dataset, json_file ) return if not os.path.getsize( dataset.path ) > 0: file_err( 'The uploaded file is empty', dataset, json_file ) return if not dataset.type == 'url': # Already set is_multi_byte above if type == 'url' try: dataset.is_multi_byte = util.is_multi_byte( codecs.open( dataset.path, 'r', 'utf-8' ).read( 100 ) ) except UnicodeDecodeError, e: dataset.is_multi_byte = False # Is dataset an image? image = check_image( dataset.path ) if image: if not PIL: image = None # get_image_ext() returns None if nor a supported Image type ext = get_image_ext( dataset.path, image ) data_type = ext # Is dataset content multi-byte? elif dataset.is_multi_byte: data_type = 'multi-byte char' ext = sniff.guess_ext( dataset.path, is_multi_byte=True ) # Is dataset content supported sniffable binary? else: # FIXME: This ignores the declared sniff order in datatype_conf.xml # resulting in improper behavior type_info = Binary.is_sniffable_binary( dataset.path )
if not os.path.exists(dataset.path): file_err('Uploaded temporary file (%s) does not exist.' % dataset.path, dataset, json_file) return if not os.path.getsize(dataset.path) > 0: file_err('The uploaded file is empty', dataset, json_file) return if not dataset.type == 'url': # Already set is_multi_byte above if type == 'url' try: dataset.is_multi_byte = util.is_multi_byte( codecs.open(dataset.path, 'r', 'utf-8').read(100)) except UnicodeDecodeError, e: dataset.is_multi_byte = False # Is dataset an image? image = check_image(dataset.path) if image: if not PIL: image = None # get_image_ext() returns None if nor a supported Image type ext = get_image_ext(dataset.path, image) data_type = ext # Is dataset content multi-byte? elif dataset.is_multi_byte: data_type = 'multi-byte char' ext = sniff.guess_ext(dataset.path, is_multi_byte=True) # Is dataset content supported sniffable binary? else: # FIXME: This ignores the declared sniff order in datatype_conf.xml # resulting in improper behavior type_info = Binary.is_sniffable_binary(dataset.path)