From 9c1550b36e9b5cffb581568428802b47dcff65c5 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Thu, 16 Apr 2015 09:31:10 -0400 Subject: [PATCH] Improved Cheetah type casting for int/float types. Based on idea by @peterjc in a discussion here - http://dev.list.galaxyproject.org/Geting-integer-value-from-InputValueWrapper-in-plugin-xml-file-td4666971.html. With simple test demonstrating new functionality. Run test with ./run_tests.sh -framework -id cheetah_casting --- lib/galaxy/tools/wrappers.py | 6 +++++ test/functional/tools/cheetah_casting.xml | 27 +++++++++++++++++++++ test/functional/tools/samples_tool_conf.xml | 2 ++ 3 files changed, 35 insertions(+) create mode 100644 test/functional/tools/cheetah_casting.xml diff --git a/lib/galaxy/tools/wrappers.py b/lib/galaxy/tools/wrappers.py index 1a483b66e74..9282f446935 100644 --- a/lib/galaxy/tools/wrappers.py +++ b/lib/galaxy/tools/wrappers.py @@ -98,6 +98,12 @@ class InputValueWrapper( ToolParameterValueWrapper ): def __getattr__( self, key ): return getattr( self.value, key ) + def __int__(self): + return int(str(self)) + + def __float__(self): + return float(str(self)) + class SelectToolParameterWrapper( ToolParameterValueWrapper ): """ diff --git a/test/functional/tools/cheetah_casting.xml b/test/functional/tools/cheetah_casting.xml new file mode 100644 index 00000000000..d12bb6569e8 --- /dev/null +++ b/test/functional/tools/cheetah_casting.xml @@ -0,0 +1,27 @@ + + + #set $int_val_inc = int($inttest) + 1 + #set $float_val_inc = float($floattest) + 1 + echo $int_val_inc >> $out_file1; + echo $float_val_inc >> $out_file1; + + + + + + + + + + + + + + + + + + + + + diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index 40780b3d9aa..f257f8790fa 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -51,6 +51,8 @@ + +