Better clean command in setup.py

This commit is contained in:
Lonami Exo 2019-05-04 17:51:14 +02:00
parent 05fcbfd7b7
commit 84c197be60
2 changed files with 5 additions and 7 deletions

View File

@ -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

View File

@ -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))