mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Decreased size of checkCapability by moving some duplicated code out to another function with no good name.
This commit is contained in:
parent
2456082661
commit
35d0a3cb22
31
src/ircdb.py
31
src/ircdb.py
@ -489,14 +489,17 @@ def checkIgnored(hostmask, recipient='', users=users, channels=channels):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _x(capability, ret):
|
||||||
|
if isAntiCapability(capability):
|
||||||
|
return not ret
|
||||||
|
else:
|
||||||
|
return ret
|
||||||
|
|
||||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||||
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
||||||
if world.startup:
|
if world.startup:
|
||||||
#debug.printf('world.startup is active.')
|
#debug.printf('world.startup is active.')
|
||||||
if isAntiCapability(capability):
|
return _x(capability, True)
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
|
||||||
try:
|
try:
|
||||||
u = users.getUser(hostmask)
|
u = users.getUser(hostmask)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -511,10 +514,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
return c.checkCapability(capability)
|
return c.checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
#debug.printf('capability not in c.capabilities')
|
#debug.printf('capability not in c.capabilities')
|
||||||
if isAntiCapability(capability):
|
return _x(capability, c.defaultAllow)
|
||||||
return not c.defaultAllow
|
|
||||||
else:
|
|
||||||
return c.defaultAllow
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
#debug.printf('no such channel %s' % channel)
|
#debug.printf('no such channel %s' % channel)
|
||||||
pass
|
pass
|
||||||
@ -526,10 +526,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
#debug.printf('returning appropriate value given no good reason')
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
if isAntiCapability(capability):
|
return _x(capability, conf.defaultAllow)
|
||||||
return not conf.defaultAllow
|
|
||||||
else:
|
|
||||||
return conf.defaultAllow
|
|
||||||
#debug.printf('user found.')
|
#debug.printf('user found.')
|
||||||
if capability in u.capabilities:
|
if capability in u.capabilities:
|
||||||
#debug.printf('found capability in u.capabilities.')
|
#debug.printf('found capability in u.capabilities.')
|
||||||
@ -546,10 +543,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
return c.checkCapability(capability)
|
return c.checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
#debug.printf('capability not in c.capabilities')
|
#debug.printf('capability not in c.capabilities')
|
||||||
if isAntiCapability(capability):
|
return _x(capability, c.defaultAllow)
|
||||||
return not c.defaultAllow
|
|
||||||
else:
|
|
||||||
return c.defaultAllow
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
#debug.printf('no such channel %s' % channel)
|
#debug.printf('no such channel %s' % channel)
|
||||||
pass
|
pass
|
||||||
@ -561,10 +555,7 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
#debug.printf('returning appropriate value given no good reason')
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
if isAntiCapability(capability):
|
return _x(capability, conf.defaultAllow)
|
||||||
return not conf.defaultAllow
|
|
||||||
else:
|
|
||||||
return conf.defaultAllow
|
|
||||||
|
|
||||||
|
|
||||||
def checkCapabilities(hostmask, capabilities, requireAll=False):
|
def checkCapabilities(hostmask, capabilities, requireAll=False):
|
||||||
|
Loading…
Reference in New Issue
Block a user