-# Copyright (C) 2013-2020 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2013-2021 CEA/DEN, EDF R&D, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# Formatting scripts and args as a Bash-like command-line:
# script1.py [args] ; script2.py [args] ; ...
# scriptArgs is a list of ScriptAndArgs objects; their output parameters are omitted
-def formatScriptsAndArgs(scriptArgs=None):
+def formatScriptsAndArgs(scriptArgs=None, escapeSpaces=False):
if scriptArgs is None:
return ""
commands = []
for sa_obj in scriptArgs:
cmd = sa_obj.script
+ if escapeSpaces and cmd:
+ if sys.platform == "win32":
+ cmd = cmd.replace(' ', ' "', 1)
+ cmd = cmd + '"'
+ else:
+ cmd = cmd.replace(' ', '\ ').replace('\ ', ' ', 1)
if sa_obj.args:
cmd = " ".join([cmd]+sa_obj.args)
commands.append(cmd)