Breakup big remove method in tool_panel_manager.py to ease testing.

Separate out logic for dealing with toolbox from logic for dealing repository metadata in the database.
This commit is contained in:
John Chilton
2014-12-24 00:42:54 -05:00
parent 0e0b3199e7
commit f315f8ee76
2 changed files with 7 additions and 4 deletions
@@ -249,9 +249,9 @@ class AdminToolshed( AdminGalaxy ):
if tool_shed_repository.includes_tools_for_display_in_tool_panel:
# Handle tool panel alterations.
tpm = tool_panel_manager.ToolPanelManager( trans.app )
tpm.remove_from_tool_panel( tool_shed_repository,
shed_tool_conf,
uninstall=remove_from_disk_checked )
tpm.remove_repository_contents( tool_shed_repository,
shed_tool_conf,
uninstall=remove_from_disk_checked )
if tool_shed_repository.includes_data_managers:
dmh = data_manager.DataManagerHandler( trans.app )
dmh.remove_from_data_manager( tool_shed_repository )
@@ -427,7 +427,7 @@ class ToolPanelManager( object ):
# Persist the altered in-memory version of the tool config.
self.config_elems_to_xml_file( config_elems, shed_tool_conf, tool_path )
def remove_from_tool_panel( self, repository, shed_tool_conf, uninstall ):
def remove_repository_contents( self, repository, shed_tool_conf, uninstall ):
"""
A tool shed repository is being deactivated or uninstalled, so handle
tool panel alterations accordingly.
@@ -442,6 +442,9 @@ class ToolPanelManager( object ):
# Create a list of guids for all tools that will be removed from the in-memory tool panel
# and config file on disk.
guids_to_remove = [ k for k in tool_panel_dict.keys() ]
self.remove_guids( guids_to_remove, shed_tool_conf, uninstall )
def remove_guids( self, guids_to_remove, shed_tool_conf, uninstall ):
# Remove the tools from the toolbox's tools_by_id dictionary.
for guid_to_remove in guids_to_remove:
if guid_to_remove in self.app.toolbox.tools_by_id: