Move all imported schema objects outside TLObject

This commit is contained in:
Dan 2019-08-01 18:44:20 +02:00
parent d727754ad6
commit 9ad5e62dea
3 changed files with 5 additions and 9 deletions

View File

@ -19,8 +19,7 @@
from importlib import import_module
from .all import objects
from .core.tl_object import TLObject
for k, v in objects.items():
path, name = v.rsplit(".", 1)
TLObject.all[k] = getattr(import_module(path), name)
objects[k] = getattr(import_module(path), name)

View File

@ -22,8 +22,5 @@ from .gzip_packed import GzipPacked
from .list import List
from .message import Message
from .msg_container import MsgContainer
from .primitives import (
Bool, BoolTrue, BoolFalse, Bytes, Double,
Int, Long, Int128, Int256, Null, String, Vector
)
from .primitives import *
from .tl_object import TLObject

View File

@ -20,17 +20,17 @@ from collections import OrderedDict
from io import BytesIO
from json import dumps
from ..all import objects
class TLObject:
all = {}
__slots__ = []
QUALNAME = "Base"
@staticmethod
def read(b: BytesIO, *args): # TODO: Rename b -> data
return TLObject.all[int.from_bytes(b.read(4), "little")].read(b, *args)
return objects[int.from_bytes(b.read(4), "little")].read(b, *args)
def write(self, *args) -> bytes:
pass