message pylint fixes
This commit is contained in:
parent
40e15579fd
commit
9aa7dd9d78
|
@ -1,24 +1,30 @@
|
||||||
|
"""
|
||||||
|
src/messagetypes/message.py
|
||||||
|
===========================
|
||||||
|
"""
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from messagetypes import MsgBase
|
from messagetypes import MsgBase
|
||||||
|
|
||||||
|
|
||||||
class Message(MsgBase):
|
class Message(MsgBase):
|
||||||
def __init__(self):
|
"""Encapsulate a message"""
|
||||||
return
|
# pylint: disable=attribute-defined-outside-init
|
||||||
|
|
||||||
def decode(self, data):
|
def decode(self, data):
|
||||||
|
"""Decode a message"""
|
||||||
# UTF-8 and variable type validator
|
# 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(data["subject"], 'utf-8', 'replace')
|
||||||
else:
|
else:
|
||||||
self.subject = unicode(str(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(data["body"], 'utf-8', 'replace')
|
||||||
else:
|
else:
|
||||||
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
self.body = unicode(str(data["body"]), 'utf-8', 'replace')
|
||||||
|
|
||||||
def encode(self, data):
|
def encode(self, data):
|
||||||
super(Message, self).encode()
|
"""Encode a message"""
|
||||||
|
super(Message, self).__init__()
|
||||||
try:
|
try:
|
||||||
self.data["subject"] = data["subject"]
|
self.data["subject"] = data["subject"]
|
||||||
self.data["body"] = data["body"]
|
self.data["body"] = data["body"]
|
||||||
|
@ -27,5 +33,6 @@ class Message(MsgBase):
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
|
"""Process a message"""
|
||||||
logger.debug("Subject: %i bytes", len(self.subject))
|
logger.debug("Subject: %i bytes", len(self.subject))
|
||||||
logger.debug("Body: %i bytes", len(self.body))
|
logger.debug("Body: %i bytes", len(self.body))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user