From 624223e370f3b5d1e7910f01d03baf541ab6f7ec Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 2 Sep 2012 08:32:12 -0400 Subject: [PATCH] handler: add InvalidMessage.message_id convenience method. --- pygrader/handler/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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): -- 2.26.2