summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2014-02-14 12:41:58 -0400
committerKali Kaneko <kali@leap.se>2014-02-17 11:39:50 -0400
commit45733a231128cc06e123f352b4eb9886d6820878 (patch)
tree498dd8fe3f1db509367d9424606750022aa3224d
parent7eba9d5badcd3ebbdb746e6598ce452a8d9b7649 (diff)
docstring fixes
-rw-r--r--src/leap/mail/imap/mailbox.py2
-rw-r--r--src/leap/mail/imap/memorystore.py27
-rw-r--r--src/leap/mail/imap/service/imap.py4
-rw-r--r--src/leap/mail/imap/soledadstore.py3
4 files changed, 24 insertions, 12 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 045de82..d55cae6 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -895,6 +895,8 @@ class SoledadMailbox(WithMsgFields, MBoxParser):
Get a copy of the fdoc for this message, and check whether
it already exists.
+ :param message: an IMessage implementor
+ :type message: LeapMessage
:return: exist, new_fdoc
:rtype: tuple
"""
diff --git a/src/leap/mail/imap/memorystore.py b/src/leap/mail/imap/memorystore.py
index 1e4262a..53b8d99 100644
--- a/src/leap/mail/imap/memorystore.py
+++ b/src/leap/mail/imap/memorystore.py
@@ -25,6 +25,7 @@ import weakref
from collections import defaultdict
from copy import copy
+from enum import Enum
from twisted.internet import defer
from twisted.internet.task import LoopingCall
from twisted.python import log
@@ -69,6 +70,9 @@ def set_bool_flag(obj, att):
setattr(obj, att, False)
+DirtyState = Enum("none", "dirty", "new")
+
+
class MemoryStore(object):
"""
An in-memory store to where we can write the different parts that
@@ -293,7 +297,6 @@ class MemoryStore(object):
# a defer that will inmediately have its callback triggered.
self.reactor.callFromThread(observer.callback, uid)
-
def put_message(self, mbox, uid, message, notify_on_disk=True):
"""
Put an existing message.
@@ -407,7 +410,8 @@ class MemoryStore(object):
return doc_id
- def get_message(self, mbox, uid, dirtystate="none", flags_only=False):
+ def get_message(self, mbox, uid, dirtystate=DirtyState.none,
+ flags_only=False):
"""
Get a MessageWrapper for the given mbox and uid combination.
@@ -415,8 +419,9 @@ class MemoryStore(object):
:type mbox: str or unicode
:param uid: the message UID
:type uid: int
- :param dirtystate: one of `dirty`, `new` or `none` (default)
- :type dirtystate: str
+ :param dirtystate: DirtyState enum: one of `dirty`, `new`
+ or `none` (default)
+ :type dirtystate: enum
:param flags_only: whether the message should carry only a reference
to the flags document.
:type flags_only: bool
@@ -424,7 +429,7 @@ class MemoryStore(object):
:return: MessageWrapper or None
"""
- if dirtystate == "dirty":
+ if dirtystate == DirtyState.dirty:
flags_only = True
key = mbox, uid
@@ -434,11 +439,11 @@ class MemoryStore(object):
return None
new, dirty = False, False
- if dirtystate == "none":
+ if dirtystate == DirtyState.none:
new, dirty = self._get_new_dirty_state(key)
- if dirtystate == "dirty":
+ if dirtystate == DirtyState.dirty:
new, dirty = False, True
- if dirtystate == "new":
+ if dirtystate == DirtyState.new:
new, dirty = True, False
if flags_only:
@@ -514,6 +519,7 @@ class MemoryStore(object):
Write the message documents in this MemoryStore to a different store.
:param store: the IMessageStore to write to
+ :rtype: False if queue is not empty, None otherwise.
"""
# For now, we pass if the queue is not empty, to avoid duplicate
# queuing.
@@ -880,7 +886,7 @@ class MemoryStore(object):
:rtype: generator
"""
gm = self.get_message
- new = [gm(*key) for key in self._new]
+ new = [gm(*key, dirtystate=DirtyState.new) for key in self._new]
# move content from new set to the queue
self._new_queue.update(self._new)
self._new.difference_update(self._new)
@@ -894,7 +900,8 @@ class MemoryStore(object):
:rtype: generator
"""
gm = self.get_message
- dirty = [gm(*key, flags_only=True) for key in self._dirty]
+ dirty = [gm(*key, flags_only=True, dirtystate=DirtyState.dirty)
+ for key in self._dirty]
# move content from new and dirty sets to the queue
self._dirty_queue.update(self._dirty)
diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py
index a7799ca..b79d42d 100644
--- a/src/leap/mail/imap/service/imap.py
+++ b/src/leap/mail/imap/service/imap.py
@@ -118,8 +118,8 @@ class LeapIMAPFactory(ServerFactory):
"""
Return a protocol suitable for the job.
- :param addr: ???
- :type addr: ???
+ :param addr: remote ip address
+ :type addr: str
"""
imapProtocol = LeapIMAPServer(
uuid=self._uuid,
diff --git a/src/leap/mail/imap/soledadstore.py b/src/leap/mail/imap/soledadstore.py
index 6d6d382..e1a278a 100644
--- a/src/leap/mail/imap/soledadstore.py
+++ b/src/leap/mail/imap/soledadstore.py
@@ -295,9 +295,12 @@ class SoledadStore(ContentDedup):
def _soledad_write_document_parts(self, items):
"""
Write the document parts to soledad in a separate thread.
+
:param items: the iterator through the different document wrappers
payloads.
:type items: iterator
+ :return: whether the write was successful or not
+ :rtype: bool
"""
failed = False
for item, call in items: