From 868658c7e72e3d0f37e36c51316a72a56a270376 Mon Sep 17 00:00:00 2001 From: guerler Date: Thu, 13 Oct 2016 21:19:09 -0400 Subject: [PATCH] Always display text, with test cases --- lib/galaxy/tools/parameters/basic.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index ddb50cecc16..fbb16e2d283 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -146,13 +146,29 @@ class ToolParameter( object, Dictifiable ): else: return self.to_python( value, app ) - def value_to_display_text( self, value, app ): + def value_to_display_text( self, value, app=None ): """ Convert a value to a text representation suitable for displaying to the user + >>> p = ToolParameter( None, XML( '' ) ) + >>> print p.value_to_display_text( None ) + Not available. + >>> print p.value_to_display_text( '' ) + Empty. + >>> print p.value_to_display_text( 'text' ) + text + >>> print p.value_to_display_text( True ) + True + >>> print p.value_to_display_text( False ) + False + >>> print p.value_to_display_text( 0 ) + 0 """ if value is not None: - return unicodify( value ) + str_value = unicodify( value ) + if not str_value: + return "Empty." + return str_value return "Not available." def to_param_dict_string( self, value, other_values={} ):