minor tidy

This commit is contained in:
Casper da Costa-Luis 2020-04-25 18:44:23 +01:00
parent 27e9338f24
commit 8d0e68350a
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 9 additions and 11 deletions

View File

@ -8,23 +8,21 @@ from io import open as io_open
from os import path
import re
RE_OPT = re.compile(r'(\w+) :', flags=re.M)
def doc2opt(doc):
"""
doc : str, document to parse
"""
options = ['--' + i.strip(' :') for i in re.findall(r'\w+ :', doc)]
return options
return {'--' + i for i in RE_OPT.findall(doc)}
# CLI options
options = ['-h', '--help', '-v', '--version']
options += doc2opt(tqdm.tqdm.__init__.__doc__)
options += doc2opt(tqdm.cli.CLI_EXTRA_DOC)
# Remove options without CLI support
no_support = ['--' + i for i in tqdm.cli.UNSUPPORTED_OPTS]
# TODO: Check and remove option `name`
no_support += ['--name']
options = list(set(options) - set(no_support))
options = {'-h', '--help', '-v', '--version'}
options ^= doc2opt(tqdm.tqdm.__init__.__doc__)
options ^= doc2opt(tqdm.cli.CLI_EXTRA_DOC)
options -= {'--name'} ^ {'--' + i for i in tqdm.cli.UNSUPPORTED_OPTS}
src_dir = path.abspath(path.dirname(__file__))
completion = u"""\