improvements to the doc strings

This commit is contained in:
Damien Churchill 2009-05-11 19:31:29 +00:00
commit 901038b3c2

View file

@ -282,13 +282,27 @@ class WebApi(JSONComponent):
super(WebApi, self).__init__("Web") super(WebApi, self).__init__("Web")
self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS) self.host_list = ConfigManager("hostlist.conf.1.2", DEFAULT_HOSTS)
def get_host(self, connection_id): def get_host(self, host_id):
"""
Return the information about a host
:param host_id: str, the id of the host
:returns: the host information
:rtype: list
"""
for host in self.host_list["hosts"]: for host in self.host_list["hosts"]:
if host[0] == connection_id: if host[0] == host_id:
return host return host
@export @export
def connect(self, host_id): def connect(self, host_id):
"""
Connect the client to a daemon
:param host_id: str, the id of the daemon in the host list
:returns: the methods the daemon supports
:rtype: list
"""
d = Deferred() d = Deferred()
def on_connected(methods): def on_connected(methods):
d.callback(methods) d.callback(methods)
@ -300,12 +314,21 @@ class WebApi(JSONComponent):
@export @export
def connected(self): def connected(self):
"""
The current connection state.
:returns: True if the client is connected
:rtype: bool
"""
d = Deferred() d = Deferred()
d.callback(client.connected()) d.callback(client.connected())
return d return d
@export @export
def disconnect(self): def disconnect(self):
"""
Disconnect the web interface from the connected daemon.
"""
d = Deferred() d = Deferred()
client.disconnect() client.disconnect()
d.callback(True) d.callback(True)
@ -313,7 +336,14 @@ class WebApi(JSONComponent):
@export @export
def update_ui(self, keys, filter_dict): def update_ui(self, keys, filter_dict):
"""
Gather the information required for updating the web interface.
:param keys: list, the information about the torrents to gather
:param filter_dict: dict, the filters to apply when selecting torrents.
:returns: The torrent and ui information.
:rtype: dict
"""
ui_info = { ui_info = {
"torrents": None, "torrents": None,
"filters": None, "filters": None,
@ -381,11 +411,11 @@ class WebApi(JSONComponent):
@export @export
def download_torrent_from_url(self, url): def download_torrent_from_url(self, url):
""" """
input: Download a torrent file from a url to a temporary directory.
url: the url of the torrent to download
returns: :param url: str, the url of the torrent
filename: the temporary file name of the torrent file :returns: the temporary file name of the torrent file
:rtype: str
""" """
tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1]) tmp_file = os.path.join(tempfile.gettempdir(), url.split("/")[-1])
filename, headers = urllib.urlretrieve(url, tmp_file) filename, headers = urllib.urlretrieve(url, tmp_file)
@ -397,13 +427,10 @@ class WebApi(JSONComponent):
@export @export
def get_torrent_info(self, filename): def get_torrent_info(self, filename):
""" """
Goal: Return information about a torrent on the filesystem.
allow the webui to retrieve data about the torrent
input: :param filename: str, the path to the torrent
filename: the filename of the torrent to gather info about :returns:
returns:
{ {
"filename": the torrent file "filename": the torrent file
"name": the torrent name "name": the torrent name
@ -423,11 +450,10 @@ class WebApi(JSONComponent):
@export @export
def add_torrents(self, torrents): def add_torrents(self, torrents):
""" """
input: Add torrents by file
torrents [{
path: the path of the torrent file, :param torrents: dict, a list of dictionaries containing the torrent
options: the torrent options path and torrent options to add with.
}]
""" """
for torrent in torrents: for torrent in torrents:
filename = os.path.basename(torrent["path"]) filename = os.path.basename(torrent["path"])