This commit is contained in:
JP White 2021-02-28 19:24:36 -05:00
parent 0bfacc1d66
commit 4dfb314628
11 changed files with 66 additions and 15 deletions

View file

@ -38,7 +38,7 @@ lint: ## check style with flake8
# stop the build if there are Python syntax errors or undefined names
flake8 gitinspector tests --count --select=E9,F63,F7,F82 --show-source --statistics --builtins="_"
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 gitinspector tests --count --ignore=E722,W503,E401,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics --builtins="_"
flake8 gitinspector tests --count --ignore=E203,E722,W503,E401,C901 --exit-zero --max-complexity=10 --max-line-length=127 --statistics --builtins="_"
format: ## auto format all the code with black
black gitinspector --line-length 127

View file

@ -8,14 +8,10 @@ name = "pypi"
[dev-packages]
pytest = "*"
flake8 = "*"
autopep8 = "*"
black = "*"
twine = "*"
coverage = "*"
coveralls = "*"
[requires]
python_version = "3.8"
[pipenv]
allow_prereleases = true

View file

@ -42,8 +42,8 @@ def get():
def __add_one__(string):
for i in __filters__:
if (i + ":").lower() == string[0:len(i) + 1].lower():
__filters__[i][0].add(string[len(i) + 1:])
if (i + ":").lower() == string[0 : len(i) + 1].lower():
__filters__[i][0].add(string[len(i) + 1 :])
return
__filters__["file"][0].add(string)

View file

@ -144,7 +144,7 @@ class BlameOutput(Outputable):
)
for i in sorted(self.blame.get_summed_blames().items()):
print(terminal.ljust(i[0], 20)[0:20 - terminal.get_excess_column_count(i[0])], end=" ")
print(terminal.ljust(i[0], 20)[0 : 20 - terminal.get_excess_column_count(i[0])], end=" ")
print(str(i[1].rows).rjust(10), end=" ")
print("{0:.1f}".format(Blame.get_stability(i[0], i[1].rows, self.changes)).rjust(14), end=" ")
print("{0:.1f}".format(float(i[1].skew) / i[1].rows).rjust(12), end=" ")

View file

@ -163,7 +163,7 @@ class ChangesOutput(Outputable):
authorinfo = authorinfo_list.get(i)
percentage = 0 if total_changes == 0 else (authorinfo.insertions + authorinfo.deletions) / total_changes * 100
print(terminal.ljust(i, 20)[0:20 - terminal.get_excess_column_count(i)], end=" ")
print(terminal.ljust(i, 20)[0 : 20 - terminal.get_excess_column_count(i)], end=" ")
print(str(authorinfo.commits).rjust(13), end=" ")
print(str(authorinfo.insertions).rjust(13), end=" ")
print(str(authorinfo.deletions).rjust(14), end=" ")

View file

@ -103,7 +103,7 @@ class FilteringOutput(Outputable):
for i in filtered:
(width, _unused) = terminal.get_size()
print("...%s" % i[-width + 3:] if len(i) > width else i)
print("...%s" % i[-width + 3 :] if len(i) > width else i)
def output_text(self):
FilteringOutput.__output_text_section__(_(FILTERING_INFO_TEXT), __filters__["file"][1])

View file

@ -52,7 +52,7 @@ class ResponsibilitiesOutput(Outputable):
width -= 7
print(str(entry[0]).rjust(6), end=" ")
print("...%s" % entry[1][-width + 3:] if len(entry[1]) > width else entry[1])
print("...%s" % entry[1][-width + 3 :] if len(entry[1]) > width else entry[1])
if j >= 9:
break

View file

@ -37,7 +37,7 @@ def __output_row__text__(timeline_data, periods, names):
for name in names:
if timeline_data.is_author_in_periods(periods, name[0]):
print(terminal.ljust(name[0], 20)[0:20 - terminal.get_excess_column_count(name[0])], end=" ")
print(terminal.ljust(name[0], 20)[0 : 20 - terminal.get_excess_column_count(name[0])], end=" ")
for period in periods:
multiplier = timeline_data.get_multiplier(period, 9)
@ -121,7 +121,7 @@ class TimelineOutput(Outputable):
max_periods_per_row = int((width - 21) / 11)
for i in range(0, len(periods), max_periods_per_row):
__output_row__text__(timeline_data, periods[i:i + max_periods_per_row], names)
__output_row__text__(timeline_data, periods[i : i + max_periods_per_row], names)
def output_html(self):
if self.changes.get_commits():
@ -135,7 +135,7 @@ class TimelineOutput(Outputable):
print(timeline_xml)
for i in range(0, len(periods), max_periods_per_row):
__output_row__html__(timeline_data, periods[i:i + max_periods_per_row], names)
__output_row__html__(timeline_data, periods[i : i + max_periods_per_row], names)
timeline_xml = "</div></div>"
print(timeline_xml)

View file

@ -173,7 +173,7 @@ def output_progress(text, pos, length):
progress_text = text.format(100 * pos / length)
if len(progress_text) > width:
progress_text = "...%s" % progress_text[-width + 3:]
progress_text = "...%s" % progress_text[-width + 3 :]
print("\r{0}\r{1}".format(" " * width, progress_text), end="")
sys.stdout.flush()

31
tests/test_basedir.py Normal file
View file

@ -0,0 +1,31 @@
import os
import unittest
from pathlib import Path
from gitinspector import basedir
class TestBasedirModule(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
def setUp(self):
self.TEST_BASEDIR = Path(os.path.dirname(os.path.abspath(__file__)))
self.PROJECT_BASEDIR = Path(self.TEST_BASEDIR).parent
self.MODULE_BASEDIR = Path(self.PROJECT_BASEDIR, 'gitinspector')
self.CWD = os.getcwd()
def test_get_basedir(self):
expected = str(self.MODULE_BASEDIR)
actual = basedir.get_basedir()
self.assertEqual(expected, actual)
def test_get_basedir_git(self):
expected = self.CWD
actual = basedir.get_basedir_git()
self.assertEqual(expected, actual)
def test_get_basedir_git_with_path(self):
expected = str(self.PROJECT_BASEDIR)
actual = basedir.get_basedir_git(self.TEST_BASEDIR)
self.assertEqual(expected, actual)

24
tests/test_blame.py Normal file
View file

@ -0,0 +1,24 @@
import os
import unittest
from pathlib import Path
from gitinspector import blame
class TestBlameModule(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass
def setUp(self):
self.TEST_BASEDIR = Path(os.path.dirname(os.path.abspath(__file__)))
self.PROJECT_BASEDIR = Path(self.TEST_BASEDIR).parent
self.MODULE_BASEDIR = Path(self.PROJECT_BASEDIR, 'gitinspector')
self.CWD = os.getcwd()
def test_BlameEntry_attrs(self):
blame_entry = blame.BlameEntry()
expected = 0
self.assertEqual(expected, blame_entry.rows)
self.assertEqual(expected, blame_entry.skew)
self.assertEqual(expected, blame_entry.comments)