summaryrefslogtreecommitdiff
path: root/src/leap/mx/mail_receiver.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-10-16 11:59:33 -0300
committerTomás Touceda <chiiph@leap.se>2013-10-16 11:59:33 -0300
commitcd550b38686d6772aa7b1ae64c1fcdac5a22251d (patch)
treed7c9c5add741e944b1d80d898a5295a1035f8c7b /src/leap/mx/mail_receiver.py
parentbf74c7720808ae4a0a94ea80439bea08e1441acd (diff)
parentbc2fea9affe64ffc157cb70eec68bfd776dad76f (diff)
Merge remote-tracking branch 'kali/fix-pep8' into develop
Diffstat (limited to 'src/leap/mx/mail_receiver.py')
-rw-r--r--src/leap/mx/mail_receiver.py81
1 files changed, 40 insertions, 41 deletions
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 5875034..e263604 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -15,11 +15,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
MailReceiver service definition
"""
-
import os
import uuid as pyuuid
@@ -54,14 +52,14 @@ class MailReceiver(Service):
"""
Constructor
- @param mail_couch_url: URL prefix for the couchdb where mail
+ :param mail_couch_url: URL prefix for the couchdb where mail
should be stored
- @type mail_couch_url: str
- @param users_cdb: CouchDB instance from where to get the uuid
+ :type mail_couch_url: str
+ :param users_cdb: CouchDB instance from where to get the uuid
and pubkey for a user
- @type users_cdb: ConnectedCouchDB
- @param directories: list of directories to monitor
- @type directories: list of tuples (path: str, recursive: bool)
+ :type users_cdb: ConnectedCouchDB
+ :param directories: list of directories to monitor
+ :type directories: list of tuples (path: str, recursive: bool)
"""
# Service doesn't define an __init__
self._mail_couch_url = mail_couch_url
@@ -105,16 +103,17 @@ class MailReceiver(Service):
the message to that public key.
The address is needed in order to build the OpenPGPKey object.
- @param uuid_pubkey: tuple that holds the uuid and the public
- key as it is returned by the previous call in the chain
- @type uuid_pubkey: tuple (str, str)
- @param address: mail address for this message
- @type address: str
- @param message: message contents
- @type message: str
-
- @return: uuid, doc to sync with Soledad
- @rtype: tuple(str, SoledadDocument)
+ :param uuid_pubkey: tuple that holds the uuid and the public
+ key as it is returned by the previous call in the
+ chain
+ :type uuid_pubkey: tuple (str, str)
+ :param address: mail address for this message
+ :type address: str
+ :param message: message contents
+ :type message: str
+
+ :return: uuid, doc to sync with Soledad
+ :rtype: tuple(str, SoledadDocument)
"""
uuid, pubkey = uuid_pubkey
log.msg("Encrypting message to %s's pubkey" % (uuid,))
@@ -153,14 +152,14 @@ class MailReceiver(Service):
"""
Given a UUID and a SoledadDocument, it saves it directly in the
couchdb that serves as a backend for Soledad, in a db
- accessible to the recipient of the mail
+ accessible to the recipient of the mail.
- @param uuid_doc: tuple that holds the UUID and SoledadDocument
- @type uuid_doc: tuple(str, SoledadDocument)
+ :param uuid_doc: tuple that holds the UUID and SoledadDocument
+ :type uuid_doc: tuple(str, SoledadDocument)
- @return: True if it's ok to remove the message, False
- otherwise
- @rtype: bool
+ :return: True if it's ok to remove the message, False
+ otherwise
+ :rtype: bool
"""
uuid, doc = uuid_doc
log.msg("Exporting message for %s" % (uuid,))
@@ -177,13 +176,13 @@ class MailReceiver(Service):
def _conditional_remove(self, do_remove, filepath):
"""
- Removes the message if do_remove is True
+ Removes the message if do_remove is True.
- @param do_remove: True if the message should be removed, False
- otherwise
- @type do_remove: bool
- @param filepath: path to the mail
- @type filepath: twisted.python.filepath.FilePath
+ :param do_remove: True if the message should be removed, False
+ otherwise
+ :type do_remove: bool
+ :param filepath: path to the mail
+ :type filepath: twisted.python.filepath.FilePath
"""
if do_remove:
# remove the original mail
@@ -196,18 +195,18 @@ class MailReceiver(Service):
def _process_incoming_email(self, otherself, filepath, mask):
"""
- Callback that processes incoming email
-
- @param otherself: Watch object for the current callback from
- inotify
- @type otherself: twisted.internet.inotify._Watch
- @param filepath: Path of the file that changed
- @type filepath: twisted.python.filepath.FilePath
- @param mask: identifier for the type of change that triggered
- this callback
- @type mask: int
+ Callback that processes incoming email.
+
+ :param otherself: Watch object for the current callback from
+ inotify.
+ :type otherself: twisted.internet.inotify._Watch
+ :param filepath: Path of the file that changed
+ :type filepath: twisted.python.filepath.FilePath
+ :param mask: identifier for the type of change that triggered
+ this callback
+ :type mask: int
"""
- if os.path.split(filepath.dirname())[-1] == "new":
+ if os.path.split(filepath.dirname())[-1] == "new":
log.msg("Processing new mail at %s" % (filepath.path,))
with filepath.open("r") as f:
mail_data = f.read()