Raise a KeyError exception if trying to stop a component that hasn't

isn't registered
This commit is contained in:
Andrew Resch 2010-03-24 22:52:03 -07:00
parent c8f2173a04
commit 78f9f22a40
1 changed files with 10 additions and 1 deletions

View File

@ -252,11 +252,20 @@ class ComponentRegistry(object):
sucessfully stopped
:rtype: twisted.internet.defer.Deferred
:raises KeyError: if a component name is not registered
"""
if not names:
names = self.components.keys()
elif isinstance(names, str):
names = [names]
if names in self.components:
names = [names]
else:
raise KeyError("%s is not a registered component!" % names)
for name in names:
if name is not in self.components:
raise KeyError("%s is not a registered component!" % name)
deferreds = []