Make more TLObject methods private

Even though raw API is somewhat necessary at times,
these methods should remain implementation details.
This commit is contained in:
Lonami Exo
2022-02-08 10:02:59 +01:00
parent 1f3ce07594
commit 84b016cf1c
9 changed files with 24 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ class GzipPacked(tlobject.TLObject):
def __bytes__(self):
return struct.pack('<I', GzipPacked.CONSTRUCTOR_ID) + \
tlobject.TLObject.serialize_bytes(gzip.compress(self.data))
tlobject.TLObject._serialize_bytes(gzip.compress(self.data))
@staticmethod
def read(reader):
@@ -35,7 +35,7 @@ class GzipPacked(tlobject.TLObject):
return gzip.decompress(reader.tgread_bytes())
@classmethod
def from_reader(cls, reader):
def _from_reader(cls, reader):
return GzipPacked(gzip.decompress(reader.tgread_bytes()))
def to_dict(self):

View File

@@ -33,7 +33,7 @@ class MessageContainer(TLObject):
}
@classmethod
def from_reader(cls, reader):
def _from_reader(cls, reader):
# This assumes that .read_* calls are done in the order they appear
messages = []
for _ in range(reader.read_int()):

View File

@@ -12,13 +12,13 @@ class RpcResult(TLObject):
self.error = error
@classmethod
def from_reader(cls, reader):
def _from_reader(cls, reader):
msg_id = reader.read_long()
inner_code = reader.read_int(signed=False)
if inner_code == _tl.RpcError.CONSTRUCTOR_ID:
return RpcResult(msg_id, None, _tl.RpcError.from_reader(reader))
return RpcResult(msg_id, None, _tl.RpcError._from_reader(reader))
if inner_code == GzipPacked.CONSTRUCTOR_ID:
return RpcResult(msg_id, GzipPacked.from_reader(reader).data, None)
return RpcResult(msg_id, GzipPacked._from_reader(reader).data, None)
reader.seek(-4)
# This reader.read() will read more than necessary, but it's okay.