From: W. Trevor King Date: Sun, 2 Sep 2012 12:32:12 +0000 (-0400) Subject: handler: add InvalidMessage.message_id convenience method. X-Git-Tag: v0.3~36 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=624223e370f3b5d1e7910f01d03baf541ab6f7ec;p=pygrader.git handler: add InvalidMessage.message_id convenience method. --- diff --git a/pygrader/handler/__init__.py b/pygrader/handler/__init__.py index 1837721..3fb7b28 100644 --- a/pygrader/handler/__init__.py +++ b/pygrader/handler/__init__.py @@ -11,6 +11,19 @@ class InvalidMessage (ValueError): self.message = message self.error = error + def message_id(self): + """Return a short string identifying the invalid message. + """ + if self.message is None: + return None + subject = self.message['Subject'] + if subject is not None: + return repr(subject) + message_id = self.message['Message-ID'] + if message_id is not None: + return message_id + return None + class UnsignedMessage (InvalidMessage): def __init__(self, **kwargs):