fix codacy

This commit is contained in:
Casper da Costa-Luis 2020-04-26 21:50:55 +01:00
parent 6240f932ac
commit c7586a604e
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
4 changed files with 20 additions and 17 deletions

View File

@ -1,24 +1,25 @@
from __future__ import print_function
from os import path
import sys
sys.path.insert(0, path.dirname(path.dirname(__file__))) # NOQA
import tqdm
import tqdm.cli
from io import open as io_open
from os import path
import re
import sys
sys.path.insert(0, path.dirname(path.dirname(__file__))) # NOQA
import tqdm
import tqdm.cli
RE_OPT = re.compile(r'(\w+) :', flags=re.M)
RE_OPT_INPUT = re.compile(
r'(\w+) : (?:str|int|float|chr|dict|tuple)', flags=re.M)
def doc2opt(doc, all=False):
def doc2opt(doc, user_input=True):
"""
doc : str, document to parse
all : bool, [default: False] for only options requiring user input
user_input : bool, optional.
[default: True] for only options requiring user input
"""
RE = RE_OPT if all else RE_OPT_INPUT
RE = RE_OPT_INPUT if user_input else RE_OPT
return ('--' + i for i in RE.findall(doc))
@ -26,8 +27,8 @@ def doc2opt(doc, all=False):
options = {'-h', '--help', '-v', '--version'}
options_input = set()
for doc in (tqdm.tqdm.__init__.__doc__, tqdm.cli.CLI_EXTRA_DOC):
options.update(doc2opt(doc, all=True))
options_input.update(doc2opt(doc, all=False))
options.update(doc2opt(doc, user_input=False))
options_input.update(doc2opt(doc, user_input=True))
options.difference_update(
'--' + i for i in ('name',) + tqdm.cli.UNSUPPORTED_OPTS)
options_input &= options

View File

@ -1,12 +1,13 @@
from __future__ import print_function
from io import open as io_open
from os import path
import sys
from textwrap import dedent
sys.path.insert(0, path.dirname(path.dirname(__file__))) # NOQA
import tqdm
import tqdm.cli
from textwrap import dedent
from io import open as io_open
from os import path
HEAD_ARGS = """
Parameters

View File

@ -95,7 +95,7 @@ tqdm/tqdm.1: .meta/.tqdm.1.md tqdm/cli.py tqdm/std.py
cat "$<" - |\
pandoc -o "$@" -s -t man
tqdm/completion.sh: tqdm/std.py tqdm/cli.py
tqdm/completion.sh: .meta/mkcompletion.py tqdm/std.py tqdm/cli.py
@python .meta/mkcompletion.py
README.rst: .meta/.readme.rst tqdm/std.py tqdm/cli.py

View File

@ -210,9 +210,10 @@ Options:
from shutil import copyfile
from pkg_resources import resource_filename, Requirement
def cp(fi, fo):
copyfile(fi, fo)
log.info("written:" + fo)
def cp(src, dst):
"""copies from src path to dst"""
copyfile(src, dst)
log.info("written:" + dst)
if manpath is not None:
cp(resource_filename(Requirement.parse('tqdm'), 'tqdm/tqdm.1'),
path.join(manpath, 'tqdm.1'))