From 9aa7dd9d78d4eda83f78f577af7b47ccd8694fa2 Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Mon, 30 Sep 2019 18:42:36 +0530 Subject: [PATCH] message pylint fixes --- src/messagetypes/message.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/messagetypes/message.py b/src/messagetypes/message.py index f52c6b35..cd5bf762 100644 --- a/src/messagetypes/message.py +++ b/src/messagetypes/message.py @@ -1,24 +1,30 @@ +""" +src/messagetypes/message.py +=========================== +""" from debug import logger from messagetypes import MsgBase class Message(MsgBase): - def __init__(self): - return + """Encapsulate a message""" + # pylint: disable=attribute-defined-outside-init def decode(self, data): + """Decode a message""" # UTF-8 and variable type validator - if type(data["subject"]) is str: + if isinstance(data["subject"], str): self.subject = unicode(data["subject"], 'utf-8', 'replace') else: self.subject = unicode(str(data["subject"]), 'utf-8', 'replace') - if type(data["body"]) is str: + if isinstance(data["body"], str): self.body = unicode(data["body"], 'utf-8', 'replace') else: self.body = unicode(str(data["body"]), 'utf-8', 'replace') def encode(self, data): - super(Message, self).encode() + """Encode a message""" + super(Message, self).__init__() try: self.data["subject"] = data["subject"] self.data["body"] = data["body"] @@ -27,5 +33,6 @@ class Message(MsgBase): return self.data def process(self): + """Process a message""" logger.debug("Subject: %i bytes", len(self.subject)) logger.debug("Body: %i bytes", len(self.body))