Skip to content

Commit

Permalink
Merge pull request #6317 from mvdbeek/fix_6314
Browse files Browse the repository at this point in the history
Allow #if $datasets #end if pattern for file lists
  • Loading branch information
hexylena committed Jun 12, 2018
2 parents c08f7c9 + 550eb88 commit 9b9ab6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/galaxy/tools/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ def to_dataset_instances(dataset_instance_sources):
def __str__(self):
return ','.join(map(str, self))

def __bool__(self):
# Fail `#if $param` checks in cheetah if optional input is not provided
return any(self)
__nonzero__ = __bool__


class DatasetCollectionWrapper(ToolParameterValueWrapper, HasDatasets):

Expand Down
19 changes: 15 additions & 4 deletions test/functional/tools/multi_data_optional.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<tool id="multi_data_optional" name="multi_data_optional" version="0.1.0">
<command>
touch $out1;
touch '$out1';
#if $input1
#for $input in $input1
#if $input
cat $input >> $out1;
#end if
#if $input
cat '$input' >> '$out1';
#end if
#end for
#else
echo "No input selected" >> '$out1'
#end if
</command>
<inputs>
<param name="input1" type="data" format="txt" multiple="true" label="Data 1" optional="true" />
Expand All @@ -23,5 +27,12 @@
</assert_contents>
</output>
</test>
<test>
<output name="out1">
<assert_contents>
<has_line line="No input selected" />
</assert_contents>
</output>
</test>
</tests>
</tool>

0 comments on commit 9b9ab6a

Please sign in to comment.