Config: make 'config list' exclude pseudo-children of network-specific variables.

This commit is contained in:
Valentin Lorentz 2019-11-02 18:47:45 +01:00
parent 9e58b2c936
commit 322923c957
2 changed files with 15 additions and 2 deletions

View File

@ -151,8 +151,13 @@ class Config(callbacks.Plugin):
def _list(self, irc, group): def _list(self, irc, group):
L = [] L = []
for (vname, v) in group._children.items(): for (vname, v) in group._children.items():
if hasattr(group, '_channelValue') and group._channelValue and \ if getattr(group, '_networkValue', False) and \
irc.isChannel(vname) and not v._children: vname.startswith(':'):
# Skip pseudo-children that are network names
continue
if getattr(group, '_channelValue', False) and \
irc.isChannel(vname):
# Skip pseudo-children that are channel names
continue continue
if hasattr(v, '_channelValue') and v._channelValue: if hasattr(v, '_channelValue') and v._channelValue:
vname = '#' + vname vname = '#' + vname

View File

@ -56,6 +56,14 @@ class ConfigTestCase(ChannelPluginTestCase):
self.assertNotError('config list supybot.replies') self.assertNotError('config list supybot.replies')
self.assertRegexp('config list supybot', r'@plugins.*@replies.*@reply') self.assertRegexp('config list supybot', r'@plugins.*@replies.*@reply')
def testListExcludes(self):
"""Checks that 'config list' excludes pseudo-children of
network-specific and channel-specific variables."""
self.assertNotError(
'config channel #zpojfejf supybot.replies.error foo')
self.assertRegexp('config list supybot.replies.error',
"There don't seem to be any values")
def testHelp(self): def testHelp(self):
self.assertError('config help alsdkfj') self.assertError('config help alsdkfj')
self.assertError('config help supybot.alsdkfj') self.assertError('config help supybot.alsdkfj')