@@ -371,15 +371,15 @@ def _field_value(self, field, check_file=False):
371
371
return value
372
372
373
373
def _command_shelltask_executable (self , field ):
374
- """Returining position and value for executable ShellTask input"""
374
+ """Returning position and value for executable ShellTask input"""
375
375
pos = 0 # executable should be the first el. of the command
376
376
value = self ._field_value (field )
377
377
if value is None :
378
378
raise ValueError ("executable has to be set" )
379
379
return pos , ensure_list (value , tuple2list = True )
380
380
381
381
def _command_shelltask_args (self , field ):
382
- """Returining position and value for args ShellTask input"""
382
+ """Returning position and value for args ShellTask input"""
383
383
pos = - 1 # assuming that args is the last el. of the command
384
384
value = self ._field_value (field , check_file = True )
385
385
if value is None :
@@ -396,7 +396,7 @@ def _command_pos_args(self, field):
396
396
argstr = field .metadata .get ("argstr" , None )
397
397
formatter = field .metadata .get ("formatter" , None )
398
398
if argstr is None and formatter is None :
399
- # assuming that input that has no arstr is not used in the command,
399
+ # assuming that input that has no argstr is not used in the command,
400
400
# or a formatter is not provided too.
401
401
return None
402
402
pos = field .metadata .get ("position" , None )
@@ -429,7 +429,7 @@ def _command_pos_args(self, field):
429
429
430
430
cmd_add = []
431
431
# formatter that creates a custom command argument
432
- # it can thake the value of the filed , all inputs, or the value of other fields.
432
+ # it can take the value of the field , all inputs, or the value of other fields.
433
433
if "formatter" in field .metadata :
434
434
call_args = inspect .getfullargspec (field .metadata ["formatter" ])
435
435
call_args_val = {}
@@ -453,12 +453,16 @@ def _command_pos_args(self, field):
453
453
cmd_add += split_cmd (cmd_el_str )
454
454
elif field .type is bool :
455
455
# if value is simply True the original argstr is used,
456
- # if False, nothing is added to the command
456
+ # if False, nothing is added to the command.
457
457
if value is True :
458
458
cmd_add .append (argstr )
459
459
else :
460
460
sep = field .metadata .get ("sep" , " " )
461
- if argstr .endswith ("..." ) and isinstance (value , list ):
461
+ if (
462
+ argstr .endswith ("..." )
463
+ and isinstance (value , ty .Iterable )
464
+ and not isinstance (value , (str , bytes ))
465
+ ):
462
466
argstr = argstr .replace ("..." , "" )
463
467
# if argstr has a more complex form, with "{input_field}"
464
468
if "{" in argstr and "}" in argstr :
@@ -474,7 +478,9 @@ def _command_pos_args(self, field):
474
478
else :
475
479
# in case there are ... when input is not a list
476
480
argstr = argstr .replace ("..." , "" )
477
- if isinstance (value , list ):
481
+ if isinstance (value , ty .Iterable ) and not isinstance (
482
+ value , (str , bytes )
483
+ ):
478
484
cmd_el_str = sep .join ([str (val ) for val in value ])
479
485
value = cmd_el_str
480
486
# if argstr has a more complex form, with "{input_field}"
@@ -505,10 +511,10 @@ def cmdline(self):
505
511
command_args = self .container_args + self .command_args
506
512
else :
507
513
command_args = self .command_args
508
- # Skip the executable, which can be a multi-part command, e.g. 'docker run'.
514
+ # Skip the executable, which can be a multipart command, e.g. 'docker run'.
509
515
cmdline = command_args [0 ]
510
516
for arg in command_args [1 :]:
511
- # If there are spaces in the arg and it is not enclosed by matching
517
+ # If there are spaces in the arg, and it is not enclosed by matching
512
518
# quotes, add quotes to escape the space. Not sure if this should
513
519
# be expanded to include other special characters apart from spaces
514
520
if " " in arg :
@@ -600,7 +606,7 @@ def __init__(
600
606
def _field_value (self , field , check_file = False ):
601
607
"""
602
608
Checking value of the specific field, if value is not set, None is returned.
603
- If check_file is True, checking if field is a a local file
609
+ If check_file is True, checking if field is a local file
604
610
and settings bindings if needed.
605
611
"""
606
612
value = super ()._field_value (field )
@@ -854,12 +860,12 @@ def split_cmd(cmd: str):
854
860
str
855
861
the command line string split into process args
856
862
"""
857
- # Check whether running on posix or windows system
863
+ # Check whether running on posix or Windows system
858
864
on_posix = platform .system () != "Windows"
859
865
args = shlex .split (cmd , posix = on_posix )
860
866
cmd_args = []
861
867
for arg in args :
862
- match = re .match ("('| \" )(.*)\\ 1$" , arg )
868
+ match = re .match ("([' \" ] )(.*)\\ 1$" , arg )
863
869
if match :
864
870
cmd_args .append (match .group (2 ))
865
871
else :
0 commit comments