mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Changed some non-public checkCapability methods to be prefixed with an underscore.
This commit is contained in:
parent
dae2a02231
commit
6002089619
14
src/ircdb.py
14
src/ircdb.py
@ -242,7 +242,7 @@ class IrcUser(object):
|
|||||||
"""Takes from the user the given capability."""
|
"""Takes from the user the given capability."""
|
||||||
self.capabilities.remove(capability)
|
self.capabilities.remove(capability)
|
||||||
|
|
||||||
def checkCapability(self, capability):
|
def _checkCapability(self, capability):
|
||||||
"""Checks the user for a given capability."""
|
"""Checks the user for a given capability."""
|
||||||
if self.ignore:
|
if self.ignore:
|
||||||
if isAntiCapability(capability):
|
if isAntiCapability(capability):
|
||||||
@ -404,7 +404,7 @@ class IrcChannel(object):
|
|||||||
"""Sets the default capability in the channel."""
|
"""Sets the default capability in the channel."""
|
||||||
self.defaultAllow = b
|
self.defaultAllow = b
|
||||||
|
|
||||||
def checkCapability(self, capability):
|
def _checkCapability(self, capability):
|
||||||
"""Checks whether a certain capability is allowed by the channel."""
|
"""Checks whether a certain capability is allowed by the channel."""
|
||||||
assert isCapability(capability), 'got %s' % capability
|
assert isCapability(capability), 'got %s' % capability
|
||||||
if capability in self.capabilities:
|
if capability in self.capabilities:
|
||||||
@ -969,7 +969,7 @@ def checkIgnored(hostmask, recipient='', users=users, channels=channels):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
if user.checkCapability('owner'):
|
if user._checkCapability('owner'):
|
||||||
# Owners shouldn't ever be ignored.
|
# Owners shouldn't ever be ignored.
|
||||||
return False
|
return False
|
||||||
elif user.ignore:
|
elif user.ignore:
|
||||||
@ -1000,7 +1000,7 @@ def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
|
|||||||
try:
|
try:
|
||||||
c = channels.getChannel(channel)
|
c = channels.getChannel(channel)
|
||||||
if capability in c.capabilities:
|
if capability in c.capabilities:
|
||||||
return c.checkCapability(capability)
|
return c._checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
return _x(capability, c.defaultAllow)
|
return _x(capability, c.defaultAllow)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -1030,19 +1030,19 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
return _checkCapabilityForUnknownUser(capability, users=users,
|
return _checkCapabilityForUnknownUser(capability, users=users,
|
||||||
channels=channels)
|
channels=channels)
|
||||||
if capability in u.capabilities:
|
if capability in u.capabilities:
|
||||||
return u.checkCapability(capability)
|
return u._checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
if isChannelCapability(capability):
|
if isChannelCapability(capability):
|
||||||
(channel, capability) = fromChannelCapability(capability)
|
(channel, capability) = fromChannelCapability(capability)
|
||||||
try:
|
try:
|
||||||
chanop = makeChannelCapability(channel, 'op')
|
chanop = makeChannelCapability(channel, 'op')
|
||||||
if u.checkCapability(chanop):
|
if u._checkCapability(chanop):
|
||||||
return _x(capability, True)
|
return _x(capability, True)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
c = channels.getChannel(channel)
|
c = channels.getChannel(channel)
|
||||||
if capability in c.capabilities:
|
if capability in c.capabilities:
|
||||||
return c.checkCapability(capability)
|
return c._checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
return _x(capability, c.defaultAllow)
|
return _x(capability, c.defaultAllow)
|
||||||
defaultCapabilities = conf.supybot.capabilities()
|
defaultCapabilities = conf.supybot.capabilities()
|
||||||
|
@ -203,15 +203,15 @@ class IrcUserTestCase(IrcdbTestCase):
|
|||||||
def testCapabilities(self):
|
def testCapabilities(self):
|
||||||
u = ircdb.IrcUser()
|
u = ircdb.IrcUser()
|
||||||
u.addCapability('foo')
|
u.addCapability('foo')
|
||||||
self.failUnless(u.checkCapability('foo'))
|
self.failUnless(u._checkCapability('foo'))
|
||||||
self.failIf(u.checkCapability('-foo'))
|
self.failIf(u._checkCapability('-foo'))
|
||||||
u.addCapability('-bar')
|
u.addCapability('-bar')
|
||||||
self.failUnless(u.checkCapability('-bar'))
|
self.failUnless(u._checkCapability('-bar'))
|
||||||
self.failIf(u.checkCapability('bar'))
|
self.failIf(u._checkCapability('bar'))
|
||||||
u.removeCapability('foo')
|
u.removeCapability('foo')
|
||||||
u.removeCapability('-bar')
|
u.removeCapability('-bar')
|
||||||
self.assertRaises(KeyError, u.checkCapability, 'foo')
|
self.assertRaises(KeyError, u._checkCapability, 'foo')
|
||||||
self.assertRaises(KeyError, u.checkCapability, '-bar')
|
self.assertRaises(KeyError, u._checkCapability, '-bar')
|
||||||
|
|
||||||
def testAddhostmask(self):
|
def testAddhostmask(self):
|
||||||
u = ircdb.IrcUser()
|
u = ircdb.IrcUser()
|
||||||
@ -228,12 +228,12 @@ class IrcUserTestCase(IrcdbTestCase):
|
|||||||
def testOwner(self):
|
def testOwner(self):
|
||||||
u = ircdb.IrcUser()
|
u = ircdb.IrcUser()
|
||||||
u.addCapability('owner')
|
u.addCapability('owner')
|
||||||
self.failUnless(u.checkCapability('foo'))
|
self.failUnless(u._checkCapability('foo'))
|
||||||
self.failIf(u.checkCapability('-foo'))
|
self.failIf(u._checkCapability('-foo'))
|
||||||
|
|
||||||
def testInitCapabilities(self):
|
def testInitCapabilities(self):
|
||||||
u = ircdb.IrcUser(capabilities=['foo'])
|
u = ircdb.IrcUser(capabilities=['foo'])
|
||||||
self.failUnless(u.checkCapability('foo'))
|
self.failUnless(u._checkCapability('foo'))
|
||||||
|
|
||||||
def testPassword(self):
|
def testPassword(self):
|
||||||
u = ircdb.IrcUser()
|
u = ircdb.IrcUser()
|
||||||
@ -294,8 +294,8 @@ class IrcUserTestCase(IrcdbTestCase):
|
|||||||
|
|
||||||
def testIgnore(self):
|
def testIgnore(self):
|
||||||
u = ircdb.IrcUser(ignore=True)
|
u = ircdb.IrcUser(ignore=True)
|
||||||
self.failIf(u.checkCapability('foo'))
|
self.failIf(u._checkCapability('foo'))
|
||||||
self.failUnless(u.checkCapability('-foo'))
|
self.failUnless(u._checkCapability('-foo'))
|
||||||
|
|
||||||
def testRemoveCapability(self):
|
def testRemoveCapability(self):
|
||||||
u = ircdb.IrcUser(capabilities=('foo',))
|
u = ircdb.IrcUser(capabilities=('foo',))
|
||||||
@ -304,27 +304,27 @@ class IrcUserTestCase(IrcdbTestCase):
|
|||||||
class IrcChannelTestCase(IrcdbTestCase):
|
class IrcChannelTestCase(IrcdbTestCase):
|
||||||
def testInit(self):
|
def testInit(self):
|
||||||
c = ircdb.IrcChannel()
|
c = ircdb.IrcChannel()
|
||||||
self.failIf(c.checkCapability('op'))
|
self.failIf(c._checkCapability('op'))
|
||||||
self.failIf(c.checkCapability('voice'))
|
self.failIf(c._checkCapability('voice'))
|
||||||
self.failIf(c.checkCapability('halfop'))
|
self.failIf(c._checkCapability('halfop'))
|
||||||
self.failIf(c.checkCapability('protected'))
|
self.failIf(c._checkCapability('protected'))
|
||||||
|
|
||||||
def testCapabilities(self):
|
def testCapabilities(self):
|
||||||
c = ircdb.IrcChannel(defaultAllow=False)
|
c = ircdb.IrcChannel(defaultAllow=False)
|
||||||
self.failIf(c.checkCapability('foo'))
|
self.failIf(c._checkCapability('foo'))
|
||||||
c.addCapability('foo')
|
c.addCapability('foo')
|
||||||
self.failUnless(c.checkCapability('foo'))
|
self.failUnless(c._checkCapability('foo'))
|
||||||
c.removeCapability('foo')
|
c.removeCapability('foo')
|
||||||
self.failIf(c.checkCapability('foo'))
|
self.failIf(c._checkCapability('foo'))
|
||||||
|
|
||||||
def testDefaultCapability(self):
|
def testDefaultCapability(self):
|
||||||
c = ircdb.IrcChannel()
|
c = ircdb.IrcChannel()
|
||||||
c.setDefaultCapability(False)
|
c.setDefaultCapability(False)
|
||||||
self.failIf(c.checkCapability('foo'))
|
self.failIf(c._checkCapability('foo'))
|
||||||
self.failUnless(c.checkCapability('-foo'))
|
self.failUnless(c._checkCapability('-foo'))
|
||||||
c.setDefaultCapability(True)
|
c.setDefaultCapability(True)
|
||||||
self.failUnless(c.checkCapability('foo'))
|
self.failUnless(c._checkCapability('foo'))
|
||||||
self.failIf(c.checkCapability('-foo'))
|
self.failIf(c._checkCapability('-foo'))
|
||||||
|
|
||||||
def testLobotomized(self):
|
def testLobotomized(self):
|
||||||
c = ircdb.IrcChannel(lobotomized=True)
|
c = ircdb.IrcChannel(lobotomized=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user