From 84c197be609c25f829ce2f2b507cac4f4725666f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 4 May 2019 17:51:14 +0200 Subject: [PATCH] Better clean command in setup.py --- setup.py | 10 ++++------ telethon_generator/generators/tlobject.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index 7efec8c4..87b64edc 100755 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ DOCS_IN_RES = GENERATOR_DIR / 'data/html' DOCS_OUT = Path('docs') -def generate(which): +def generate(action, which): from telethon_generator.parsers import\ parse_errors, parse_methods, parse_tl, find_layer @@ -71,10 +71,8 @@ def generate(which): if not which: which.extend(('tl', 'errors')) - clean = 'clean' in which + clean = action == 'clean' action = 'Cleaning' if clean else 'Generating' - if clean: - which.remove('clean') if 'all' in which: which.remove('all') @@ -141,8 +139,8 @@ def generate(which): def main(): - if len(argv) >= 2 and argv[1] == 'gen': - generate(argv[2:]) + if len(argv) >= 2 and argv[1] in ('gen', 'clean'): + generate(argv[1], argv[2:]) elif len(argv) >= 2 and argv[1] == 'pypi': # (Re)generate the code to make sure we don't push without it diff --git a/telethon_generator/generators/tlobject.py b/telethon_generator/generators/tlobject.py index 5e7f066d..cd2b99d7 100644 --- a/telethon_generator/generators/tlobject.py +++ b/telethon_generator/generators/tlobject.py @@ -737,7 +737,7 @@ def generate_tlobjects(tlobjects, layer, import_depth, output_dir): def clean_tlobjects(output_dir): - for d in ('functions', 'types'): + for d in ('functions', 'types', 'patched'): d = output_dir / d if d.is_dir(): shutil.rmtree(str(d))