13
13
logging .basicConfig (level = logging .INFO )
14
14
logger = logging .getLogger (__name__ )
15
15
16
+
16
17
class XMLParam (object ):
17
18
name = "node"
18
19
@@ -69,7 +70,7 @@ def cli(self):
69
70
lines .append (child .command_line ())
70
71
return "\n " .join (lines )
71
72
72
- def command_line (self , mako_path = None ):
73
+ def command_line (self , mako_path = None ):
73
74
"""
74
75
genetate the command line for the node (and its childres)
75
76
@@ -355,7 +356,7 @@ def __init__(self, name, **kwargs):
355
356
# We use kwargs instead of the usual locals(), so manually copy the
356
357
# name to kwargs
357
358
if name is not None :
358
- kwargs = dict ([("name" , name )] + list (kwargs .items ()) )
359
+ kwargs = dict ([("name" , name )] + list (kwargs .items ()))
359
360
360
361
# Handle positional parameters
361
362
if "positional" in kwargs and kwargs ["positional" ]:
@@ -420,7 +421,7 @@ def mako_name(self, mako_path=None):
420
421
if len (parent_identifiers ) > 0 :
421
422
parent_identifiers .append ("" )
422
423
path = "." .join (parent_identifiers )
423
- return "$" + path + self .mako_identifier
424
+ return "$" + path + self .mako_identifier
424
425
425
426
def flag (self ):
426
427
flag = "-" * self .num_dashes
@@ -492,7 +493,7 @@ def command_line(self, mako_path=None):
492
493
for c in self .children [1 :]:
493
494
if len (c .children ) == 0 :
494
495
continue
495
- lines .append ('#if str(%s) == "%s"' % (self .children [0 ].mako_name (mako_path ), c .value ))
496
+ lines .append ('#if str(%s) == "%s"' % (self .children [0 ].mako_name (mako_path ), c .value ))
496
497
lines .append (c .cli ())
497
498
lines .append ('#end if' )
498
499
return "\n " .join (lines )
@@ -835,8 +836,18 @@ def __init__(
835
836
def acceptable_child (self , child ):
836
837
return isinstance (child , OutputData ) or isinstance (child , OutputFilter ) or isinstance (child , DiscoverDatasets )
837
838
838
- def command_line (self , mako_path ):
839
- return "## TODO CLI for OutputCollection %s" % self .name
839
+ def command_line_before (self , mako_path ):
840
+ return "<output_collection name = '%s'>" % self .name
841
+
842
+ def command_line_after (self ):
843
+ return "</output_collection>"
844
+
845
+ def command_line_actual (self , mako_path ):
846
+ lines = []
847
+ for child in self .children :
848
+ lines .append (child .command_line ())
849
+ return "\n " .join (lines )
850
+
840
851
841
852
class DiscoverDatasets (XMLParam ):
842
853
name = "discover_datasets"
@@ -894,6 +905,14 @@ def __init__(
894
905
super (TestOutput , self ).__init__ (** params )
895
906
896
907
908
+ class TestOCElement (XMLParam ):
909
+ name = "element"
910
+
911
+ def __init__ (self , name = None , file = None , ftype = None , ** kwargs ):
912
+ params = Util .clean_kwargs (locals ().copy ())
913
+ super (TestOCElement , self ).__init__ (** params )
914
+
915
+
897
916
class TestOutputCollection (XMLParam ):
898
917
name = "output_collection"
899
918
@@ -911,15 +930,21 @@ def __init__(
911
930
params = Util .clean_kwargs (locals ().copy ())
912
931
super (TestOutputCollection , self ).__init__ (** params )
913
932
933
+ def acceptable_child (self , child ):
934
+ return isinstance (child , TestOCElement )
935
+
914
936
def command_line_before (self , mako_path ):
915
937
return "<output_collection name = '%s'>" % self .name
916
938
917
939
def command_line_after (self ):
918
940
return "</output_collection>"
919
941
920
942
def command_line_actual (self , mako_path ):
943
+ lines = []
944
+ for child in self .children :
945
+ lines .append (child .command_line ())
946
+ return "\n " .join (lines )
921
947
922
- return ""
923
948
924
949
class TestRepeat (XMLParam ):
925
950
name = "repeat"
@@ -939,7 +964,9 @@ def __init__(
939
964
super (TestRepeat , self ).__init__ (** params )
940
965
941
966
def acceptable_child (self , child ):
942
- return issubclass (type (child ), TestParam )
967
+ return issubclass (type (child ), TestParam ) \
968
+ or issubclass (type (child ), TestOutput ) \
969
+ or issubclass (type (child ), TestOutputCollection )
943
970
944
971
def command_line_before (self , mako_path ):
945
972
return "<repeat name = '%s'>" % self .name
0 commit comments