diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-10-06 22:00:48 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-10-06 22:00:48 -0400 |
commit | 5e6cf76bd85de2ca63e2c78d5c4a865dc69d63c2 (patch) | |
tree | 7b141bfe66ee68ebc08cac6023e7c058f7499573 | |
parent | d0654e136ae19837d8659b064205115ce59f940f (diff) | |
download | cmd2-git-5e6cf76bd85de2ca63e2c78d5c4a865dc69d63c2.tar.gz |
Quoting strings with utility function
-rw-r--r-- | cmd2/pyscript_bridge.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/cmd2/pyscript_bridge.py b/cmd2/pyscript_bridge.py index 5f5c3542..9a1d0fec 100644 --- a/cmd2/pyscript_bridge.py +++ b/cmd2/pyscript_bridge.py @@ -13,7 +13,7 @@ import sys from typing import List, Callable, Optional from .argparse_completer import _RangeAction -from .utils import namedtuple_with_defaults, StdSim +from .utils import namedtuple_with_defaults, StdSim, quote_string_if_needed # Python 3.4 require contextlib2 for temporarily redirecting stderr and stdout if sys.version_info < (3, 5): @@ -225,8 +225,7 @@ class ArgparseFunctor: if isinstance(value, List) or isinstance(value, tuple): for item in value: item = str(item).strip() - if ' ' in item: - item = '"{}"'.format(item) + item = quote_string_if_needed(item) cmd_str[0] += '{} '.format(item) # If this is a flag parameter that can accept a variable number of arguments and we have not @@ -238,8 +237,7 @@ class ArgparseFunctor: else: value = str(value).strip() - if ' ' in value: - value = '"{}"'.format(value) + value = quote_string_if_needed(value) cmd_str[0] += '{} '.format(value) # If this is a flag parameter that can accept a variable number of arguments and we have not |