Skip to content

Commit

Permalink
Always display text, with test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Oct 14, 2016
1 parent 4446ccc commit 868658c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions lib/galaxy/tools/parameters/basic.py
Expand Up @@ -146,13 +146,29 @@ def value_from_basic( self, value, app, ignore_errors=False ):
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( '<param name="_name" />' ) )
>>> 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={} ):
Expand Down

0 comments on commit 868658c

Please sign in to comment.