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 8 of file Main.py.
11 Helper to convert values to old .opts format.
13 >>> print toOpt('some "text"')
15 >>> print toOpt('first\\nsecond')
18 >>> print toOpt({'a': [1, 2, '3']})
21 if isinstance(value, basestring):
22 return '"{0}"'.
format(value.replace(
'"',
'\\"'))
23 elif isinstance(value, dict):
25 for k, v
in value.iteritems()))
26 elif hasattr(value,
'__iter__'):
27 return '[{0}]'.
format(
', '.join(
map(toOpt, value)))