aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJ08nY2017-06-27 15:50:33 +0200
committerJ08nY2017-06-27 15:50:33 +0200
commita2f2b42cc5ba705463830d32a06ecd0b368d4c39 (patch)
treef546587c077589e74dfb3f42dd094b02a6dea568 /src
parente2653d12da7c9fb15f9431419eff0ea1819ebb53 (diff)
downloadmailman-pgp-a2f2b42cc5ba705463830d32a06ecd0b368d4c39.tar.gz
mailman-pgp-a2f2b42cc5ba705463830d32a06ecd0b368d4c39.tar.zst
mailman-pgp-a2f2b42cc5ba705463830d32a06ecd0b368d4c39.zip
Simplify combined wrapper + pep8.
Diffstat (limited to 'src')
-rw-r--r--src/mailman_pgp/pgp/wrapper.py36
-rw-r--r--src/mailman_pgp/rules/encryption.py4
-rw-r--r--src/mailman_pgp/rules/signature.py13
3 files changed, 14 insertions, 39 deletions
diff --git a/src/mailman_pgp/pgp/wrapper.py b/src/mailman_pgp/pgp/wrapper.py
index bc0a3c6..19e4b42 100644
--- a/src/mailman_pgp/pgp/wrapper.py
+++ b/src/mailman_pgp/pgp/wrapper.py
@@ -47,20 +47,8 @@ class PGPWrapper():
MIMEWrapper.__name__ + ' ' +
InlineWrapper.__name__ + '.')
- def is_mime_signed(self):
- return self.mime.is_signed()
-
- def is_inline_signed(self):
- return self.inline.is_signed()
-
def is_signed(self):
- return self.is_mime_signed() or self.is_inline_signed()
-
- def mime_sign(self, key):
- return self.mime.sign(key)
-
- def inline_sign(self, key):
- return self.inline.sign(key)
+ return self.mime.is_signed() or self.inline.is_signed()
def sign(self, key):
return self.default.sign(key)
@@ -74,28 +62,16 @@ class PGPWrapper():
:return: The verified signature.
:rtype: generator of pgpy.types.SignatureVerification
"""
- if self.is_mime_signed():
+ if self.mime.is_signed():
yield from self.mime.verify(key)
- elif self.is_inline_signed():
+ elif self.inline.is_signed():
yield from self.inline.verify(key)
def verifies(self, key):
return all(bool(verification) for verification in self.verify(key))
- def is_mime_encrypted(self):
- return self.mime.is_encrypted()
-
- def is_inline_encrypted(self):
- return self.inline.is_encrypted()
-
def is_encrypted(self):
- return self.is_mime_encrypted() or self.is_inline_encrypted()
-
- def mime_encrypt(self, *keys, **kwargs):
- return self.mime.encrypt(*keys, **kwargs)
-
- def inline_encrypt(self, *keys, **kwargs):
- return self.inline.encrypt(*keys, **kwargs)
+ return self.mime.is_encrypted() or self.inline.is_encrypted()
def encrypt(self, *keys, **kwargs):
return self.default.encrypt(*keys, **kwargs)
@@ -109,9 +85,9 @@ class PGPWrapper():
:return: The decrypted message.
:rtype: PGPMessage
"""
- if self.is_mime_encrypted():
+ if self.mime.is_encrypted():
return self.mime.decrypt(key)
- elif self.is_inline_encrypted():
+ elif self.inline.is_encrypted():
return self.inline.decrypt(key)
def is_keys(self):
diff --git a/src/mailman_pgp/rules/encryption.py b/src/mailman_pgp/rules/encryption.py
index cabd62c..8e4840d 100644
--- a/src/mailman_pgp/rules/encryption.py
+++ b/src/mailman_pgp/rules/encryption.py
@@ -30,8 +30,8 @@ class Encryption:
name = 'encryption'
description = _(
- """A rule which jumps to the moderation chain,
- when the incoming runner instructs it to.""")
+ "A rule which jumps to the moderation chain, "
+ "when the incoming runner instructs it to.")
record = True
def check(self, mlist, msg, msgdata):
diff --git a/src/mailman_pgp/rules/signature.py b/src/mailman_pgp/rules/signature.py
index 6bac3dc..02f13c1 100644
--- a/src/mailman_pgp/rules/signature.py
+++ b/src/mailman_pgp/rules/signature.py
@@ -44,14 +44,14 @@ class Signature:
name = 'signature'
description = _(
- """A rule which enforces PGP enabled list signature configuration.""")
+ "A rule which enforces PGP enabled list signature configuration.")
record = True
def check(self, mlist, msg, msgdata):
"""See `IRule`."""
# Find the `PGPMailingList` this is for.
enc_list = query(PGPMailingList).filter_by(
- list_id=mlist.list_id).first()
+ list_id=mlist.list_id).first()
if enc_list is None:
raise ValueError('PGP enabled mailing list not found.')
@@ -63,7 +63,7 @@ class Signature:
action = enc_list.unsigned_msg_action
if action != Action.defer:
record_action(msgdata, action, msg.sender,
- 'The message is unsigned.')
+ 'The message is unsigned.')
return True
# Take `inline_pgp_action` if inline signed.
@@ -71,7 +71,7 @@ class Signature:
action = enc_list.inline_pgp_action
if action != Action.defer:
record_action(msgdata, action, msg.sender,
- 'Inline PGP is not allowed.')
+ 'Inline PGP is not allowed.')
return True
# Lookup the address by sender, and its corresponding `PGPAddress`.
@@ -79,7 +79,7 @@ class Signature:
sender = msg.sender
address = user_manager.get_address(sender)
enc_address = PGPAddress.query().filter_by(
- email=address.email).first()
+ email=address.email).first()
if enc_address is None:
raise ValueError('PGP enabled address not found.')
@@ -93,10 +93,9 @@ class Signature:
action = enc_list.invalid_sig_action
if action != Action.defer:
record_action(msgdata, action, msg.sender,
- 'Signature did not verify.')
+ 'Signature did not verify.')
return True
-
# # TODO: handle more signatures here?
# sig_obj = next(verification.good_signatures)
# sig_key = sig_obj.by