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 141 of file Main.py.
143 Helper to convert values to old .opts format. 145 >>> print toOpt('some "text"') 147 >>> print toOpt('first\\nsecond') 150 >>> print toOpt({'a': [1, 2, '3']}) 153 if isinstance(value, basestring):
154 return '"{0}"'.
format(value.replace(
'"',
'\\"'))
155 elif isinstance(value, dict):
157 for k, v
in value.iteritems()))
158 elif hasattr(value,
'__iter__'):
159 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.