2018-04-14 19:17:59 +03:00
|
|
|
from telethon_generator.parsers import parse_errors, parse_tl, find_layer
|
2018-04-14 22:15:58 +03:00
|
|
|
from telethon_generator.generators import\
|
|
|
|
generate_errors, generate_tlobjects, generate_docs
|
2018-04-14 14:56:39 +03:00
|
|
|
|
|
|
|
|
2018-04-14 19:20:29 +03:00
|
|
|
ERRORS_INPUT_JSON = 'data/errors.json'
|
|
|
|
ERRORS_INPUT_DESC = 'data/error_descriptions'
|
2018-04-14 19:17:59 +03:00
|
|
|
ERRORS_OUTPUT = '../telethon/errors/rpc_error_list.py'
|
|
|
|
|
2018-04-14 19:20:29 +03:00
|
|
|
TLOBJECT_INPUT_TL = 'data/scheme.tl'
|
2018-04-14 19:17:59 +03:00
|
|
|
TLOBJECT_OUTPUT = '../telethon/tl'
|
2018-04-14 14:56:39 +03:00
|
|
|
|
2018-04-14 22:15:58 +03:00
|
|
|
DOCS_INPUT_RES = 'data/html'
|
|
|
|
DOCS_OUTPUT = '../docs'
|
|
|
|
|
2018-04-14 14:56:39 +03:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2018-04-14 22:15:58 +03:00
|
|
|
tlobjects = list(parse_tl(TLOBJECT_INPUT_TL, ignore_core=True))
|
|
|
|
errors = list(parse_errors(ERRORS_INPUT_JSON, ERRORS_INPUT_DESC))
|
|
|
|
layer = find_layer(TLOBJECT_INPUT_TL)
|
2018-04-14 19:17:59 +03:00
|
|
|
|
2018-04-14 22:15:58 +03:00
|
|
|
generate_tlobjects(tlobjects, layer, TLOBJECT_OUTPUT)
|
2018-04-14 19:17:59 +03:00
|
|
|
with open(ERRORS_OUTPUT, 'w', encoding='utf-8') as file:
|
2018-04-14 22:15:58 +03:00
|
|
|
generate_errors(errors, file)
|
|
|
|
|
|
|
|
generate_docs(tlobjects, errors, layer, DOCS_INPUT_RES, DOCS_OUTPUT)
|