Skip to content

Commit

Permalink
Use ValidationContext data tables instead of separately passing in re…
Browse files Browse the repository at this point in the history
…levant data tables
  • Loading branch information
mvdbeek committed Dec 3, 2017
1 parent 482c9cc commit db88175
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 4 additions & 7 deletions lib/tool_shed/tools/data_table_manager.py
Expand Up @@ -12,7 +12,6 @@
class ShedToolDataTableManager(object):

def __init__(self, app):
self.tdtm = tdtm(app.config.shed_tool_data_path)
self.app = app

def generate_repository_info_elem(self, tool_shed, repository_name, changeset_revision, owner,
Expand Down Expand Up @@ -90,7 +89,7 @@ def handle_missing_data_table_entry(self, relative_install_dir, tool_path, repos
self.reset_tool_data_tables()
return repository_tools_tups

def handle_sample_tool_data_table_conf_file(self, filename, persist=False, tool_data_tables=None):
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
Expand All @@ -99,10 +98,8 @@ def handle_sample_tool_data_table_conf_file(self, filename, persist=False, tool_
file on disk.
"""
error = False
message = ''
tdtm = tool_data_tables or self.tdtm
try:
new_table_elems, message = tdtm \
new_table_elems, message = self.app.tool_data_tables \
.add_new_entries_from_config_file(config_filename=filename,
tool_data_path=self.app.config.shed_tool_data_path,
shed_tool_data_table_config=self.app.config.shed_tool_data_table_config,
Expand Down Expand Up @@ -170,9 +167,9 @@ def install_tool_data_tables(self, tool_shed_repository, tool_index_sample_files
# Remove old data_table
os.unlink(tool_data_table_conf_filename)
# Persist new data_table content.
self.tdtm.to_xml_file(tool_data_table_conf_filename, elems)
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.tdtm.data_tables = {}
self.app.tool_data_tables.data_tables = {}
3 changes: 1 addition & 2 deletions lib/tool_shed/tools/tool_validator.py
Expand Up @@ -70,8 +70,7 @@ def check_tool_input_params(self, repo_dir, tool_config_name, tool, sample_files
if sample_tool_data_table_conf:
error, correction_msg = \
self.stdtm.handle_sample_tool_data_table_conf_file(sample_tool_data_table_conf,
persist=False,
tool_data_tables=tool.app.tool_data_tables)
persist=False)
if error:
invalid_files_and_errors_tups.append(('tool_data_table_conf.xml.sample', correction_msg))
else:
Expand Down

0 comments on commit db88175

Please sign in to comment.