mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2025-02-02 13:01:24 +01:00
pylint-full.py should now be windows compatible
This commit is contained in:
parent
e31bfb58f0
commit
70c381d9f4
@ -7,12 +7,14 @@ this program will exit with exit code 1.
|
|||||||
|
|
||||||
__doc__ = DOCSTR
|
__doc__ = DOCSTR
|
||||||
|
|
||||||
from sh import pylint
|
import subprocess
|
||||||
from sh import ErrorReturnCode
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
os.chdir("..") # leave bin/
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(DOCSTR)
|
parser = argparse.ArgumentParser(DOCSTR)
|
||||||
|
|
||||||
parser.add_argument("--min-eval", dest="min_eval", type=float, default=10.00,
|
parser.add_argument("--min-eval", dest="min_eval", type=float, default=10.00,
|
||||||
@ -22,20 +24,32 @@ parser.add_argument("--min-eval", dest="min_eval", type=float, default=10.00,
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
PYLINT_ARGS = ("minecraft", "--disable=E")
|
PYLINT = ("pylint", "minecraft", "--disable=E")
|
||||||
|
EVAL_PATTERN = (r"Global evaluation\n-----------------\n"
|
||||||
|
r"Your code has been rated at (\d*\.\d+)/10")
|
||||||
|
|
||||||
try:
|
|
||||||
output = pylint(*PYLINT_ARGS)
|
|
||||||
except ErrorReturnCode as e:
|
|
||||||
output = e.stdout
|
|
||||||
output = output.decode()
|
|
||||||
|
|
||||||
global_eval_pattern = re.compile(r"Global evaluation\n-----------------\n"
|
def get_evaluation_score_and_output():
|
||||||
r"Your code has been rated at (\d*\.\d+)/10")
|
"""
|
||||||
|
Returns a tuple containing ``(output, eval_score)`` where:
|
||||||
|
``output`` is a ``str`` with the pylint output.
|
||||||
|
``eval_score`` is a ``float`` with the pylint evaluation score
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output(PYLINT)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
output = e.output
|
||||||
|
output = output.decode()
|
||||||
|
|
||||||
match = global_eval_pattern.search(output)
|
global_eval_pattern = re.compile(EVAL_PATTERN)
|
||||||
evaluation = float(match.group(1))
|
|
||||||
|
|
||||||
|
match = global_eval_pattern.search(output)
|
||||||
|
|
||||||
|
evaluation = float(match.group(1))
|
||||||
|
|
||||||
|
return (output, evaluation)
|
||||||
|
|
||||||
|
output, evaluation = get_evaluation_score_and_output()
|
||||||
print(output) # We want to appear as if we're pylint
|
print(output) # We want to appear as if we're pylint
|
||||||
|
|
||||||
if evaluation < args.min_eval:
|
if evaluation < args.min_eval:
|
||||||
|
6
tox.ini
6
tox.ini
@ -36,7 +36,7 @@ deps =
|
|||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
basepython = python3.4
|
basepython = python3.4
|
||||||
commands =
|
commands =
|
||||||
flake8 minecraft tests bin/*.py setup.py start.py
|
flake8 minecraft tests setup.py
|
||||||
deps =
|
deps =
|
||||||
{[testenv]deps}
|
{[testenv]deps}
|
||||||
flake8
|
flake8
|
||||||
@ -53,9 +53,9 @@ basepython = python3.4
|
|||||||
deps =
|
deps =
|
||||||
{[testenv]deps}
|
{[testenv]deps}
|
||||||
pylint
|
pylint
|
||||||
sh
|
changedir = bin
|
||||||
commands =
|
commands =
|
||||||
python {toxinidir}/bin/pylint-full.py --min-eval=9.5
|
python pylint-full.py --min-eval=9.5
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
basepython = python3.4
|
basepython = python3.4
|
||||||
|
Loading…
Reference in New Issue
Block a user