mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Cleaner interface for Config.list.
This commit is contained in:
parent
58ce7c2141
commit
6c1a7cb4a5
@ -108,38 +108,25 @@ class Config(callbacks.Privmsg):
|
|||||||
name = 'supybot.' + name
|
name = 'supybot.' + name
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def _list(self, name, groups=False):
|
def _list(self, name):
|
||||||
name = self._canonicalizeName(name)
|
name = self._canonicalizeName(name)
|
||||||
group = getWrapper(name)
|
group = getWrapper(name)
|
||||||
if groups:
|
|
||||||
L = []
|
L = []
|
||||||
for (vname, v) in group._children.iteritems():
|
for (vname, v) in group._children.iteritems():
|
||||||
if v._added:
|
if v._added:
|
||||||
|
vname = '@' + vname
|
||||||
L.append(vname)
|
L.append(vname)
|
||||||
utils.sortBy(str.lower, L)
|
utils.sortBy(str.lower, L)
|
||||||
return L
|
return L
|
||||||
else:
|
|
||||||
try:
|
|
||||||
L = [t[0] for t in group.getValues(fullNames=False)]
|
|
||||||
utils.sortBy(str.lower, L)
|
|
||||||
return L
|
|
||||||
except TypeError:
|
|
||||||
return []
|
|
||||||
|
|
||||||
def list(self, irc, msg, args):
|
def list(self, irc, msg, args):
|
||||||
"""[--groups] <group>
|
"""<group>
|
||||||
|
|
||||||
Returns the configuration variables available under the given
|
Returns the configuration variables available under the given
|
||||||
configuration <group>. If --groups is given, return the subgroups of
|
configuration <group>. Subgroups are indicated by a preceding @.
|
||||||
the <group>.
|
|
||||||
"""
|
"""
|
||||||
(optlist, rest) = getopt.getopt(args, '', ['groups'])
|
name = privmsgs.getArgs(args)
|
||||||
groups = False
|
L = self._list(name)
|
||||||
for (name, arg) in optlist:
|
|
||||||
if name == '--groups':
|
|
||||||
groups = True
|
|
||||||
name = privmsgs.getArgs(rest)
|
|
||||||
L = self._list(name, groups=groups)
|
|
||||||
if L:
|
if L:
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(utils.commaAndify(L))
|
||||||
elif groups:
|
elif groups:
|
||||||
|
Loading…
Reference in New Issue
Block a user