Fix up some docstrings

This commit is contained in:
Andrew Resch 2010-03-25 12:01:40 -07:00
parent c978c6d016
commit e7e480cf3e
1 changed files with 15 additions and 24 deletions

View File

@ -42,28 +42,28 @@ class ComponentAlreadyRegistered(Exception):
class Component(object): class Component(object):
""" """
Component objects are singletons managed by the `:class:ComponentRegistry`. Component objects are singletons managed by the :class:`ComponentRegistry`.
When a new Component object is instantiated, it will be automatically When a new Component object is instantiated, it will be automatically
registered with the `:class:ComponentRegistry`. registered with the :class:`ComponentRegistry`.
The ComponentRegistry has the ability to start, stop, pause and shutdown the The ComponentRegistry has the ability to start, stop, pause and shutdown the
components registered with it. components registered with it.
Events: **Events:**
start() - This method is called when the client has connected to a **start()** - This method is called when the client has connected to a
Deluge core. Deluge core.
stop() - This method is called when the client has disconnected from a **stop()** - This method is called when the client has disconnected from a
Deluge core. Deluge core.
update() - This method is called every 1 second by default while the **update()** - This method is called every 1 second by default while the
Componented is in a "Started" state. The interval can be Componented is in a "Started" state. The interval can be
specified during instantiation. The update() timer can be specified during instantiation. The update() timer can be
paused by instructing the `:class:ComponentRegistry` to pause paused by instructing the :class:`ComponentRegistry` to pause
this Component. this Component.
shutdown() - This method is called when the client is exiting. If the **shutdown()** - This method is called when the client is exiting. If the
Component is in a "Started" state when this is called, a Component is in a "Started" state when this is called, a
call to stop() will be issued prior to shutdown(). call to stop() will be issued prior to shutdown().
@ -158,7 +158,7 @@ class Component(object):
class ComponentRegistry(object): class ComponentRegistry(object):
""" """
The ComponentRegistry holds a list of currently registered The ComponentRegistry holds a list of currently registered
`:class:Component` objects. It is used to manage the Components by :class:`Component` objects. It is used to manage the Components by
starting, stopping, pausing and shutting them down. starting, stopping, pausing and shutting them down.
""" """
def __init__(self): def __init__(self):
@ -205,7 +205,7 @@ class ComponentRegistry(object):
def start(self, names=[]): def start(self, names=[]):
""" """
Starts Components that are currently in a Stopped state and their Starts Components that are currently in a Stopped state and their
dependencies. If `:param:names` is specified, will only start those dependencies. If :param:`names` is specified, will only start those
Components and their dependencies and if not it will start all Components and their dependencies and if not it will start all
registered components. registered components.
@ -242,7 +242,7 @@ class ComponentRegistry(object):
def stop(self, names=[]): def stop(self, names=[]):
""" """
Stops Components that are currently not in a Stopped state. If Stops Components that are currently not in a Stopped state. If
`:param:names` is specified, then it will only stop those Components, :param:`names` is specified, then it will only stop those Components,
and if not it will stop all the registered Components. and if not it will stop all the registered Components.
:param names: a list of Components to start :param names: a list of Components to start
@ -252,20 +252,11 @@ class ComponentRegistry(object):
sucessfully stopped sucessfully stopped
:rtype: twisted.internet.defer.Deferred :rtype: twisted.internet.defer.Deferred
:raises KeyError: if a component name is not registered
""" """
if not names: if not names:
names = self.components.keys() names = self.components.keys()
elif isinstance(names, str): elif isinstance(names, str):
if names in self.components: names = [names]
names = [names]
else:
raise KeyError("%s is not a registered component!" % names)
for name in names:
if name not in self.components:
raise KeyError("%s is not a registered component!" % name)
deferreds = [] deferreds = []
@ -278,7 +269,7 @@ class ComponentRegistry(object):
def pause(self, names=[]): def pause(self, names=[]):
""" """
Pauses Components that are currently in a Started state. If Pauses Components that are currently in a Started state. If
`:param:names` is specified, then it will only pause those Components, :param:`names` is specified, then it will only pause those Components,
and if not it will pause all the registered Components. and if not it will pause all the registered Components.
:param names: a list of Components to pause :param names: a list of Components to pause
@ -305,7 +296,7 @@ class ComponentRegistry(object):
def resume(self, names=[]): def resume(self, names=[]):
""" """
Resumes Components that are currently in a Paused state. If Resumes Components that are currently in a Paused state. If
`:param:names` is specified, then it will only resume those Components, :param:`names` is specified, then it will only resume those Components,
and if not it will resume all the registered Components. and if not it will resume all the registered Components.
:param names: a list of Components to resume :param names: a list of Components to resume
@ -332,7 +323,7 @@ class ComponentRegistry(object):
def shutdown(self): def shutdown(self):
""" """
Shutdowns all Components regardless of state. This will call Shutdowns all Components regardless of state. This will call
`:meth:stop` on call the components prior to shutting down. This should :meth:`stop` on call the components prior to shutting down. This should
be called when the program is exiting to ensure all Components have a be called when the program is exiting to ensure all Components have a
chance to properly shutdown. chance to properly shutdown.