Added registry.split.

This commit is contained in:
Jeremy Fincher 2004-07-24 21:40:47 +00:00
parent 191fe6e96b
commit 3f08089a32
3 changed files with 8 additions and 4 deletions

View File

@ -56,7 +56,7 @@ class InvalidRegistryName(callbacks.Error):
pass pass
def getWrapper(name): def getWrapper(name):
parts = name.split('.') parts = registry.split(name)
if not parts or parts[0] not in ('supybot', 'users'): if not parts or parts[0] not in ('supybot', 'users'):
raise InvalidRegistryName, name raise InvalidRegistryName, name
group = getattr(conf, parts.pop(0)) group = getattr(conf, parts.pop(0))
@ -69,7 +69,7 @@ def getWrapper(name):
def getCapability(name): def getCapability(name):
capability = 'owner' # Default to requiring the owner capability. capability = 'owner' # Default to requiring the owner capability.
parts = name.split('.') parts = registry.split(name)
while parts: while parts:
part = parts.pop() part = parts.pop()
if ircutils.isChannel(part): if ircutils.isChannel(part):

View File

@ -190,7 +190,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
for (name, s) in registry._cache.iteritems(): for (name, s) in registry._cache.iteritems():
if name.startswith('supybot.plugins'): if name.startswith('supybot.plugins'):
try: try:
(_, _, name) = name.split('.') (_, _, name) = registry.split(name)
except ValueError: # unpack list of wrong size. except ValueError: # unpack list of wrong size.
continue continue
if name == name.lower(): # This can't be right. if name == name.lower(): # This can't be right.
@ -198,7 +198,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
conf.registerPlugin(name) conf.registerPlugin(name)
if name.startswith('supybot.commands.defaultPlugins'): if name.startswith('supybot.commands.defaultPlugins'):
try: try:
(_, _, _, name) = name.split('.') (_, _, _, name) = registry.split(name)
except ValueError: # unpack list of wrong size. except ValueError: # unpack list of wrong size.
continue continue
registerDefaultPlugin(name, s) registerDefaultPlugin(name, s)

View File

@ -109,6 +109,10 @@ def close(registry, filename, annotated=True, helpOnceOnly=False):
def isValidRegistryName(name): def isValidRegistryName(name):
return '.' not in name and ':' not in name and len(name.split()) == 1 return '.' not in name and ':' not in name and len(name.split()) == 1
def split(name):
# XXX: This should eventually handle escapes.
return name.split('.')
class Group(object): class Group(object):
def __init__(self, supplyDefault=False): def __init__(self, supplyDefault=False):
self.name = 'unset' self.name = 'unset'