Added storing of the default value to Values and GroupsWithDefault.

This commit is contained in:
Jeremy Fincher 2004-01-15 00:26:31 +00:00
parent fbcec1b89f
commit a61b5b8dca

View File

@ -64,7 +64,7 @@ def close(registry, filename):
class Value(object):
def __init__(self, default, help):
self.help = utils.normalizeWhitespace(help)
self.value = default
self.value = self.default = default
def set(self, s):
"""Override this with a function to convert a string to whatever type
@ -160,6 +160,16 @@ class Group(object):
else:
self.__nonExistentEntry(original)
def default(self, attr):
original = attr
attr = attr.lower()
if attr in self.values:
return self.values[attr].default
elif attr in self.children and hasattr(self.children[attr], 'default'):
return self.children[attr].default
else:
self.__nonExistentEntry(original)
def setName(self, name):
self.__dict__['name'] = name
@ -210,8 +220,8 @@ class Group(object):
class GroupWithDefault(Group):
def __init__(self, value):
Group.__init__(self)
self.__dict__['value'] = value
self.__dict__['help'] = value.help
self.__dict__['value'] = self.__dict__['default'] = value
def __makeChild(self, attr, s):
v = copy.copy(self.value)