Made a showDefault configuration option for deciding whether or not to write the default to the registry, and made registerPlugin set it to False (who needs to know what the default is for that stuff?)

This commit is contained in:
Jeremy Fincher 2004-02-10 03:15:31 +00:00
parent 20285ae546
commit d6f79c4a56
2 changed files with 10 additions and 8 deletions

View File

@ -59,7 +59,7 @@ supybot.setName('supybot')
def registerPlugin(name, currentValue=None): def registerPlugin(name, currentValue=None):
supybot.plugins.register(name, registry.Boolean(False, """Determines supybot.plugins.register(name, registry.Boolean(False, """Determines
whether this plugin is loaded by default.""")) whether this plugin is loaded by default.""", showDefault=False))
if currentValue is not None: if currentValue is not None:
supybot.plugins.get(name).setValue(currentValue) supybot.plugins.get(name).setValue(currentValue)

View File

@ -87,6 +87,7 @@ def close(registry, filename, annotated=True, helpOnceOnly=False):
lines.insert(0, '\n') lines.insert(0, '\n')
if hasattr(value, 'value'): if hasattr(value, 'value'):
lines.append('#\n') lines.append('#\n')
if value.showDefault:
try: try:
original = value.value original = value.value
value.value = value.default value.value = value.default
@ -190,9 +191,10 @@ class Group(object):
class Value(Group): class Value(Group):
def __init__(self, default, help, **kwargs): def __init__(self, default, help, showDefault=True, **kwargs):
Group.__init__(self, **kwargs) Group.__init__(self, **kwargs)
self.default = default self.default = default
self.showDefault = showDefault
self.help = utils.normalizeWhitespace(help.strip()) self.help = utils.normalizeWhitespace(help.strip())
self.setValue(default) self.setValue(default)