@@ -217,8 +217,7 @@ def parse_macros_files(macros_file_names, tool_version, supported_file_types, re
217217 for xml_element in root .findall ("xml" ):
218218 name = xml_element .attrib ["name" ]
219219 if name in macros_to_expand :
220- logging .warning ("Macro %s has already been found. Duplicate found in file %s." %
221- (name , macros_file_name ))
220+ logging .warning ("Macro %s has already been found. Duplicate found in file %s." % (name , macros_file_name ))
222221 continue
223222 logging .info ("Macro %s found" % name )
224223 macros_to_expand .append (name )
@@ -482,7 +481,6 @@ def _convert_internal(parsed_ctds, **kwargs):
482481 create_configfiles (tool , model , ** kwargs )
483482 inputs = create_inputs (tool , model , ** kwargs )
484483 outputs = create_outputs (tool , model , ** kwargs )
485- tests_node = add_child_node (tool , "tests" )
486484 if kwargs ["test_test" ]:
487485 create_tests (tool , inputs = copy .deepcopy (inputs ), outputs = copy .deepcopy (outputs ))
488486
@@ -656,14 +654,14 @@ def create_command(tool, model, **kwargs):
656654 param_cmd ['preprocessing' ].append (f'#if ${ _actual_parameter } _select == "no"' )
657655 param_cmd ['preprocessing' ].append (f"mkdir ${{' '.join([\" '{ actual_parameter } /%s'\" % (i) for i, f in enumerate(${ _actual_parameter } ) if f])}} && " )
658656 param_cmd ['preprocessing' ].append (f"${{' '.join([\" ln -s '%s' '{ actual_parameter } /%s/%s.%s' && \" % (f, i, re.sub('[^\\ w\\ -_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate(${ _actual_parameter } ) if f])}}" )
659- param_cmd ['preprocessing' ].append (f '#else' )
657+ param_cmd ['preprocessing' ].append ('#else' )
660658 param_cmd ['preprocessing' ].append (f"ln -s '${ _actual_parameter } ' '{ actual_parameter } /${{re.sub(\" [^\\ w\\ -_]\" , \" _\" , ${ _actual_parameter } .element_identifier)}}.$gxy2omsext(${ _actual_parameter } .ext)' &&" )
661- param_cmd ['preprocessing' ].append (f '#end if' )
659+ param_cmd ['preprocessing' ].append ('#end if' )
662660 param_cmd ['command' ].append (f'#if ${ actual_parameter } _select == "no"' )
663661 param_cmd ['command' ].append (f"${{' '.join([\" '{ actual_parameter } /%s/%s.%s'\" %(i, re.sub('[^\\ w\\ -_]', '_', f.element_identifier), $gxy2omsext(f.ext)) for i, f in enumerate(${ _actual_parameter } ) if f])}}" )
664- param_cmd ['command' ].append (f '#else' )
662+ param_cmd ['command' ].append ('#else' )
665663 param_cmd ['command' ].append (f"'{ actual_parameter } /${{re.sub(\" [^\\ w\\ -_]\" , \" _\" , ${ _actual_parameter } .element_identifier)}}.$gxy2omsext(${ _actual_parameter } .ext)'" )
666- param_cmd ['command' ].append (f '#end if' )
664+ param_cmd ['command' ].append ('#end if' )
667665 else :
668666 param_cmd ['preprocessing' ].append ("ln -s '$" + _actual_parameter + "' '" + actual_parameter + "/${re.sub(\" [^\\ w\\ -_]\" , \" _\" , $" + _actual_parameter + ".element_identifier)}.$gxy2omsext($" + _actual_parameter + ".ext)' &&" )
669667 param_cmd ['command' ].append ("'" + actual_parameter + "/${re.sub(\" [^\\ w\\ -_]\" , \" _\" , $" + _actual_parameter + ".element_identifier)}.$gxy2omsext($" + _actual_parameter + ".ext)'" )
@@ -796,7 +794,7 @@ def create_command(tool, model, **kwargs):
796794 for stage in advanced_cmd :
797795 if len (advanced_cmd [stage ]) == 0 :
798796 continue
799- advanced_cmd [stage ] = [] + utils .indent (advanced_cmd [stage ]) + []
797+ advanced_cmd [stage ] = [advanced_command_start ] + utils .indent (advanced_cmd [stage ]) + [advanced_command_end ]
800798 final_cmd [stage ].extend (advanced_cmd [stage ])
801799
802800 out , optout = all_outputs (model , parameter_hardcoder )
@@ -814,7 +812,6 @@ def create_command(tool, model, **kwargs):
814812 command_node .text = CDATA ("\n " .join (sum (final_cmd .values (), [])))
815813
816814
817-
818815def import_macros (tool , model , ** kwargs ):
819816 """
820817 creates the xml elements needed to import the needed macros files
@@ -835,15 +832,15 @@ def import_macros(tool, model, **kwargs):
835832 import_node .text = os .path .basename (macro_file .name )
836833
837834
838- def add_macros (tool , model , test_macros_prefix = None , test_macros_file_names = None ):
835+ def add_macros (tool , model , test_macros_prefix = None , test_macros_file_names = None ):
839836 """
840837 paste all test macros for a tool into the tests node of the tool
841838 """
842- if test_macros_file_names == None :
839+ if test_macros_file_names is None :
843840 return
844841 tool_id = model .name .replace (" " , "_" )
845842 tests_node = tool .find (".//tests" )
846-
843+
847844 for macros_file , macros_prefix in zip (test_macros_file_names , test_macros_prefix ):
848845 macros_root = parse (macros_file )
849846 tool_tests = macros_root .find (f".//xml[@name='{ macros_prefix } { tool_id } ']" )
@@ -887,7 +884,7 @@ def get_galaxy_parameter_path(param, separator=".", suffix=None, fix_underscore=
887884 # data input params with multiple="true" are in a (batch mode) conditional
888885 # which needs to be added to the param path list
889886 if param .type is _InFile and param .is_list :
890- path .insert (len (path )- 1 , f"{ p } _cond" )
887+ path .insert (len (path ) - 1 , f"{ p } _cond" )
891888 return separator .join (path ).replace ("-" , "_" )
892889
893890
@@ -1133,7 +1130,7 @@ def get_formats(param, model, o2g):
11331130 elif is_out_type_param (param , model ):
11341131 choices = param .restrictions .choices
11351132 else :
1136- raise InvalidModelException (f"Unrecognized restriction type [{ type (param .restrictions )} ] for [{ name } ]" )
1133+ raise InvalidModelException (f"Unrecognized restriction type [{ type (param .restrictions )} ] for [{ param . name } ]" )
11371134
11381135 # check if there are formats that have not been registered yet...
11391136 formats = set ()
@@ -1400,19 +1397,19 @@ def create_param_attribute_list(param, model, supported_file_formats, parameter_
14001397
14011398 if param_node .attrib ["type" ] == "data" and param_node .attrib .get ("multiple" ) == "true" :
14021399 conditional_attrib = OrderedDict ([
1403- ("name" , get_galaxy_parameter_name (param )+ "_cond" )
1400+ ("name" , get_galaxy_parameter_name (param ) + "_cond" )
14041401 ])
14051402 conditional = Element ("conditional" , conditional_attrib )
14061403
14071404 select_attrib = OrderedDict ([
1408- ("name" , get_galaxy_parameter_name (param )+ "_select" ),
1405+ ("name" , get_galaxy_parameter_name (param ) + "_select" ),
14091406 ("type" , "select" ),
14101407 ("label" , f"Run tool in batch mode for -{ get_galaxy_parameter_name (param )} " )
14111408 ])
14121409 select = add_child_node (conditional , "param" , select_attrib )
14131410 add_child_node (select , "option" , attributes = {"value" : "no" }, text = "No: process all datasets jointly" )
14141411 add_child_node (select , "option" , attributes = {"value" : "yes" }, text = "Yes: process each dataset in an independent job" )
1415-
1412+
14161413 when_no = add_child_node (conditional , "when" , attributes = {"value" : "no" })
14171414 when_no .append (copy .deepcopy (param_node ))
14181415 when_yes = add_child_node (conditional , "when" , attributes = {"value" : "yes" })
@@ -1422,6 +1419,7 @@ def create_param_attribute_list(param, model, supported_file_formats, parameter_
14221419
14231420 return param_node
14241421
1422+
14251423def generate_label_and_help (desc ):
14261424 help_text = ""
14271425 # This tag is found in some descriptions
@@ -1737,16 +1735,7 @@ def create_tests(parent, inputs=None, outputs=None):
17371735 @param inputs a copy of the inputs
17381736 """
17391737
1740- if not (inputs is None or outputs is None ):
1741- fidx = 0
1742- test_node = add_child_node (tests_node , "test" )
1743- strip_elements (inputs , "validator" , "sanitizer" )
1744- for node in inputs .iter ():
1745- if node .tag == "expand" and node .attrib ["macro" ] == ADVANCED_OPTIONS_NAME + "_macro" :
1746- node .tag = "section"
1747- node .attrib ["name" ] = ADVANCED_OPTIONS_NAME
1748- if "type" not in node .attrib :
1749- continue
1738+ tests_node = add_child_node (parent , "tests" )
17501739
17511740 fidx = 0
17521741 test_node = add_child_node (tests_node , "test" )
@@ -1983,7 +1972,7 @@ def create_test_only(model, **kwargs):
19831972 # for input-files with multiple=true we need to add the batch mode conditional
19841973 if param .type is _InFile and param .is_list :
19851974 batch_cond_attrib = OrderedDict ([
1986- ("name" , get_galaxy_parameter_name (param )+ "_cond" )
1975+ ("name" , get_galaxy_parameter_name (param ) + "_cond" )
19871976 ])
19881977 parent = add_child_node (parent , "conditional" , batch_cond_attrib )
19891978
0 commit comments