1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/9cce4ead1079/ Changeset: 9cce4ead1079 User: greg Date: 2014-07-22 21:12:40 Summary: Add a ToolDataTableManager for managing tool data tables in the Tool Shed. Affected #: 9 files diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -13,13 +13,13 @@ from tool_shed.dependencies import attribute_handlers from tool_shed.galaxy_install import dependency_display from tool_shed.metadata import repository_metadata_manager -import tool_shed.repository_types.util as rt_util +from tool_shed.repository_types import util as rt_util +from tool_shed.tools import data_table_manager from tool_shed.util import basic_util from tool_shed.util import commit_util from tool_shed.util import hg_util from tool_shed.util import shed_util_common as suc -from tool_shed.util import tool_util from tool_shed.util import xml_util from galaxy import eggs @@ -100,6 +100,7 @@ if uploaded_file or uploaded_directory: rdah = attribute_handlers.RepositoryDependencyAttributeHandler( trans.app, unpopulate=False ) tdah = attribute_handlers.ToolDependencyAttributeHandler( trans.app, unpopulate=False ) + tdtm = data_table_manager.ToolDataTableManager( trans.app ) ok = True isgzip = False isbz2 = False @@ -221,7 +222,7 @@ # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded # by parsing the file and adding new entries to the in-memory trans.app.tool_data_tables # dictionary. - error, error_message = tool_util.handle_sample_tool_data_table_conf_file( trans.app, full_path ) + error, error_message = tdtm.handle_sample_tool_data_table_conf_file( full_path, persist=False ) if error: message = '%s<br/>%s' % ( message, error_message ) # See if the content of the change set was valid. @@ -309,7 +310,7 @@ message += invalid_repository_dependencies_message status = 'error' # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - tool_util.reset_tool_data_tables( trans.app ) + tdtm.reset_tool_data_tables() if uploaded_directory: basic_util.remove_dir( uploaded_directory ) trans.response.send_redirect( web.url_for( controller='repository', @@ -323,7 +324,7 @@ basic_util.remove_dir( uploaded_directory ) status = 'error' # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - tool_util.reset_tool_data_tables( trans.app ) + tdtm.reset_tool_data_tables() selected_categories = [ trans.security.decode_id( id ) for id in category_ids ] return trans.fill_template( '/webapps/tool_shed/repository/upload.mako', repository=repository, diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/galaxy_install/install_manager.py --- a/lib/tool_shed/galaxy_install/install_manager.py +++ b/lib/tool_shed/galaxy_install/install_manager.py @@ -35,6 +35,7 @@ from tool_shed.galaxy_install.tools import data_manager from tool_shed.galaxy_install.tools import tool_panel_manager +from tool_shed.tools import data_table_manager from tool_shed.tools import tool_version_manager log = logging.getLogger( __name__ ) @@ -508,6 +509,7 @@ reinstalling an uninstalled repository. """ shed_config_dict = self.app.toolbox.get_shed_config_dict_by_filename( shed_tool_conf ) + tdtm = data_table_manager.ToolDataTableManager( self.app ) irmm = InstalledRepositoryMetadataManager( self.app, self.tpm ) metadata_dict, invalid_file_tups = \ irmm.generate_metadata_for_changeset_revision( repository=tool_shed_repository, @@ -533,9 +535,9 @@ set_status=True ) if 'sample_files' in metadata_dict: sample_files = metadata_dict.get( 'sample_files', [] ) - tool_index_sample_files = tool_util.get_tool_index_sample_files( sample_files ) + tool_index_sample_files = tdtm.get_tool_index_sample_files( sample_files ) tool_data_table_conf_filename, tool_data_table_elems = \ - tool_util.install_tool_data_tables( self.app, tool_shed_repository, tool_index_sample_files ) + tdtm.install_tool_data_tables( tool_shed_repository, tool_index_sample_files ) if tool_data_table_elems: self.app.tool_data_tables.add_new_entries_from_config_file( tool_data_table_conf_filename, None, @@ -544,16 +546,15 @@ if 'tools' in metadata_dict: tool_panel_dict = self.tpm.generate_tool_panel_dict_for_new_install( metadata_dict[ 'tools' ], tool_section ) sample_files = metadata_dict.get( 'sample_files', [] ) - tool_index_sample_files = tool_util.get_tool_index_sample_files( sample_files ) + tool_index_sample_files = tdtm.get_tool_index_sample_files( sample_files ) tool_util.copy_sample_files( self.app, tool_index_sample_files, tool_path=tool_path ) sample_files_copied = [ str( s ) for s in tool_index_sample_files ] repository_tools_tups = irmm.get_repository_tools_tups( metadata_dict ) if repository_tools_tups: # Handle missing data table entries for tool parameters that are dynamically generated select lists. - repository_tools_tups = tool_util.handle_missing_data_table_entry( self.app, - relative_install_dir, - tool_path, - repository_tools_tups ) + repository_tools_tups = tdtm.handle_missing_data_table_entry( relative_install_dir, + tool_path, + repository_tools_tups ) # Handle missing index files for tool parameters that are dynamically generated select lists. repository_tools_tups, sample_files_copied = tool_util.handle_missing_index_file( self.app, tool_path, diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/galaxy_install/tool_migration_manager.py --- a/lib/tool_shed/galaxy_install/tool_migration_manager.py +++ b/lib/tool_shed/galaxy_install/tool_migration_manager.py @@ -17,6 +17,7 @@ from tool_shed.galaxy_install.metadata.installed_repository_metadata_manager import InstalledRepositoryMetadataManager from tool_shed.galaxy_install.tools import tool_panel_manager +from tool_shed.tools import data_table_manager from tool_shed.tools import tool_version_manager from tool_shed.util import basic_util @@ -440,25 +441,27 @@ else: tool_dependencies = None if 'tools' in metadata_dict: + tdtm = data_table_manager.ToolDataTableManager( self.app ) sample_files = metadata_dict.get( 'sample_files', [] ) sample_files = [ str( s ) for s in sample_files ] - tool_index_sample_files = tool_util.get_tool_index_sample_files( sample_files ) + tool_index_sample_files = tdtm.get_tool_index_sample_files( sample_files ) tool_util.copy_sample_files( self.app, tool_index_sample_files, tool_path=self.tool_path ) sample_files_copied = [ s for s in tool_index_sample_files ] repository_tools_tups = irmm.get_repository_tools_tups( metadata_dict ) if repository_tools_tups: - # Handle missing data table entries for tool parameters that are dynamically generated select lists. - repository_tools_tups = tool_util.handle_missing_data_table_entry( self.app, - relative_install_dir, - self.tool_path, - repository_tools_tups ) + # Handle missing data table entries for tool parameters that are dynamically + # generated select lists. + repository_tools_tups = tdtm.handle_missing_data_table_entry( relative_install_dir, + self.tool_path, + repository_tools_tups ) # Handle missing index files for tool parameters that are dynamically generated select lists. repository_tools_tups, sample_files_copied = tool_util.handle_missing_index_file( self.app, self.tool_path, sample_files, repository_tools_tups, sample_files_copied ) - # Copy remaining sample files included in the repository to the ~/tool-data directory of the local Galaxy instance. + # Copy remaining sample files included in the repository to the ~/tool-data + # directory of the local Galaxy instance. tool_util.copy_sample_files( self.app, sample_files, tool_path=self.tool_path, diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/metadata/repository_metadata_manager.py --- a/lib/tool_shed/metadata/repository_metadata_manager.py +++ b/lib/tool_shed/metadata/repository_metadata_manager.py @@ -897,7 +897,7 @@ # revisions from the changelog. self.reset_all_tool_versions( id, repo ) # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - tool_util.reset_tool_data_tables( self.app ) + self.app.tool_data_tables.data_tables = {} return invalid_file_tups, metadata_dict def reset_all_tool_versions( self, id, repo ): @@ -1085,7 +1085,7 @@ metadata_dict ) status = 'error' # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - tool_util.reset_tool_data_tables( self.app ) + self.app.tool_data_tables.data_tables = {} return message, status def set_repository_metadata_due_to_new_tip( self, host, repository, content_alert_str=None, **kwd ): diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/tools/data_table_manager.py --- /dev/null +++ b/lib/tool_shed/tools/data_table_manager.py @@ -0,0 +1,142 @@ +import logging +import os +import shutil + +from tool_shed.util import hg_util +from tool_shed.util import shed_util_common as suc +from tool_shed.util import xml_util + +log = logging.getLogger( __name__ ) + + +class ToolDataTableManager( object ): + + def __init__( self, app ): + self.app = app + + def get_tool_index_sample_files( self, sample_files ): + """ + Try to return the list of all appropriate tool data sample files included + in the repository. + """ + tool_index_sample_files = [] + for s in sample_files: + # The problem with this is that Galaxy does not follow a standard naming + # convention for file names. + if s.endswith( '.loc.sample' ) or s.endswith( '.xml.sample' ) or s.endswith( '.txt.sample' ): + tool_index_sample_files.append( str( s ) ) + return tool_index_sample_files + + def handle_missing_data_table_entry( self, relative_install_dir, tool_path, repository_tools_tups ): + """ + Inspect each tool to see if any have input parameters that are dynamically + generated select lists that require entries in the tool_data_table_conf.xml + file. This method is called only from Galaxy (not the tool shed) when a + repository is being installed or reinstalled. + """ + missing_data_table_entry = False + for index, repository_tools_tup in enumerate( repository_tools_tups ): + tup_path, guid, repository_tool = repository_tools_tup + if repository_tool.params_with_missing_data_table_entry: + missing_data_table_entry = True + break + if missing_data_table_entry: + # The repository must contain a tool_data_table_conf.xml.sample file that includes + # all required entries for all tools in the repository. + sample_tool_data_table_conf = hg_util.get_config_from_disk( 'tool_data_table_conf.xml.sample', + relative_install_dir ) + if sample_tool_data_table_conf: + # Add entries to the ToolDataTableManager's in-memory data_tables dictionary. + error, message = self.handle_sample_tool_data_table_conf_file( sample_tool_data_table_conf, + persist=True ) + if error: + # TODO: Do more here than logging an exception. + log.debug( message ) + # Reload the tool into the local list of repository_tools_tups. + repository_tool = self.app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid ) + repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) + # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. + self.reset_tool_data_tables() + return repository_tools_tups + + def handle_sample_tool_data_table_conf_file( self, filename, persist=False ): + """ + Parse the incoming filename and add new entries to the in-memory + self.app.tool_data_tables dictionary. If persist is True (should + only occur if call is from the Galaxy side, not the tool shed), the + new entries will be appended to Galaxy's shed_tool_data_table_conf.xml + file on disk. + """ + error = False + message = '' + try: + new_table_elems, message = self.app.tool_data_tables \ + .add_new_entries_from_config_file( config_filename=filename, + tool_data_path=self.app.config.tool_data_path, + shed_tool_data_table_config=self.app.config.shed_tool_data_table_config, + persist=persist ) + if message: + error = True + except Exception, e: + message = str( e ) + error = True + return error, message + + def install_tool_data_tables( self, tool_shed_repository, tool_index_sample_files ): + TOOL_DATA_TABLE_FILE_NAME = 'tool_data_table_conf.xml' + TOOL_DATA_TABLE_FILE_SAMPLE_NAME = '%s.sample' % ( TOOL_DATA_TABLE_FILE_NAME ) + SAMPLE_SUFFIX = '.sample' + SAMPLE_SUFFIX_OFFSET = -len( SAMPLE_SUFFIX ) + tool_path, relative_target_dir = tool_shed_repository.get_tool_relative_path( self.app ) + # This is where index files will reside on a per repo/installed version basis. + target_dir = os.path.join( self.app.config.shed_tool_data_path, relative_target_dir ) + if not os.path.exists( target_dir ): + os.makedirs( target_dir ) + for sample_file in tool_index_sample_files: + path, filename = os.path.split ( sample_file ) + target_filename = filename + if target_filename.endswith( SAMPLE_SUFFIX ): + target_filename = target_filename[ : SAMPLE_SUFFIX_OFFSET ] + source_file = os.path.join( tool_path, sample_file ) + # We're not currently uninstalling index files, do not overwrite existing files. + target_path_filename = os.path.join( target_dir, target_filename ) + if not os.path.exists( target_path_filename ) or target_filename == TOOL_DATA_TABLE_FILE_NAME: + shutil.copy2( source_file, target_path_filename ) + else: + log.debug( "Did not copy sample file '%s' to install directory '%s' because file already exists.", filename, target_dir ) + # For provenance and to simplify introspection, let's keep the original data table sample file around. + if filename == TOOL_DATA_TABLE_FILE_SAMPLE_NAME: + shutil.copy2( source_file, os.path.join( target_dir, filename ) ) + tool_data_table_conf_filename = os.path.join( target_dir, TOOL_DATA_TABLE_FILE_NAME ) + elems = [] + if os.path.exists( tool_data_table_conf_filename ): + tree, error_message = xml_util.parse_xml( tool_data_table_conf_filename ) + if tree: + for elem in tree.getroot(): + # Append individual table elems or other elemes, but not tables elems. + if elem.tag == 'tables': + for table_elem in elems: + elems.append( elem ) + else: + elems.append( elem ) + else: + log.debug( "The '%s' data table file was not found, but was expected to be copied from '%s' during repository installation.", + tool_data_table_conf_filename, TOOL_DATA_TABLE_FILE_SAMPLE_NAME ) + for elem in elems: + if elem.tag == 'table': + for file_elem in elem.findall( 'file' ): + path = file_elem.get( 'path', None ) + if path: + file_elem.set( 'path', os.path.normpath( os.path.join( target_dir, os.path.split( path )[1] ) ) ) + # Store repository info in the table tag set for trace-ability. + repo_elem = suc.generate_repository_info_elem_from_repository( tool_shed_repository, parent_elem=elem ) + if elems: + # Remove old data_table + os.unlink( tool_data_table_conf_filename ) + # Persist new data_table content. + self.app.tool_data_tables.to_xml_file( tool_data_table_conf_filename, elems ) + return tool_data_table_conf_filename, elems + + def reset_tool_data_tables( self ): + # Reset the tool_data_tables to an empty dictionary. + self.app.tool_data_tables.data_tables = {} diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/tools/tool_validator.py --- a/lib/tool_shed/tools/tool_validator.py +++ b/lib/tool_shed/tools/tool_validator.py @@ -6,6 +6,8 @@ from galaxy.tools import parameters from galaxy.tools.parameters import dynamic_options +from tool_shed.tools import data_table_manager + from tool_shed.util import basic_util from tool_shed.util import hg_util from tool_shed.util import shed_util_common as suc @@ -18,6 +20,7 @@ def __init__( self, app ): self.app = app + self.tdtm = data_table_manager.ToolDataTableManager( self.app ) def can_use_tool_config_disk_file( self, repository, repo, file_path, changeset_revision ): """ @@ -60,7 +63,8 @@ sample_tool_data_table_conf = hg_util.get_config_from_disk( 'tool_data_table_conf.xml.sample', repo_dir ) if sample_tool_data_table_conf: error, correction_msg = \ - tool_util.handle_sample_tool_data_table_conf_file( self.app, sample_tool_data_table_conf ) + self.tdtm.handle_sample_tool_data_table_conf_file( sample_tool_data_table_conf, + persist=False ) if error: invalid_files_and_errors_tups.append( ( 'tool_data_table_conf.xml.sample', correction_msg ) ) else: @@ -199,7 +203,8 @@ if 'tool_data_table_conf.xml.sample' in sample_files: # Load entries into the tool_data_tables if the tool requires them. tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) - error, message = tool_util.handle_sample_tool_data_table_conf_file( self.app, tool_data_table_config ) + error, message = self.tdtm.handle_sample_tool_data_table_conf_file( tool_data_table_config, + persist=False ) tool, valid, message2 = self.load_tool_from_config( repository_id, tool_config_filepath ) message = self.concat_messages( message, message2 ) return tool, valid, message, sample_files @@ -218,7 +223,8 @@ # Load entries into the tool_data_tables if the tool requires them. tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) if tool_data_table_config: - error, message = tool_util.handle_sample_tool_data_table_conf_file( self.app, tool_data_table_config ) + error, message = self.tdtm.handle_sample_tool_data_table_conf_file( tool_data_table_config, + persist=False ) if error: log.debug( message ) manifest_ctx, ctx_file = hg_util.get_ctx_file_path_from_manifest( tool_config_filename, repo, changeset_revision ) @@ -279,7 +285,7 @@ basic_util.remove_dir( work_dir ) self.app.config.tool_data_path = original_tool_data_path # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - tool_util.reset_tool_data_tables( self.app ) + self.tdtm.reset_tool_data_tables() return repository, tool, message def load_tool_from_config( self, repository_id, full_path ): diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -4,11 +4,15 @@ import os import shutil import tempfile + from galaxy.datatypes import checkers + +from tool_shed.tools import data_table_manager + from tool_shed.util import basic_util from tool_shed.util import hg_util from tool_shed.util import shed_util_common as suc -from tool_shed.util import tool_util + import tool_shed.repository_types.util as rt_util log = logging.getLogger( __name__ ) @@ -184,7 +188,8 @@ # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded # by parsing the file and adding new entries to the in-memory app.tool_data_tables # dictionary. - error, message = tool_util.handle_sample_tool_data_table_conf_file( app, filename_in_archive ) + tdtm = data_table_manager.ToolDataTableManager( app ) + error, message = tdtm.handle_sample_tool_data_table_conf_file( filename_in_archive, persist=False ) if error: return False, message, files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed hg_util.commit_changeset( repo.ui, diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -11,9 +11,6 @@ from galaxy.tools.actions.upload import UploadToolAction from tool_shed.util import basic_util -from tool_shed.util import hg_util -from tool_shed.util import xml_util -import tool_shed.util.shed_util_common as suc log = logging.getLogger( __name__ ) @@ -156,45 +153,6 @@ return tool_path, relative_install_dir return None, None -def get_tool_index_sample_files( sample_files ): - """Try to return the list of all appropriate tool data sample files included in the repository.""" - tool_index_sample_files = [] - for s in sample_files: - # The problem with this is that Galaxy does not follow a standard naming convention for file names. - if s.endswith( '.loc.sample' ) or s.endswith( '.xml.sample' ) or s.endswith( '.txt.sample' ): - tool_index_sample_files.append( str( s ) ) - return tool_index_sample_files - -def handle_missing_data_table_entry( app, relative_install_dir, tool_path, repository_tools_tups ): - """ - Inspect each tool to see if any have input parameters that are dynamically - generated select lists that require entries in the tool_data_table_conf.xml - file. This method is called only from Galaxy (not the tool shed) when a - repository is being installed or reinstalled. - """ - missing_data_table_entry = False - for index, repository_tools_tup in enumerate( repository_tools_tups ): - tup_path, guid, repository_tool = repository_tools_tup - if repository_tool.params_with_missing_data_table_entry: - missing_data_table_entry = True - break - if missing_data_table_entry: - # The repository must contain a tool_data_table_conf.xml.sample file that includes - # all required entries for all tools in the repository. - sample_tool_data_table_conf = hg_util.get_config_from_disk( 'tool_data_table_conf.xml.sample', relative_install_dir ) - if sample_tool_data_table_conf: - # Add entries to the ToolDataTableManager's in-memory data_tables dictionary. - error, message = handle_sample_tool_data_table_conf_file( app, sample_tool_data_table_conf, persist=True ) - if error: - # TODO: Do more here than logging an exception. - log.debug( message ) - # Reload the tool into the local list of repository_tools_tups. - repository_tool = app.toolbox.load_tool( os.path.join( tool_path, tup_path ), guid=guid ) - repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) - # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. - reset_tool_data_tables( app ) - return repository_tools_tups - def handle_missing_index_file( app, tool_path, sample_files, repository_tools_tups, sample_files_copied ): """ Inspect each tool to see if it has any input parameters that are dynamically @@ -222,84 +180,6 @@ repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) return repository_tools_tups, sample_files_copied -def handle_sample_tool_data_table_conf_file( app, filename, persist=False ): - """ - Parse the incoming filename and add new entries to the in-memory - app.tool_data_tables dictionary. If persist is True (should only occur - if call is from the Galaxy side, not the tool shed), the new entries will - be appended to Galaxy's shed_tool_data_table_conf.xml file on disk. - """ - error = False - message = '' - try: - new_table_elems, message = \ - app.tool_data_tables.add_new_entries_from_config_file( config_filename=filename, - tool_data_path=app.config.tool_data_path, - shed_tool_data_table_config=app.config.shed_tool_data_table_config, - persist=persist ) - if message: - error = True - except Exception, e: - message = str( e ) - error = True - return error, message - -def install_tool_data_tables( app, tool_shed_repository, tool_index_sample_files ): - """Only ever called from Galaxy end when installing""" - TOOL_DATA_TABLE_FILE_NAME = 'tool_data_table_conf.xml' - TOOL_DATA_TABLE_FILE_SAMPLE_NAME = '%s.sample' % ( TOOL_DATA_TABLE_FILE_NAME ) - SAMPLE_SUFFIX = '.sample' - SAMPLE_SUFFIX_OFFSET = -len( SAMPLE_SUFFIX ) - tool_path, relative_target_dir = tool_shed_repository.get_tool_relative_path( app ) - target_dir = os.path.join( app.config.shed_tool_data_path, relative_target_dir ) #this is where index files will reside on a per repo/installed version - if not os.path.exists( target_dir ): - os.makedirs( target_dir ) - for sample_file in tool_index_sample_files: - path, filename = os.path.split ( sample_file ) - target_filename = filename - if target_filename.endswith( SAMPLE_SUFFIX ): - target_filename = target_filename[ : SAMPLE_SUFFIX_OFFSET ] - source_file = os.path.join( tool_path, sample_file ) - #we're not currently uninstalling index files, do not overwrite existing files - target_path_filename = os.path.join( target_dir, target_filename ) - if not os.path.exists( target_path_filename ) or target_filename == TOOL_DATA_TABLE_FILE_NAME: - shutil.copy2( source_file, target_path_filename ) - else: - log.debug( "Did not copy sample file '%s' to install directory '%s' because file already exists.", filename, target_dir ) - #for provenance and to simplify introspection, lets keep the original data table sample file around - if filename == TOOL_DATA_TABLE_FILE_SAMPLE_NAME: - shutil.copy2( source_file, os.path.join( target_dir, filename ) ) - tool_data_table_conf_filename = os.path.join( target_dir, TOOL_DATA_TABLE_FILE_NAME ) - elems = [] - if os.path.exists( tool_data_table_conf_filename ): - tree, error_message = xml_util.parse_xml( tool_data_table_conf_filename ) - if tree: - for elem in tree.getroot(): - #append individual table elems or other elemes, but not tables elems - if elem.tag == 'tables': - for table_elem in elems: - elems.append( elem ) - else: - elems.append( elem ) - else: - log.debug( "The '%s' data table file was not found, but was expected to be copied from '%s' during repository installation.", - tool_data_table_conf_filename, TOOL_DATA_TABLE_FILE_SAMPLE_NAME ) - for elem in elems: - if elem.tag == 'table': - for file_elem in elem.findall( 'file' ): - path = file_elem.get( 'path', None ) - if path: - file_elem.set( 'path', os.path.normpath( os.path.join( target_dir, os.path.split( path )[1] ) ) ) - #store repository info in the table tagset for traceability - repo_elem = suc.generate_repository_info_elem_from_repository( tool_shed_repository, parent_elem=elem ) - if elems: - # Remove old data_table - os.unlink( tool_data_table_conf_filename ) - # Persist new data_table content. - app.tool_data_tables.to_xml_file( tool_data_table_conf_filename, elems ) - return tool_data_table_conf_filename, elems - - def is_column_based( fname, sep='\t', skip=0, is_multi_byte=False ): """See if the file is column based with respect to a separator.""" headers = get_headers( fname, sep, is_multi_byte=is_multi_byte ) @@ -384,7 +264,3 @@ tool = app.toolbox.tools_by_id[ tool_id ] if isinstance( tool.tool_action, UploadToolAction ): app.toolbox.reload_tool_by_id( tool_id ) - -def reset_tool_data_tables( app ): - # Reset the tool_data_tables to an empty dictionary. - app.tool_data_tables.data_tables = {} diff -r b2cdaba8715e1e2c18dab5f365fac28b6c5365a4 -r 9cce4ead10795278446af4ab84eecfc4e2b26dce lib/tool_shed/util/workflow_util.py --- a/lib/tool_shed/util/workflow_util.py +++ b/lib/tool_shed/util/workflow_util.py @@ -16,7 +16,6 @@ from tool_shed.util import encoding_util from tool_shed.util import metadata_util from tool_shed.util import shed_util_common as suc -from tool_shed.util import tool_util eggs.require( "SVGFig" ) import svgfig 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.