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):
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:
supybot.plugins.get(name).setValue(currentValue)

View File

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