Correct argument quoting for Windows platforms.

This commit is contained in:
Bastian Kleineidam 2010-04-05 08:46:09 +02:00
parent 1e83fc3594
commit 97901d89d9
1 changed files with 10 additions and 0 deletions

View File

@ -272,9 +272,19 @@ def tmpfile (dir=None, prefix="temp", suffix=None):
def shell_quote (value):
"""Quote all shell metacharacters in given string value with strong
(ie. single) quotes, handling the single quote especially."""
if os.name == 'nt':
return shell_quote_nt(value)
return "'%s'" % value.replace("'", r"'\''")
def shell_quote_nt (value):
"""Quote argument for Windows system. Modeled after distutils
_nt_quote_args() function."""
if " " in value:
return '"%s"' % value
return value
def stripext (filename):
"""Return the basename without extension of given filename."""
return os.path.splitext(os.path.basename(filename))[0]