From a61b5b8dca89121e48f810ef10c048e2df13507b Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 15 Jan 2004 00:26:31 +0000 Subject: [PATCH] Added storing of the default value to Values and GroupsWithDefault. --- src/registry.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/registry.py b/src/registry.py index 1b9326162..52aed6160 100644 --- a/src/registry.py +++ b/src/registry.py @@ -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 @@ -159,6 +159,16 @@ class Group(object): return self.children[attr].help 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)