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 154 of file Main.py.
156 Helper to convert values to old .opts format. 158 >>> print toOpt('some "text"') 160 >>> print toOpt('first\\nsecond') 163 >>> print toOpt({'a': [1, 2, '3']}) 166 if isinstance(value, basestring):
167 return '"{0}"'.
format(value.replace(
'"',
'\\"'))
168 elif isinstance(value, dict):
169 return '{{{0}}}'.
format(
', '.join(
171 for k, v
in value.iteritems()))
172 elif hasattr(value,
'__iter__'):
173 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.