From c09f6759ab5dae8e012ae122e376899d08a6a68e Mon Sep 17 00:00:00 2001 From: Greg Von Kuster Date: Mon, 26 Jan 2009 14:41:00 -0500 Subject: [PATCH] Add a make_dict_copy method to Tool.execute so that when wrapping the tool's inputs to display output labels and such, we are not overwriting the incoming param dictionary. Also, yet another fix for tranlsating EOL to
so they can be displayed in the data.info in the histoy. --- lib/galaxy/datatypes/data.py | 15 ++++++++------- lib/galaxy/tools/actions/__init__.py | 20 +++++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/galaxy/datatypes/data.py b/lib/galaxy/datatypes/data.py index 3858efd7692..5cee678b67c 100644 --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -137,13 +137,14 @@ class Data( object ): """Returns formatted html of dataset info""" try: # Change new line chars to html - if dataset.info.find( '\r\n' ) >= 0: - dataset.info = dataset.info.replace( '\r\n', '
' ) - if dataset.info.find( '\r' ) >= 0: - dataset.info = dataset.info.replace( '\r', '
' ) - if dataset.info.find( '\n' ) >= 0: - dataset.info = dataset.info.replace( '\n', '
' ) - return escape( dataset.info ) + info = escape( dataset.info ) + if info.find( '\r\n' ) >= 0: + info = info.replace( '\r\n', '
' ) + if info.find( '\r' ) >= 0: + info = info.replace( '\r', '
' ) + if info.find( '\n' ) >= 0: + info = info.replace( '\n', '
' ) + return info except: return "info unavailable" def validate(self, dataset): diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 3e0093d1b60..b9230b2fbac 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -6,6 +6,7 @@ from galaxy.util.none_like import NoneDataset from galaxy.web import url_for from galaxy.jobs import JOB_OK import galaxy.tools +from types import * import logging log = logging.getLogger( __name__ ) @@ -65,8 +66,21 @@ class DefaultToolAction( object ): param_values[input.name] = input_datasets[ prefix + input.name ] tool.visit_inputs( param_values, visitor ) return input_datasets - + def execute(self, tool, trans, incoming={}, set_output_hid=True ): + def make_dict_copy( from_dict ): + """ + Makes a copy of input dictionary from_dict such that all values that are dictionaries + result in creation of a new dictionary ( a sort of deepcopy ). We may need to handle + other complex types ( e.g., lists, etc ), but not sure... + """ + copy_from_dict = {} + for key, value in from_dict.items(): + if type( value ).__name__ == 'dict': + copy_from_dict[ key ] = make_dict_copy( value ) + else: + copy_from_dict[ key ] = value + return copy_from_dict def wrap_values( inputs, input_values ): # Wrap tool inputs as necessary for input in inputs.itervalues(): @@ -75,7 +89,7 @@ class DefaultToolAction( object ): wrap_values( input.inputs, d ) elif isinstance( input, Conditional ): values = input_values[ input.name ] - current = values["__current_case__"] + current = values[ "__current_case__" ] wrap_values( input.cases[current].inputs, values ) elif isinstance( input, DataToolParameter ): input_values[ input.name ] = \ @@ -172,7 +186,7 @@ class DefaultToolAction( object ): data.blurb = "queued" # Set output label if output.label: - params = dict( incoming ) + params = make_dict_copy( incoming ) # wrapping the params allows the tool config to contain things like # #