summaryrefslogtreecommitdiff
path: root/client/src
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-08-20 14:46:25 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-08-26 17:20:22 -0300
commitd1b47b03661be1341cbaf28c2f37663b50ba24f9 (patch)
treef015dfee2851470a4c26151305454282a5744f32 /client/src
parent8654021f8719cf9d0f17f9d58e4455074aa43bb9 (diff)
[docs] Fix docstrings
There were some missing or on incorrect format (sphinx) as drebs and kaliy pointed out.
Diffstat (limited to 'client/src')
-rw-r--r--client/src/leap/soledad/client/http_target/api.py50
-rw-r--r--client/src/leap/soledad/client/http_target/fetch.py8
-rw-r--r--client/src/leap/soledad/client/http_target/send.py4
-rw-r--r--client/src/leap/soledad/client/http_target/support.py25
4 files changed, 33 insertions, 54 deletions
diff --git a/client/src/leap/soledad/client/http_target/api.py b/client/src/leap/soledad/client/http_target/api.py
index 344d999c..d83250ee 100644
--- a/client/src/leap/soledad/client/http_target/api.py
+++ b/client/src/leap/soledad/client/http_target/api.py
@@ -26,55 +26,11 @@ from twisted.internet import defer
from leap.soledad.common.errors import InvalidAuthTokenError
from leap.soledad.client.http_target.support import readBody
-from leap.common.http import HTTPClient
-
class SyncTargetAPI(SyncTarget):
-
- def __init__(self, url, source_replica_uid, creds, crypto, cert_file,
- sync_db=None, sync_enc_pool=None):
- """
- Initialize the sync target.
-
- :param url: The server sync url.
- :type url: str
- :param source_replica_uid: The source replica uid which we use when
- deferring decryption.
- :type source_replica_uid: str
- :param creds: A dictionary containing the uuid and token.
- :type creds: creds
- :param crypto: An instance of SoledadCrypto so we can encrypt/decrypt
- document contents when syncing.
- :type crypto: soledad.crypto.SoledadCrypto
- :param cert_file: Path to the certificate of the ca used to validate
- the SSL certificate used by the remote soledad
- server.
- :type cert_file: str
- :param sync_db: Optional. handler for the db with the symmetric
- encryption of the syncing documents. If
- None, encryption will be done in-place,
- instead of retreiving it from the dedicated
- database.
- :type sync_db: Sqlite handler
- :param sync_enc_pool: The encryption pool to use to defer encryption.
- If None is passed the encryption will not be
- deferred.
- :type sync_enc_pool: leap.soledad.client.encdecpool.SyncEncrypterPool
- """
- if url.endswith("/"):
- url = url[:-1]
- self._url = str(url) + "/sync-from/" + str(source_replica_uid)
- self.source_replica_uid = source_replica_uid
- self._auth_header = None
- self.set_creds(creds)
- self._crypto = crypto
- self._sync_db = sync_db
- self._sync_enc_pool = sync_enc_pool
- self._insert_doc_cb = None
- # asynchronous encryption/decryption attributes
- self._decryption_callback = None
- self._sync_decr_pool = None
- self._http = HTTPClient(cert_file)
+ """
+ Declares public methods and implements u1db.SyncTarget.
+ """
def close(self):
self._http.close()
diff --git a/client/src/leap/soledad/client/http_target/fetch.py b/client/src/leap/soledad/client/http_target/fetch.py
index aa02063a..a991d2a2 100644
--- a/client/src/leap/soledad/client/http_target/fetch.py
+++ b/client/src/leap/soledad/client/http_target/fetch.py
@@ -30,6 +30,14 @@ logger = logging.getLogger(__name__)
class HTTPDocFetcher(object):
+ """
+ Handles Document fetching from Soledad server, using HTTP as transport.
+ Steps:
+ * Prepares metadata by asking server for one document
+ * Fetch the total on response and prepare to ask all remaining
+ * (async) Documents will come encrypted.
+ So we parse, decrypt and insert locally as they arrive.
+ """
@defer.inlineCallbacks
def _receive_docs(self, last_known_generation, last_known_trans_id,
diff --git a/client/src/leap/soledad/client/http_target/send.py b/client/src/leap/soledad/client/http_target/send.py
index a6e64908..fe3a753f 100644
--- a/client/src/leap/soledad/client/http_target/send.py
+++ b/client/src/leap/soledad/client/http_target/send.py
@@ -24,6 +24,10 @@ logger = logging.getLogger(__name__)
class HTTPDocSender(object):
+ """
+ Handles Document uploading from Soledad server, using HTTP as transport.
+ They need to be encrypted and metadata prepared before sending.
+ """
@defer.inlineCallbacks
def _send_docs(self, docs_by_generation, last_known_generation,
diff --git a/client/src/leap/soledad/client/http_target/support.py b/client/src/leap/soledad/client/http_target/support.py
index 363a4f7d..5daabb61 100644
--- a/client/src/leap/soledad/client/http_target/support.py
+++ b/client/src/leap/soledad/client/http_target/support.py
@@ -31,6 +31,10 @@ from twisted.web._newclient import PotentialDataLoss
# client below.
class ReadBodyProtocol(_ReadBodyProtocol):
+ """
+ From original Twisted implementation, focused on adding our error
+ handling and ensuring that the proper u1db error is raised.
+ """
def __init__(self, response, deferred):
"""
@@ -143,7 +147,8 @@ class RequestBody(object):
"""
Creates a new RequestBody holding header information.
- @param header_dict: A dictionary with the headers.
+ :param header_dict: A dictionary with the headers.
+ :type header_dict: dict
"""
self.headers = header_dict
self.entries = []
@@ -152,9 +157,11 @@ class RequestBody(object):
"""
Dumps an entry into JSON format and add it to entries list.
- @param entry_dicts: Entry as a dictionary
+ :param entry_dict: Entry as a dictionary
+ :type entry_dict: dict
- @return: length of the entry after JSON dumps
+ :return: length of the entry after JSON dumps
+ :rtype: int
"""
entry = json.dumps(entry_dict)
self.entries.append(entry)
@@ -165,9 +172,11 @@ class RequestBody(object):
Removes an amount of entries and returns it formatted and ready
to be sent.
- @param number: number of entries to remove and format
+ :param number: number of entries to remove and format
+ :type number: int
- @return: formatted body ready to be sent
+ :return: formatted body ready to be sent
+ :rtype: str
"""
entries = [self.entries.pop(0) for i in xrange(number)]
return self.entries_to_str(entries)
@@ -183,9 +192,11 @@ class RequestBody(object):
Format a list of entries into the body format expected
by the server.
- @param entries: entries to format
+ :param entries: entries to format
+ :type entries: list
- @return: formatted body ready to be sent
+ :return: formatted body ready to be sent
+ :rtype: str
"""
data = '[\r\n' + json.dumps(self.headers)
data += ''.join(',\r\n' + entry for entry in entries)