Add Bot API parser and code-generator

This commit is contained in:
Alex RootJunior 2019-06-30 22:50:51 +03:00
parent 5e9d4e55d9
commit af2573dbee
15 changed files with 3242 additions and 1 deletions

22
generator/cli.py Normal file
View file

@ -0,0 +1,22 @@
import logging
import pathlib
import sys
import typing
from generator.generator import Generator
from generator.parser import Parser
script_path = pathlib.Path(__file__).parent
out_dir = script_path.parent / "aiogram" / "_telegram"
def main(argv: typing.List[str]) -> int:
logging.basicConfig(level=logging.ERROR, stream=sys.stdout)
parser = Parser()
parser.parse()
generator = Generator(parser)
with (out_dir / "types.py").open("w") as f:
f.write(generator.render_types())
return 0