# HG changeset patch # User Ben Croston # Date 1315222925 -3600 # Node ID 21eb67081c4331f16ed4cafd037d4ef2c3193251 # Parent 4ac14cfadc15aa8de94dff40ef3bce218bf0dbe9 Added docstrings diff -r 4ac14cfadc15 -r 21eb67081c43 wibble/client/__init__.py --- a/wibble/client/__init__.py Mon Sep 05 12:29:08 2011 +0100 +++ b/wibble/client/__init__.py Mon Sep 05 12:42:05 2011 +0100 @@ -80,7 +80,7 @@ 'Accept':'application/json'} def __init__(self, uri, proxy_uri=None, user_agent=None): - self.headers['User-Agent'] = user_agent if user_agent is not None else 'jsonrpclib' + self.headers['User-Agent'] = user_agent if user_agent is not None else 'wibble' if proxy_uri is not None: self.connection_url = urlparse(proxy_uri) self.request_path = uri @@ -136,13 +136,19 @@ Exception.__init__(self,'HTTP 502 - Bad Gateway') class ServerProxy(object): - def __init__(self, uri=None, transport=None, proxy_uri=None, user_agent=None, username=None, password=None): - if uri is None and transport is None: - raise Exception('either uri or transport needs to be specified') - - if transport is None: - transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) - self.__transport = transport + """ + A client class to communicate with a wibble server + """ + def __init__(self, uri, proxy_uri=None, user_agent=None, username=None, password=None): + """ + uri - the URI of a corresponding wibble server + proxy_uri - the http proxy to use, if any + user_agent - user agent to be used (can be used as part of authentication) + username - username to use in requests + password - password to use in requests + """ + assert uri is not None + self.__transport = _JSONRPCTransport(uri, proxy_uri=proxy_uri, user_agent=user_agent) self._username = username self._password = password