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 10 of file Main.py.
12 Helper to convert values to old .opts format. 14 >>> print toOpt('some "text"') 16 >>> print toOpt('first\\nsecond') 19 >>> print toOpt({'a': [1, 2, '3']}) 22 if isinstance(value, basestring):
23 return '"{0}"'.
format(value.replace(
'"',
'\\"'))
24 elif isinstance(value, dict):
25 return '{{{0}}}'.
format(
', '.join(
27 for k, v
in value.iteritems()))
28 elif hasattr(value,
'__iter__'):
29 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.