@@ -237,45 +237,30 @@ def output_callback(out, processStatus):
237
237
return final_output [0 ]
238
238
239
239
240
- class FileAction (argparse .Action ):
240
+ class FSAction (argparse .Action ):
241
+ objclass = None # type: Text
241
242
242
243
def __init__ (self , option_strings , dest , nargs = None , ** kwargs ):
243
244
# type: (List[Text], Text, Any, **Any) -> None
244
245
if nargs is not None :
245
246
raise ValueError ("nargs not allowed" )
246
- super (FileAction , self ).__init__ (option_strings , dest , ** kwargs )
247
+ super (FSAction , self ).__init__ (option_strings , dest , ** kwargs )
247
248
248
249
def __call__ (self , parser , namespace , values , option_string = None ):
249
250
# type: (argparse.ArgumentParser, argparse.Namespace, Union[AnyStr, Sequence[Any], None], AnyStr) -> None
250
251
setattr (namespace ,
251
252
self .dest , # type: ignore
252
- {"class" : "File" ,
253
+ {"class" : self . objclass ,
253
254
"location" : "file://%s" % os .path .abspath (cast (AnyStr , values ))})
254
255
255
-
256
- class DirectoryAction ( argparse . Action ):
256
+ class FSAppendAction ( argparse . Action ):
257
+ objclass = None # type: Text
257
258
258
259
def __init__ (self , option_strings , dest , nargs = None , ** kwargs ):
259
260
# type: (List[Text], Text, Any, **Any) -> None
260
261
if nargs is not None :
261
262
raise ValueError ("nargs not allowed" )
262
- super (DirectoryAction , self ).__init__ (option_strings , dest , ** kwargs )
263
-
264
- def __call__ (self , parser , namespace , values , option_string = None ):
265
- # type: (argparse.ArgumentParser, argparse.Namespace, Union[AnyStr, Sequence[Any], None], AnyStr) -> None
266
- setattr (namespace ,
267
- self .dest , # type: ignore
268
- {"class" : "Directory" ,
269
- "location" : "file://%s" % os .path .abspath (cast (AnyStr , values ))})
270
-
271
-
272
- class FileAppendAction (argparse .Action ):
273
-
274
- def __init__ (self , option_strings , dest , nargs = None , ** kwargs ):
275
- # type: (List[Text], Text, Any, **Any) -> None
276
- if nargs is not None :
277
- raise ValueError ("nargs not allowed" )
278
- super (FileAppendAction , self ).__init__ (option_strings , dest , ** kwargs )
263
+ super (FSAppendAction , self ).__init__ (option_strings , dest , ** kwargs )
279
264
280
265
def __call__ (self , parser , namespace , values , option_string = None ):
281
266
# type: (argparse.ArgumentParser, argparse.Namespace, Union[AnyStr, Sequence[Any], None], AnyStr) -> None
@@ -288,9 +273,20 @@ def __call__(self, parser, namespace, values, option_string=None):
288
273
self .dest , # type: ignore
289
274
g )
290
275
g .append (
291
- {"class" : "File" ,
276
+ {"class" : self . objclass ,
292
277
"location" : "file://%s" % os .path .abspath (cast (AnyStr , values ))})
293
278
279
+ class FileAction (FSAction ):
280
+ objclass = "File"
281
+
282
+ class DirectoryAction (FSAction ):
283
+ objclass = "Directory"
284
+
285
+ class FileAppendAction (FSAppendAction ):
286
+ objclass = "File"
287
+
288
+ class DirectoryAppendAction (FSAppendAction ):
289
+ objclass = "Directory"
294
290
295
291
def generate_parser (toolparser , tool , namemap ):
296
292
# type: (argparse.ArgumentParser, Process, Dict[Text, Text]) -> argparse.ArgumentParser
@@ -330,6 +326,8 @@ def generate_parser(toolparser, tool, namemap):
330
326
elif isinstance (inptype , dict ) and inptype ["type" ] == "array" :
331
327
if inptype ["items" ] == "File" :
332
328
action = cast (argparse .Action , FileAppendAction )
329
+ elif inptype ["items" ] == "Directory" :
330
+ action = cast (argparse .Action , DirectoryAppendAction )
333
331
else :
334
332
action = "append"
335
333
elif isinstance (inptype , dict ) and inptype ["type" ] == "enum" :
0 commit comments