@@ -371,15 +371,15 @@ def _field_value(self, field, check_file=False):
371371 return value
372372
373373 def _command_shelltask_executable (self , field ):
374- """Returining position and value for executable ShellTask input"""
374+ """Returning position and value for executable ShellTask input"""
375375 pos = 0 # executable should be the first el. of the command
376376 value = self ._field_value (field )
377377 if value is None :
378378 raise ValueError ("executable has to be set" )
379379 return pos , ensure_list (value , tuple2list = True )
380380
381381 def _command_shelltask_args (self , field ):
382- """Returining position and value for args ShellTask input"""
382+ """Returning position and value for args ShellTask input"""
383383 pos = - 1 # assuming that args is the last el. of the command
384384 value = self ._field_value (field , check_file = True )
385385 if value is None :
@@ -396,7 +396,7 @@ def _command_pos_args(self, field):
396396 argstr = field .metadata .get ("argstr" , None )
397397 formatter = field .metadata .get ("formatter" , None )
398398 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,
400400 # or a formatter is not provided too.
401401 return None
402402 pos = field .metadata .get ("position" , None )
@@ -429,7 +429,7 @@ def _command_pos_args(self, field):
429429
430430 cmd_add = []
431431 # 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.
433433 if "formatter" in field .metadata :
434434 call_args = inspect .getfullargspec (field .metadata ["formatter" ])
435435 call_args_val = {}
@@ -453,12 +453,16 @@ def _command_pos_args(self, field):
453453 cmd_add += split_cmd (cmd_el_str )
454454 elif field .type is bool :
455455 # 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.
457457 if value is True :
458458 cmd_add .append (argstr )
459459 else :
460460 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+ ):
462466 argstr = argstr .replace ("..." , "" )
463467 # if argstr has a more complex form, with "{input_field}"
464468 if "{" in argstr and "}" in argstr :
@@ -474,7 +478,9 @@ def _command_pos_args(self, field):
474478 else :
475479 # in case there are ... when input is not a list
476480 argstr = argstr .replace ("..." , "" )
477- if isinstance (value , list ):
481+ if isinstance (value , ty .Iterable ) and not isinstance (
482+ value , (str , bytes )
483+ ):
478484 cmd_el_str = sep .join ([str (val ) for val in value ])
479485 value = cmd_el_str
480486 # if argstr has a more complex form, with "{input_field}"
@@ -505,10 +511,10 @@ def cmdline(self):
505511 command_args = self .container_args + self .command_args
506512 else :
507513 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'.
509515 cmdline = command_args [0 ]
510516 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
512518 # quotes, add quotes to escape the space. Not sure if this should
513519 # be expanded to include other special characters apart from spaces
514520 if " " in arg :
@@ -600,7 +606,7 @@ def __init__(
600606 def _field_value (self , field , check_file = False ):
601607 """
602608 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
604610 and settings bindings if needed.
605611 """
606612 value = super ()._field_value (field )
@@ -854,12 +860,12 @@ def split_cmd(cmd: str):
854860 str
855861 the command line string split into process args
856862 """
857- # Check whether running on posix or windows system
863+ # Check whether running on posix or Windows system
858864 on_posix = platform .system () != "Windows"
859865 args = shlex .split (cmd , posix = on_posix )
860866 cmd_args = []
861867 for arg in args :
862- match = re .match ("('| \" )(.*)\\ 1$" , arg )
868+ match = re .match ("([' \" ] )(.*)\\ 1$" , arg )
863869 if match :
864870 cmd_args .append (match .group (2 ))
865871 else :
0 commit comments