mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-16 19:41:07 +03:00
Skip core types when parsing .tl files
This avoids the need to comment then every time the file changes.
This commit is contained in:
parent
5018879f84
commit
da5c171346
|
@ -1,11 +1,3 @@
|
||||||
from .tlarg import TLArg
|
from .tlarg import TLArg
|
||||||
from .tlobject import TLObject
|
from .tlobject import TLObject
|
||||||
from .parser import parse_tl, find_layer
|
from .parser import parse_tl, find_layer
|
||||||
|
|
||||||
|
|
||||||
CORE_TYPES = (
|
|
||||||
0xbc799737, # boolFalse#bc799737 = Bool;
|
|
||||||
0x997275b5, # boolTrue#997275b5 = Bool;
|
|
||||||
0x3fedd339, # true#3fedd339 = True;
|
|
||||||
0x1cb5c415, # vector#1cb5c415 {t:Type} # [ t ] = Vector t;
|
|
||||||
)
|
|
||||||
|
|
|
@ -6,6 +6,15 @@ from .tlobject import TLObject
|
||||||
from ..methods import Usability
|
from ..methods import Usability
|
||||||
|
|
||||||
|
|
||||||
|
CORE_TYPES = {
|
||||||
|
0xbc799737, # boolFalse#bc799737 = Bool;
|
||||||
|
0x997275b5, # boolTrue#997275b5 = Bool;
|
||||||
|
0x3fedd339, # true#3fedd339 = True;
|
||||||
|
0xc4b9f9bb, # error#c4b9f9bb code:int text:string = Error;
|
||||||
|
0x56730bcc # null#56730bcc = Null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _from_line(line, is_function, method_info, layer):
|
def _from_line(line, is_function, method_info, layer):
|
||||||
match = re.match(
|
match = re.match(
|
||||||
r'^([\w.]+)' # 'name'
|
r'^([\w.]+)' # 'name'
|
||||||
|
@ -46,7 +55,7 @@ def _from_line(line, is_function, method_info, layer):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_tl(file_path, layer, methods=None):
|
def parse_tl(file_path, layer, methods=None, ignored_ids=CORE_TYPES):
|
||||||
"""
|
"""
|
||||||
This method yields TLObjects from a given .tl file.
|
This method yields TLObjects from a given .tl file.
|
||||||
|
|
||||||
|
@ -78,6 +87,9 @@ def parse_tl(file_path, layer, methods=None):
|
||||||
result = _from_line(
|
result = _from_line(
|
||||||
line, is_function, method_info, layer=layer)
|
line, is_function, method_info, layer=layer)
|
||||||
|
|
||||||
|
if result.id in ignored_ids:
|
||||||
|
continue
|
||||||
|
|
||||||
obj_all.append(result)
|
obj_all.append(result)
|
||||||
if not result.is_function:
|
if not result.is_function:
|
||||||
obj_by_name[result.fullname] = result
|
obj_by_name[result.fullname] = result
|
||||||
|
|
Loading…
Reference in New Issue
Block a user