Make lint happier

This commit is contained in:
Lonami Exo
2017-09-04 17:10:04 +02:00
parent 7f700c3bc1
commit 97cab7347b
22 changed files with 210 additions and 117 deletions

View File

@@ -26,7 +26,8 @@ class BinaryReader:
# region Reading
# "All numbers are written as little endian." |> Source: https://core.telegram.org/mtproto
# "All numbers are written as little endian."
# https://core.telegram.org/mtproto
def read_byte(self):
"""Reads a single byte value"""
return self.read(1)[0]
@@ -56,8 +57,7 @@ class BinaryReader:
"""Read the given amount of bytes"""
result = self.reader.read(length)
if len(result) != length:
raise BufferError(
'Trying to read outside the data bounds (no more data left to read)')
raise BufferError('No more data left to read')
return result
@@ -70,7 +70,9 @@ class BinaryReader:
# region Telegram custom reading
def tgread_bytes(self):
"""Reads a Telegram-encoded byte array, without the need of specifying its length"""
"""Reads a Telegram-encoded byte array,
without the need of specifying its length
"""
first_byte = self.read_byte()
if first_byte == 254:
length = self.read_byte() | (self.read_byte() << 8) | (
@@ -102,7 +104,9 @@ class BinaryReader:
raise ValueError('Invalid boolean code {}'.format(hex(value)))
def tgread_date(self):
"""Reads and converts Unix time (used by Telegram) into a Python datetime object"""
"""Reads and converts Unix time (used by Telegram)
into a Python datetime object
"""
value = self.read_int()
return None if value == 0 else datetime.fromtimestamp(value)
@@ -152,7 +156,9 @@ class BinaryReader:
self.reader.seek(position)
def seek(self, offset):
"""Seeks the stream position given an offset from the current position. May be negative"""
"""Seeks the stream position given an offset from the
current position. The offset may be negative
"""
self.reader.seek(offset, os.SEEK_CUR)
# endregion