mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
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:
parent
20285ae546
commit
d6f79c4a56
@ -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)
|
||||
|
||||
|
@ -87,12 +87,13 @@ def close(registry, filename, annotated=True, helpOnceOnly=False):
|
||||
lines.insert(0, '\n')
|
||||
if hasattr(value, 'value'):
|
||||
lines.append('#\n')
|
||||
try:
|
||||
original = value.value
|
||||
value.value = value.default
|
||||
lines.append('# Default value: %s\n' % value)
|
||||
finally:
|
||||
value.value = original
|
||||
if value.showDefault:
|
||||
try:
|
||||
original = value.value
|
||||
value.value = value.default
|
||||
lines.append('# Default value: %s\n' % value)
|
||||
finally:
|
||||
value.value = original
|
||||
lines.append('###\n')
|
||||
fd.writelines(lines)
|
||||
if hasattr(value, 'value'): # This lets us print help for non-valued.
|
||||
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user