message pylint fixes

This commit is contained in:
lakshyacis 2019-09-30 18:42:36 +05:30
parent 40e15579fd
commit 9aa7dd9d78
No known key found for this signature in database
GPG Key ID: D2C539C8EC63E9EB
1 changed files with 12 additions and 5 deletions

View File

@ -1,24 +1,30 @@
from debug import logger
from messagetypes import MsgBase
class Message(MsgBase):
def __init__(self):
"""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')
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')
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:["subject"] = data["subject"]["body"] = data["body"]
@ -27,5 +33,6 @@ class Message(MsgBase):
def process(self):
"""Process a message"""
logger.debug("Subject: %i bytes", len(self.subject))
logger.debug("Body: %i bytes", len(self.body))