@@ -26,32 +26,41 @@ def lint_inputs(tool_xml, lint_ctx):
2626 lint_ctx .warn ("Param input [%s] with no format specified - 'data' format will be assumed." , param_name )
2727 # TODO: Validate type, much more...
2828
29+ def find_list (elem , expression ):
30+ matching = elem .findall (expression )
31+ if matching is None :
32+ return []
33+ else :
34+ return matching
35+
2936 conditional_selects = tool_xml .findall ("./inputs//conditional" )
3037 for conditional in conditional_selects :
31- select = conditional . find ( '. /param[@type="select"]' ) or []
32- boolean = conditional . find ( '. /param[@type="boolean"]' ) or []
38+ booleans = find_list ( conditional , ". /param[@type='boolean']" )
39+ selects = find_list ( conditional , ". /param[@type='select']" )
3340 # Should conditionals ever not have a select?
34- if not len (select ) and not len (boolean ):
41+ if not len (selects ) and not len (booleans ):
3542 lint_ctx .warn ("Conditional without <param type=\" select\" /> or <param type=\" boolean\" />" )
3643 continue
3744
38- if len ( select ) :
45+ for select in selects :
3946 select_options = select .findall ('./option[@value]' )
4047 if any (['value' not in option .attrib for option in select_options ]):
4148 lint_ctx .error ("Option without value" )
4249
4350 select_option_ids = [option .attrib .get ('value' , None ) for option in select_options ]
44- else :
51+
52+ for boolean in booleans :
4553 select_option_ids = [
46- boolean .attrib .get ('truevalue' , 'True ' ),
47- boolean .attrib .get ('falsevalue' , 'False ' )
54+ boolean .attrib .get ('truevalue' , 'true ' ),
55+ boolean .attrib .get ('falsevalue' , 'false ' )
4856 ]
4957
5058 whens = conditional .findall ('./when' )
5159 if any (['value' not in when .attrib for when in whens ]):
5260 lint_ctx .error ("When without value" )
5361
54- when_ids = [when .attrib .get ('value' , None ) for when in whens ]
62+ when_ids = [w .attrib .get ('value' , None ) for w in whens ]
63+ when_ids = [i .lower () if i in ["True" , "False" ] else i for i in when_ids ]
5564
5665 for select_id in select_option_ids :
5766 if select_id not in when_ids :
0 commit comments