children = deque([child for child in dir(type(obj)) if isinstance(getattr(type(obj), child, None), Setting)] + \
[child for child in dir(type(obj)) if isinstance(getattr(type(obj), child, None), SettingsGroupMeta)])
# display first line
linebuf = ' '*(len(name)+3) + '+'
if children:
linebuf += '-- ' + format_child(obj, children.popleft(), width-(len(name)+7) if width is not None else None)
print linebuf
# display second line
linebuf = name + ' --|'
if children:
linebuf += '-- ' + format_child(obj, children.popleft(), width-(len(name)+7) if width is not None else None)
print linebuf
# display the rest of the lines
if children:
while children:
child = children.popleft()
linebuf = ' '*(len(name)+3) + ('|' if children else '+') + '-- ' + format_child(obj, child, width-(len(name)+7) if width is not None else None)
print linebuf
else:
linebuf = ' '*(len(name)+3) + '+'
print linebuf
print
[display_object(getattr(obj, child), child) for child in dir(type(obj)) if isinstance(getattr(type(obj), child, None), SettingsGroupMeta)]
class SettingsParser(object):
@classmethod
def parse_default(cls, type, value):
if issubclass(type, (tuple, list)):
values = re.split(r'\s*,\s*', value)
return values
elif issubclass(type, bool):
if value.lower() == 'true':
return True
else:
return False
else:
return value
@classmethod
def parse_LocalIPAddress(cls, type, value):
if value == 'auto':
return type()
return type(value)
@classmethod
def parse_MSRPRelayAddress(cls, type, value):
match = re.match(r'^(?P<host>(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|([a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*))(:(?P<port>\d+))?(;transport=(?P<transport>[a-z]+))?$', value)
if match is None:
raise ValueError("illegal value for address: %s" % value)
parser.add_option('-c', '--config-file', type='string', dest='config_file', help='The path to a configuration file to use. This overrides the default location of the configuration file.', metavar='FILE')