Helper to convert values to old .opts format.
>>> print toOpt('some "text"')
"some \\"text\\""
>>> print toOpt('first\\nsecond')
"first
second"
>>> print toOpt({'a': [1, 2, '3']})
{"a": [1, 2, "3"]}
Definition at line 140 of file Main.py.
142 Helper to convert values to old .opts format. 144 >>> print toOpt('some "text"') 146 >>> print toOpt('first\\nsecond') 149 >>> print toOpt({'a': [1, 2, '3']}) 152 if isinstance(value, basestring):
153 return '"{0}"'.
format(value.replace(
'"',
'\\"'))
154 elif isinstance(value, dict):
156 for k, v
in value.iteritems()))
157 elif hasattr(value,
'__iter__'):
158 return '[{0}]'.
format(
', '.join(
map(toOpt, value)))
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
struct GAUDI_API map
Parametrisation class for map-like implementation.