All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi.Main Namespace Reference

Classes

class  gaudimain
 

Functions

def toOpt
 

Variables

tuple log logging.getLogger(__name__)
 

Function Documentation

def Gaudi.Main.toOpt (   value)
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.

8 
9 def toOpt(value):
10  '''
11  Helper to convert values to old .opts format.
12 
13  >>> print toOpt('some "text"')
14  "some \\"text\\""
15  >>> print toOpt('first\\nsecond')
16  "first
17  second"
18  >>> print toOpt({'a': [1, 2, '3']})
19  {"a": [1, 2, "3"]}
20  '''
21  if isinstance(value, basestring):
22  return '"{0}"'.format(value.replace('"', '\\"'))
23  elif isinstance(value, dict):
24  return '{{{0}}}'.format(', '.join('{0}: {1}'.format(toOpt(k), toOpt(v))
25  for k, v in value.iteritems()))
26  elif hasattr(value, '__iter__'):
27  return '[{0}]'.format(', '.join(map(toOpt, value)))
28  else:
29  return repr(value)

Variable Documentation

tuple Gaudi.Main.log logging.getLogger(__name__)

Definition at line 6 of file Main.py.