From 05cda087d6e59420aecc1e241fccc96b331a1eeb Mon Sep 17 00:00:00 2001 From: lakshyacis Date: Tue, 8 Oct 2019 12:33:48 +0530 Subject: [PATCH] helper_msgcoding pylint fixes --- src/helper_msgcoding.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/helper_msgcoding.py b/src/helper_msgcoding.py index cc632ffa..ae2bf80b 100644 --- a/src/helper_msgcoding.py +++ b/src/helper_msgcoding.py @@ -25,19 +25,24 @@ BITMESSAGE_ENCODING_EXTENDED = 3 class MsgEncodeException(Exception): + """Exception during message encoding""" pass class MsgDecodeException(Exception): + """Exception during message decoding""" pass class DecompressionSizeException(MsgDecodeException): + # pylint: disable=super-init-not-called + """Decompression resulted in too much data (attack protection)""" def __init__(self, size): self.size = size class MsgEncode(object): + """Message encoder class""" def __init__(self, message, encoding=BITMESSAGE_ENCODING_SIMPLE): self.data = None self.encoding = encoding @@ -52,6 +57,7 @@ class MsgEncode(object): raise MsgEncodeException("Unknown encoding %i" % (encoding)) def encodeExtended(self, message): + """Handle extended encoding""" try: msgObj = messagetypes.message.Message() self.data = zlib.compress(msgpack.dumps(msgObj.encode(message)), 9) @@ -64,15 +70,18 @@ class MsgEncode(object): self.length = len(self.data) def encodeSimple(self, message): + """Handle simple encoding""" self.data = 'Subject:%(subject)s\nBody:%(body)s' % message self.length = len(self.data) def encodeTrivial(self, message): + """Handle trivial encoding""" self.data = message['body'] self.length = len(self.data) class MsgDecode(object): + """Message decoder class""" def __init__(self, encoding, data): self.encoding = encoding if self.encoding == BITMESSAGE_ENCODING_EXTENDED: @@ -88,6 +97,7 @@ class MsgDecode(object): self.subject = _translate("MsgDecode", "Unknown encoding") def decodeExtended(self, data): + """Handle extended encoding""" dc = zlib.decompressobj() tmp = "" while len(tmp) <= BMConfigParser().safeGetInt("zlib", "maxsize"): @@ -131,6 +141,7 @@ class MsgDecode(object): self.body = msgObj.body def decodeSimple(self, data): + """Handle simple encoding""" bodyPositionIndex = string.find(data, '\nBody:') if bodyPositionIndex > 1: subject = data[8:bodyPositionIndex]