Skip to content

Commit cb5739a

Browse files
fix mako_identifier bug if None in parents
if there is a when (which has a None identifier) on the path to the root then the export failed. also fix linter errors
1 parent a204e06 commit cb5739a

File tree

4 files changed

+60
-52
lines changed

4 files changed

+60
-52
lines changed

examples/example_macros.xml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,38 @@
22
<!--This tool descriptor has been generated using galaxyxml.-->
33
<token name="ARAGORN_INMACRO"><![CDATA[$flag
44
-float $float_section.float
5-
cond $cond
5+
#if str($cond.Select) == "bye"
6+
-some_int $cond.some_int
7+
#end if
68
-i$int_min,$int_max
79
810
$posint
911
select_local $select_local]]></token>
1012
<token name="ARAGORN_OUTMACRO"><![CDATA[-output '$output'
1113
## TODO CLI for OutputCollection collection]]></token>
1214
<xml name="aragorn_inmacro">
13-
<param label="Flag label" help="Flag help" checked="false" type="boolean" name="flag" argument="-flag" truevalue="-flag" falsevalue=""/>
14-
<section title="Float section" name="float_section">
15-
<param label="Float label" help="Float help" value="0" type="float" name="float" argument="-float"/>
15+
<param name="flag" type="boolean" label="Flag label" help="Flag help" checked="false" truevalue="-flag" falsevalue=""/>
16+
<section name="float_section" title="Float section">
17+
<param name="float" type="float" value="0" label="Float label" help="Float help"/>
1618
</section>
17-
<conditional label="Conditional" name="cond" argument="cond">
18-
<param label="Author did not provide help for this parameter... " type="select" name="Select" argument="Select">
19+
<conditional name="cond" label="Conditional">
20+
<param name="Select" type="select" label="Author did not provide help for this parameter... ">
1921
<option value="bye">2</option>
2022
<option value="hi">1</option>
2123
</param>
2224
<when value="hi"/>
2325
<when value="bye">
24-
<param label="Advanced value" value="0" type="integer" name="some_int" argument="-some_int"/>
26+
<param name="some_int" type="integer" value="0" label="Advanced value"/>
2527
</when>
2628
</conditional>
27-
<param label="int_min label" help="int_min help" value="0" type="integer" name="int_min" argument="-int_min"/>
28-
<param label="int_max label" help="int_max help" value="0" type="integer" name="int_max" argument="-int_max"/>
29-
<param label="posint label" help="posinthelp" value="0" type="integer" name="posint"/>
30-
<param label="Author did not provide help for this parameter... " type="select" name="select_local" argument="select_local">
29+
<param name="int_min" type="integer" value="0" label="int_min label" help="int_min help"/>
30+
<param name="int_max" type="integer" value="0" label="int_max label" help="int_max help"/>
31+
<param name="posint" type="integer" value="0" label="posint label" help="posinthelp"/>
32+
<param name="select_local" type="select" label="Author did not provide help for this parameter... ">
3133
<options from_file="loc_file.loc">
32-
<column index="0" name="name"/>
33-
<column index="1" name="value"/>
34-
<filter type="sort_by" column="1" name="sorted"/>
34+
<column name="name" index="0"/>
35+
<column name="value" index="1"/>
36+
<filter name="sorted" type="sort_by" column="1"/>
3537
</options>
3638
</param>
3739
</xml>

examples/tool.xml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,20 @@
1111
<expand macro="stdio"/>
1212
<version_command><![CDATA[aragorn.exe --version]]></version_command>
1313
<command><![CDATA[aragorn.exe $flag
14-
-float $float
15-
--float-fromarg $float_fromarg
16-
#if str($Select) == "bye"
17-
-some_int $some_int
14+
-float $float_section.float
15+
--float-fromarg $float_section.float_fromarg
16+
#if str($cond.Select) == "bye"
17+
-some_int $cond.some_int
1818
#end if
1919
-i$int_min,$int_max
2020
2121
$posint
2222
select_local $select_local
2323
#for $i in $repeat:
24-
--data $data
24+
--data $repeat.data
2525
#end for
2626
-output '$output'
27-
## TODO CLI for OutputCollection collection
28-
]]></command>
27+
## TODO CLI for OutputCollection collection]]></command>
2928
<configfiles>
3029
<configfile name="testing"><![CDATA[Hello <> World]]></configfile>
3130
<inputs name="inputs"/>

galaxyxml/tool/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def export(self, keep_old_command=False):
153153
command_line.append(export_xml.inputs.cli())
154154
except Exception as e:
155155
logger.warning(str(e))
156+
raise
156157
try:
157158
command_line.append(export_xml.outputs.cli())
158159
except Exception:

galaxyxml/tool/parameters/__init__.py

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
str,
33
object
44
)
5+
import logging
56

67
from galaxyxml import Util
78

89
from galaxy.tool_util.parser.util import _parse_name
910
from lxml import etree
1011

12+
logging.basicConfig(level=logging.INFO)
13+
logger = logging.getLogger(__name__)
14+
1115
class XMLParam(object):
1216
name = "node"
1317

@@ -160,7 +164,7 @@ def __init__(self, **kwargs):
160164

161165
def acceptable_child(self, child):
162166
return isinstance(child, RequestParamTranslation) \
163-
or isinstance(child, Expand)
167+
or isinstance(child, Expand)
164168

165169

166170
class RequestParam(XMLParam):
@@ -175,7 +179,7 @@ def __init__(self, galaxy_name, remote_name, missing, **kwargs):
175179

176180
def acceptable_child(self, child):
177181
return isinstance(child, AppendParam) and self.galaxy_name == "URL" \
178-
or isinstance(child, Expand)
182+
or isinstance(child, Expand)
179183

180184

181185
class AppendParam(XMLParam):
@@ -205,7 +209,7 @@ class EdamOperations(XMLParam):
205209

206210
def acceptable_child(self, child):
207211
return issubclass(type(child), EdamOperation) \
208-
or isinstance(child, Expand)
212+
or isinstance(child, Expand)
209213

210214
def has_operation(self, edam_operation):
211215
"""
@@ -232,7 +236,7 @@ class EdamTopics(XMLParam):
232236

233237
def acceptable_child(self, child):
234238
return issubclass(type(child), EdamTopic) \
235-
or isinstance(child, Expand)
239+
or isinstance(child, Expand)
236240

237241
def has_topic(self, edam_topic):
238242
"""
@@ -260,8 +264,8 @@ class Requirements(XMLParam):
260264

261265
def acceptable_child(self, child):
262266
return issubclass(type(child), Requirement) \
263-
or issubclass(type(child), Container) \
264-
or isinstance(child, Expand)
267+
or issubclass(type(child), Container) \
268+
or isinstance(child, Expand)
265269

266270

267271
class Requirement(XMLParam):
@@ -292,8 +296,8 @@ class Configfiles(XMLParam):
292296

293297
def acceptable_child(self, child):
294298
return issubclass(type(child), Configfile) \
295-
or issubclass(type(child), ConfigfileDefaultInputs) \
296-
or isinstance(child, Expand)
299+
or issubclass(type(child), ConfigfileDefaultInputs) \
300+
or isinstance(child, Expand)
297301

298302

299303
class Configfile(XMLParam):
@@ -327,8 +331,8 @@ def __init__(self, action=None, check_value=None, method=None, target=None, ngin
327331

328332
def acceptable_child(self, child):
329333
return issubclass(type(child), InputParameter) \
330-
or issubclass(type(child), Expand) \
331-
or issubclass(type(child), ExpandIO)
334+
or issubclass(type(child), Expand) \
335+
or issubclass(type(child), ExpandIO)
332336

333337

334338
class InputParameter(XMLParam):
@@ -406,7 +410,9 @@ def mako_name(self):
406410
parent_identifiers = []
407411
p = self.parent
408412
while p is not None and hasattr(p, "mako_identifier"):
409-
parent_identifiers.append(p.mako_identifier)
413+
# exclude None identifiers -- e.g. <when> tags
414+
if p.mako_identifier is not None:
415+
parent_identifiers.append(p.mako_identifier)
410416
p = p.parent
411417
if len(parent_identifiers) > 0:
412418
parent_identifiers.append("")
@@ -432,7 +438,7 @@ def command_line(self):
432438

433439
def acceptable_child(self, child):
434440
return issubclass(type(child), InputParameter) \
435-
or isinstance(child, Expand)
441+
or isinstance(child, Expand)
436442

437443

438444
class Repeat(InputParameter):
@@ -448,7 +454,7 @@ def __init__(self, name, title, min=None, max=None, default=None, **kwargs):
448454

449455
def acceptable_child(self, child):
450456
return issubclass(type(child), InputParameter) \
451-
or isinstance(child, Expand)
457+
or isinstance(child, Expand)
452458

453459
def command_line_actual(self):
454460
lines = []
@@ -499,7 +505,7 @@ def __init__(self, value):
499505

500506
def acceptable_child(self, child):
501507
return issubclass(type(child), InputParameter) \
502-
or isinstance(child, Expand)
508+
or isinstance(child, Expand)
503509

504510

505511
class Param(InputParameter):
@@ -520,8 +526,8 @@ def __init__(self, name, argument=None, value=None, optional=None, label=None, h
520526

521527
def acceptable_child(self, child):
522528
return issubclass(type(child), InputParameter) \
523-
or isinstance(child, ValidatorParam) \
524-
or isinstance(child, Expand)
529+
or isinstance(child, ValidatorParam) \
530+
or isinstance(child, Expand)
525531

526532

527533
class TextParam(Param):
@@ -627,8 +633,8 @@ def __init__(
627633

628634
def acceptable_child(self, child):
629635
return issubclass(type(child), SelectOption) \
630-
or issubclass(type(child), Options) \
631-
or isinstance(child, Expand)
636+
or issubclass(type(child), Options) \
637+
or isinstance(child, Expand)
632638

633639

634640
class SelectOption(InputParameter):
@@ -655,8 +661,8 @@ def __init__(self, from_dataset=None, from_file=None, from_data_table=None, from
655661

656662
def acceptable_child(self, child):
657663
return issubclass(type(child), Column) \
658-
or issubclass(type(child), Filter) \
659-
or isinstance(child, Expand)
664+
or issubclass(type(child), Filter) \
665+
or isinstance(child, Expand)
660666

661667

662668
class Column(InputParameter):
@@ -713,9 +719,9 @@ class Outputs(XMLParam):
713719

714720
def acceptable_child(self, child):
715721
return isinstance(child, OutputData) \
716-
or isinstance(child, OutputCollection) \
717-
or isinstance(child, Expand) \
718-
or isinstance(child, ExpandIO)
722+
or isinstance(child, OutputCollection) \
723+
or isinstance(child, Expand) \
724+
or isinstance(child, ExpandIO)
719725

720726

721727
class OutputData(XMLParam):
@@ -763,9 +769,9 @@ def flag(self):
763769

764770
def acceptable_child(self, child):
765771
return isinstance(child, OutputFilter) \
766-
or isinstance(child, ChangeFormat) \
767-
or isinstance(child, DiscoverDatasets) \
768-
or isinstance(child, Expand)
772+
or isinstance(child, ChangeFormat) \
773+
or isinstance(child, DiscoverDatasets) \
774+
or isinstance(child, Expand)
769775

770776

771777
class OutputFilter(XMLParam):
@@ -790,7 +796,7 @@ def __init__(self, **kwargs):
790796

791797
def acceptable_child(self, child):
792798
return isinstance(child, ChangeFormatWhen) \
793-
or isinstance(child, Expand)
799+
or isinstance(child, Expand)
794800

795801

796802
class ChangeFormatWhen(XMLParam):
@@ -840,16 +846,16 @@ class Tests(XMLParam):
840846

841847
def acceptable_child(self, child):
842848
return issubclass(type(child), Test) \
843-
or isinstance(child, Expand)
849+
or isinstance(child, Expand)
844850

845851

846852
class Test(XMLParam):
847853
name = "test"
848854

849855
def acceptable_child(self, child):
850856
return isinstance(child, TestParam) \
851-
or isinstance(child, TestOutput) \
852-
or isinstance(child, Expand)
857+
or isinstance(child, TestOutput) \
858+
or isinstance(child, Expand)
853859

854860

855861
class TestParam(XMLParam):
@@ -886,7 +892,7 @@ class Citations(XMLParam):
886892

887893
def acceptable_child(self, child):
888894
return issubclass(type(child), Citation) \
889-
or isinstance(child, Expand)
895+
or isinstance(child, Expand)
890896

891897
def has_citation(self, type, value):
892898
"""

0 commit comments

Comments
 (0)