Changed some non-public checkCapability methods to be prefixed with an underscore.

This commit is contained in:
Jeremy Fincher 2004-12-27 06:58:26 +00:00
parent dae2a02231
commit 6002089619
2 changed files with 29 additions and 29 deletions

View File

@ -242,7 +242,7 @@ class IrcUser(object):
"""Takes from the user the given capability."""
self.capabilities.remove(capability)
def checkCapability(self, capability):
def _checkCapability(self, capability):
"""Checks the user for a given capability."""
if self.ignore:
if isAntiCapability(capability):
@ -404,7 +404,7 @@ class IrcChannel(object):
"""Sets the default capability in the channel."""
self.defaultAllow = b
def checkCapability(self, capability):
def _checkCapability(self, capability):
"""Checks whether a certain capability is allowed by the channel."""
assert isCapability(capability), 'got %s' % capability
if capability in self.capabilities:
@ -969,7 +969,7 @@ def checkIgnored(hostmask, recipient='', users=users, channels=channels):
return True
else:
return False
if user.checkCapability('owner'):
if user._checkCapability('owner'):
# Owners shouldn't ever be ignored.
return False
elif user.ignore:
@ -1000,7 +1000,7 @@ def _checkCapabilityForUnknownUser(capability, users=users, channels=channels):
try:
c = channels.getChannel(channel)
if capability in c.capabilities:
return c.checkCapability(capability)
return c._checkCapability(capability)
else:
return _x(capability, c.defaultAllow)
except KeyError:
@ -1030,19 +1030,19 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
return _checkCapabilityForUnknownUser(capability, users=users,
channels=channels)
if capability in u.capabilities:
return u.checkCapability(capability)
return u._checkCapability(capability)
else:
if isChannelCapability(capability):
(channel, capability) = fromChannelCapability(capability)
try:
chanop = makeChannelCapability(channel, 'op')
if u.checkCapability(chanop):
if u._checkCapability(chanop):
return _x(capability, True)
except KeyError:
pass
c = channels.getChannel(channel)
if capability in c.capabilities:
return c.checkCapability(capability)
return c._checkCapability(capability)
else:
return _x(capability, c.defaultAllow)
defaultCapabilities = conf.supybot.capabilities()

View File

@ -203,15 +203,15 @@ class IrcUserTestCase(IrcdbTestCase):
def testCapabilities(self):
u = ircdb.IrcUser()
u.addCapability('foo')
self.failUnless(u.checkCapability('foo'))
self.failIf(u.checkCapability('-foo'))
self.failUnless(u._checkCapability('foo'))
self.failIf(u._checkCapability('-foo'))
u.addCapability('-bar')
self.failUnless(u.checkCapability('-bar'))
self.failIf(u.checkCapability('bar'))
self.failUnless(u._checkCapability('-bar'))
self.failIf(u._checkCapability('bar'))
u.removeCapability('foo')
u.removeCapability('-bar')
self.assertRaises(KeyError, u.checkCapability, 'foo')
self.assertRaises(KeyError, u.checkCapability, '-bar')
self.assertRaises(KeyError, u._checkCapability, 'foo')
self.assertRaises(KeyError, u._checkCapability, '-bar')
def testAddhostmask(self):
u = ircdb.IrcUser()
@ -228,12 +228,12 @@ class IrcUserTestCase(IrcdbTestCase):
def testOwner(self):
u = ircdb.IrcUser()
u.addCapability('owner')
self.failUnless(u.checkCapability('foo'))
self.failIf(u.checkCapability('-foo'))
self.failUnless(u._checkCapability('foo'))
self.failIf(u._checkCapability('-foo'))
def testInitCapabilities(self):
u = ircdb.IrcUser(capabilities=['foo'])
self.failUnless(u.checkCapability('foo'))
self.failUnless(u._checkCapability('foo'))
def testPassword(self):
u = ircdb.IrcUser()
@ -294,8 +294,8 @@ class IrcUserTestCase(IrcdbTestCase):
def testIgnore(self):
u = ircdb.IrcUser(ignore=True)
self.failIf(u.checkCapability('foo'))
self.failUnless(u.checkCapability('-foo'))
self.failIf(u._checkCapability('foo'))
self.failUnless(u._checkCapability('-foo'))
def testRemoveCapability(self):
u = ircdb.IrcUser(capabilities=('foo',))
@ -304,27 +304,27 @@ class IrcUserTestCase(IrcdbTestCase):
class IrcChannelTestCase(IrcdbTestCase):
def testInit(self):
c = ircdb.IrcChannel()
self.failIf(c.checkCapability('op'))
self.failIf(c.checkCapability('voice'))
self.failIf(c.checkCapability('halfop'))
self.failIf(c.checkCapability('protected'))
self.failIf(c._checkCapability('op'))
self.failIf(c._checkCapability('voice'))
self.failIf(c._checkCapability('halfop'))
self.failIf(c._checkCapability('protected'))
def testCapabilities(self):
c = ircdb.IrcChannel(defaultAllow=False)
self.failIf(c.checkCapability('foo'))
self.failIf(c._checkCapability('foo'))
c.addCapability('foo')
self.failUnless(c.checkCapability('foo'))
self.failUnless(c._checkCapability('foo'))
c.removeCapability('foo')
self.failIf(c.checkCapability('foo'))
self.failIf(c._checkCapability('foo'))
def testDefaultCapability(self):
c = ircdb.IrcChannel()
c.setDefaultCapability(False)
self.failIf(c.checkCapability('foo'))
self.failUnless(c.checkCapability('-foo'))
self.failIf(c._checkCapability('foo'))
self.failUnless(c._checkCapability('-foo'))
c.setDefaultCapability(True)
self.failUnless(c.checkCapability('foo'))
self.failIf(c.checkCapability('-foo'))
self.failUnless(c._checkCapability('foo'))
self.failIf(c._checkCapability('-foo'))
def testLobotomized(self):
c = ircdb.IrcChannel(lobotomized=True)