Skip to content

Commit

Permalink
added SLOCCount
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislit committed May 21, 2019
1 parent e0291fd commit 4382690
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions badge_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def flake8_color(score):
open('flake8.log', 'r', encoding='utf-8').read().split()[-1]
)

if not os.path.isfile('./sloccount.log'):
exit('Please direct sloccount output to sloccount.log')
with open('sloccount.log', 'r', encoding='utf-8') as fh:
pattern = r'Total Physical Source Lines of Code \(SLOC\) += ([0-9,]+)'
sloccount = re.search(pattern, fh.read()).group(1)

readme_text = open('README.rst', 'r', encoding='utf-8').read()

prefix = 'https://img.shields.io/badge/Pylint-'
Expand Down Expand Up @@ -188,5 +194,13 @@ def flake8_color(score):
1,
)

prefix = 'https://img.shields.io/badge/SLOCCount-'
readme_text = re.sub(
prefix + r'[0-9,]+',
prefix + str(sloccount),
readme_text,
1
)

with open('README.rst', 'w', encoding='utf-8') as f:
f.write(readme_text)
1 change: 1 addition & 0 deletions btest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if [ "$docs_only" = "0" ]; then
# pycodestyle . > pycodestyle.log
flake8 . > flake8.log
doc8 . > doc8.log
sloccount abydos > sloccount.log

./badge_update.py
fi
Expand Down
1 change: 1 addition & 0 deletions helpers/call_and_write_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def _run_script():
'flake8',
'doc8',
'pydocstyle',
'sloccount'
}:
sys.exit(1)
with open(args[0] + '.log', 'w') as output:
Expand Down
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ envlist =
flake8
doc8
docs
sloccount
badges
dist
# trick to enable pre-installation of Cython
Expand Down Expand Up @@ -149,6 +150,7 @@ commands =
[testenv:badges]
basepython = python3.6
skip_install = true
deps =
commands = python {toxinidir}/badge_update.py

[testenv:black]
Expand All @@ -165,3 +167,10 @@ skip_install = true
commands =
python setup.py sdist
python setup.py bdist_wheel

[testenv:sloccount]
changedir = {toxinidir}
skip_install = true
deps =
commands = {toxinidir}/helpers/call_and_write_log.py \
"sloccount --datadir .tox/sloccount ./abydos" 0

0 comments on commit 4382690

Please sign in to comment.