mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-04 18:29:21 +01:00
Updated to let GroupWithDefault have a .set() that works.
This commit is contained in:
parent
f90adb5325
commit
3d0b8dc870
@ -123,6 +123,8 @@ class Group(object):
|
|||||||
attr = attr.lower()
|
attr = attr.lower()
|
||||||
if attr in self.values:
|
if attr in self.values:
|
||||||
self.values[attr].set(s)
|
self.values[attr].set(s)
|
||||||
|
elif attr in self.children and hasattr(self.children[attr], 'set'):
|
||||||
|
self.children[attr].set(s)
|
||||||
else:
|
else:
|
||||||
s = '%s is not a valid attribute of %s' % (original, self.name)
|
s = '%s is not a valid attribute of %s' % (original, self.name)
|
||||||
raise NonExistentRegistryEntry, s
|
raise NonExistentRegistryEntry, s
|
||||||
@ -187,8 +189,13 @@ class GroupWithDefault(Group):
|
|||||||
self.values[attr] = copy.copy(self.value)
|
self.values[attr] = copy.copy(self.value)
|
||||||
self.values[attr].set(s)
|
self.values[attr].set(s)
|
||||||
|
|
||||||
def set(self, attr, s):
|
def set(self, *args):
|
||||||
self.__setattr__(attr, s)
|
if len(args) == 1:
|
||||||
|
self.value.set(args[0])
|
||||||
|
else:
|
||||||
|
assert len(args) == 2
|
||||||
|
(attr, s) = args
|
||||||
|
self.__setattr__(attr, s)
|
||||||
|
|
||||||
def getValues(self):
|
def getValues(self):
|
||||||
L = Group.getValues(self)
|
L = Group.getValues(self)
|
||||||
@ -209,6 +216,7 @@ if __name__ == '__main__':
|
|||||||
GroupWithDefault(StringSurroundedBySpaces(' || ',
|
GroupWithDefault(StringSurroundedBySpaces(' || ',
|
||||||
'Determines what separator the bot uses to separate topic entries.')))
|
'Determines what separator the bot uses to separate topic entries.')))
|
||||||
supybot.plugins.topic.separator.set('#supybot', ' |||| ')
|
supybot.plugins.topic.separator.set('#supybot', ' |||| ')
|
||||||
|
supybot.plugins.topic.separator.set(' <> ')
|
||||||
|
|
||||||
for (k, v) in supybot.getValues():
|
for (k, v) in supybot.getValues():
|
||||||
print '%s: %s' % (k, v)
|
print '%s: %s' % (k, v)
|
||||||
|
Loading…
Reference in New Issue
Block a user