Skip to content

Commit

Permalink
Merge pull request #4 from Parsl/3-update-handling-input-and-output-a…
Browse files Browse the repository at this point in the history
…rgs-of-type-string

Issue #3: update cwl to handle string args
  • Loading branch information
NishchayKarle authored Feb 19, 2024
2 parents 031e2a6 + 3139b01 commit 8c15cca
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cwl/cwl_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ def to_string(self, value: Any = None) -> str:
if value is None:
value = self.default

res_string = self.__process_value(value)
res_string = self.__process_value(
value, str_quote='"' if self.arg_type == self.STRING else ""
)

if self.prefix:
res_string = (
Expand All @@ -130,15 +132,26 @@ def __boolean_to_string(self, value: Any) -> str:
return str(self.prefix)
return ""

def __process_value(self, value: Any) -> str:
def __process_value(self, value: Any, str_quote="") -> str:
if self.array:
return self.__process_array_value(value)
return self.__process_array_value(value, str_quote)

return str(value) if self.arg_type != self.FILE else str(value.filepath)
return (
f"{str_quote}{str(value)}{str_quote}"
if self.arg_type != self.FILE
else f"{str_quote}{str(value.filepath)}{str_quote}"
)

def __process_array_value(self, value: Any) -> str:
def __process_array_value(self, value: Any, str_quote="") -> str:
itm_sep = self.item_separator if self.item_separator else " "
str_value_list = [str(v) if self.arg_type != self.FILE else str(v.filepath) for v in value]
str_value_list = [
(
f"{str_quote}{str(v)}{str_quote}"
if self.arg_type != self.FILE
else f"{str_quote}{str(v.filepath)}{str_quote}"
)
for v in value
]

return itm_sep.join(str_value_list)

Expand Down

0 comments on commit 8c15cca

Please sign in to comment.