From 91ba77f5109cabd70341e8c7377fba6df565fb2d Mon Sep 17 00:00:00 2001 From: Johannes Kulick Date: Wed, 12 Dec 2012 12:48:30 +0100 Subject: pep8 corrections --- alot/commands/envelope.py | 13 +++++++------ alot/crypto.py | 10 ++++++---- alot/db/envelope.py | 7 ++++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index 086247d3..07f523ed 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -449,11 +449,13 @@ class SignCommand(Command): # reload buffer ui.current_buffer.rebuild() -@registerCommand(MODE, 'encrypt', forced={'action':'encrypt'}, arguments=[ - (['keyid'], {'help':'keyid of the key to encrypt with'})]) -@registerCommand(MODE, 'unencrypt', forced={'action':'unencrypt'}) -@registerCommand(MODE, 'toggleencrypt', forced={'action':'toggleencrypt'}, arguments=[ - (['keyid'], {'help':'keyid of the key to encrypt with'})]) + +@registerCommand(MODE, 'encrypt', forced={'action': 'encrypt'}, arguments=[ + (['keyid'], {'help': 'keyid of the key to encrypt with'})]) +@registerCommand(MODE, 'unencrypt', forced={'action': 'unencrypt'}) +@registerCommand(MODE, 'toggleencrypt', forced={'action': 'toggleencrypt'}, + arguments=[ + (['keyid'], {'help':'keyid of the key to encrypt with'})]) class EncryptCommand(Command): def __init__(self, action=None, keyid=None, **kwargs): self.encrypt_key = keyid @@ -472,4 +474,3 @@ class EncryptCommand(Command): envelope.encrypt_key = self.encrypt_key #reload buffer ui.current_buffer.rebuild() - diff --git a/alot/crypto.py b/alot/crypto.py index 2f1781f2..dfa8491f 100644 --- a/alot/crypto.py +++ b/alot/crypto.py @@ -152,9 +152,12 @@ def detached_signature_for(plaintext_str, key=None): signature = signature_data.read() return sigs, signature + def encrypt(plaintext_str, key=None): """ - Encrypts the given plaintext string and returns a PGP/MIME compatible string + Encrypts the given plaintext string and returns a PGP/MIME compatible + string + :param plaintext_str: the mail to encrypt :param key: gpgme_key_t object representing the key to use :rtype: a string holding the encrypted mail @@ -163,9 +166,8 @@ def encrypt(plaintext_str, key=None): encrypted_data = StringIO() ctx = gpgme.Context() ctx.armor = True - ctx.encrypt([key], gpgme.ENCRYPT_ALWAYS_TRUST, plaintext_data, encrypted_data) + ctx.encrypt([key], gpgme.ENCRYPT_ALWAYS_TRUST, plaintext_data, + encrypted_data) encrypted_data.seek(0, 0) encrypted = encrypted_data.read() return encrypted - - diff --git a/alot/db/envelope.py b/alot/db/envelope.py index db233832..6d0f5311 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -190,7 +190,8 @@ class Envelope(object): micalg = crypto.RFC3156_micalg_from_algo(signatures[0].hash_algo) unencrypted_msg = MIMEMultipart('signed', micalg=micalg, - protocol='application/pgp-signature') + protocol= + 'application/pgp-signature') # wrap signature in MIMEcontainter stype = 'pgp-signature; name="signature.asc"' @@ -210,7 +211,7 @@ class Envelope(object): if self.encrypt: plaintext = crypto.email_as_string(unencrypted_msg) logging.debug('encrypting plaintext: ' + plaintext) - + # TODO: find the correct key, or ask user key = crypto.get_key(self.encrypt_key) @@ -220,7 +221,7 @@ class Envelope(object): raise GPGProblem(str(e)) outer_msg = MIMEMultipart('encrypted', - protocol='application/pgp-encrypted') + protocol='application/pgp-encrypted') version_str = 'Version: 1' encryption_mime = MIMEApplication(_data=version_str, -- cgit v1.2.3