commit/galaxy-central: dan: Minor enhancements for GenomeSpace import naming of secondary files.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/6db344e2ce55/ changeset: 6db344e2ce55 user: dan date: 2012-10-19 21:26:51 summary: Minor enhancements for GenomeSpace import naming of secondary files. affected #: 2 files diff -r 083d480bf5e35009f01e9439f11aa7e68716e429 -r 6db344e2ce554f4332b048dd41bb158e26c49fed tools/genomespace/genomespace_file_browser.py --- a/tools/genomespace/genomespace_file_browser.py +++ b/tools/genomespace/genomespace_file_browser.py @@ -39,6 +39,7 @@ 'gmt': 'gmt', 'gct': 'gct'} +VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' def chunk_write( source_stream, target_stream, source_method = "read", target_method="write" ): source_method = getattr( source_stream, source_method ) @@ -113,6 +114,7 @@ name = name[len( file_url_prefix ):] file_numbers.append( int( name ) ) file_numbers.sort() + used_filenames = [] for file_num in file_numbers: url_key = "%s%i" % ( file_url_prefix, file_num ) download_url = datasource_params.get( url_key, None ) @@ -135,8 +137,14 @@ parsed_url = urlparse.urlparse( download_url ) query_params = urlparse.parse_qs( parsed_url[4] ) filename = urllib.unquote_plus( parsed_url[2].split( '/' )[-1] ) + if not filename: + filename = download_url if output_filename is None: - output_filename = os.path.join( datasource_params['__new_file_path__'], 'primary_%i_output%i_visible_%s' % ( hda_id, file_num, galaxy_ext ) ) + filename = ''.join( c in VALID_CHARS and c or '-' for c in filename ) + while filename in used_filenames: + filename = "-%s" % filename + used_filenames.append( filename ) + output_filename = os.path.join( datasource_params['__new_file_path__'], 'primary_%i_%s_visible_%s' % ( hda_id, filename, galaxy_ext ) ) else: if dataset_id is not None: metadata_parameter_file.write( "%s\n" % simplejson.dumps( dict( type = 'dataset', diff -r 083d480bf5e35009f01e9439f11aa7e68716e429 -r 6db344e2ce554f4332b048dd41bb158e26c49fed tools/genomespace/genomespace_importer.py --- a/tools/genomespace/genomespace_importer.py +++ b/tools/genomespace/genomespace_importer.py @@ -43,7 +43,7 @@ 'gmt': 'gmt', 'gct': 'gct'} -VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' +VALID_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' def chunk_write( source_stream, target_stream, source_method = "read", target_method="write" ): source_method = getattr( source_stream, source_method ) @@ -112,6 +112,7 @@ datatypes_registry = Registry() datatypes_registry.load_datatypes( root_dir = json_params[ 'job_config' ][ 'GALAXY_ROOT_DIR' ], config = json_params[ 'job_config' ][ 'GALAXY_DATATYPES_CONF_FILE' ] ) url_param = datasource_params.get( file_url_name, None ) + used_filenames = [] for download_url in url_param.split( ',' ): using_temp_file = False parsed_url = urlparse.urlparse( download_url ) @@ -129,6 +130,8 @@ parsed_url = urlparse.urlparse( download_url ) query_params = urlparse.parse_qs( parsed_url[4] ) filename = urllib.unquote_plus( parsed_url[2].split( '/' )[-1] ) + if not filename: + filename = download_url if output_filename is None: #need to use a temp file here, because we do not know the ext yet using_temp_file = True @@ -179,7 +182,11 @@ name = "GenomeSpace importer on %s" % ( filename ) ) ) ) #if using tmp file, move the file to the new file path dir to get scooped up later if using_temp_file: - shutil.move( output_filename, os.path.join( datasource_params['__new_file_path__'], 'primary_%i_output%s_visible_%s' % ( hda_id, ''.join( c in VALID_CHARS and c or '-' for c in filename ), file_type ) ) ) + filename = ''.join( c in VALID_CHARS and c or '-' for c in filename ) + while filename in used_filenames: + filename = "-%s" % filename + used_filenames.append( filename ) + shutil.move( output_filename, os.path.join( datasource_params['__new_file_path__'], 'primary_%i_%s_visible_%s' % ( hda_id, filename, file_type ) ) ) dataset_id = None #only one primary dataset available output_filename = None #only have one filename available Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket