Call gen_tl() when installing through setup.py (#530)

This commit is contained in:
Lonami Exo 2018-01-15 18:46:04 +01:00
parent 36e2101910
commit 2ccb6063e0

View File

@ -45,11 +45,13 @@ GENERATOR_DIR = 'telethon/tl'
IMPORT_DEPTH = 2 IMPORT_DEPTH = 2
def gen_tl(): def gen_tl(force=True):
from telethon_generator.tl_generator import TLGenerator from telethon_generator.tl_generator import TLGenerator
from telethon_generator.error_generator import generate_code from telethon_generator.error_generator import generate_code
generator = TLGenerator(GENERATOR_DIR) generator = TLGenerator(GENERATOR_DIR)
if generator.tlobjects_exist(): if generator.tlobjects_exist():
if not force:
return
print('Detected previous TLObjects. Cleaning...') print('Detected previous TLObjects. Cleaning...')
generator.clean_tlobjects() generator.clean_tlobjects()
@ -99,6 +101,10 @@ def main():
fetch_errors(ERRORS_JSON) fetch_errors(ERRORS_JSON)
else: else:
# Call gen_tl() if the scheme.tl file exists, e.g. install from GitHub
if os.path.isfile(SCHEME_TL):
gen_tl(force=False)
# Get the long description from the README file # Get the long description from the README file
with open('README.rst', encoding='utf-8') as f: with open('README.rst', encoding='utf-8') as f:
long_description = f.read() long_description = f.read()