From 43e1e4ab0d0f9aa79f82db8d0ceddf089f07b989 Mon Sep 17 00:00:00 2001 From: Giovane Costa Date: Wed, 8 Nov 2023 11:23:00 -0300 Subject: [PATCH] Fix codestyle --- Makefile | 13 +++++++------ .../adapters/console/console_adapter.py | 14 +++++++++----- .../charmaps/basic/basic_charmap.py | 8 ++++++-- .../usecases/write_in_console.py | 8 +++++++- src/awesome_git_mosaic/usecases/write_mosaic.py | 4 +++- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index e75a839..dbb0c3c 100644 --- a/Makefile +++ b/Makefile @@ -7,10 +7,6 @@ code-style: setup: poetry install -.PHONY: test -test: code-style - poetry run py.test tests --cov=. --cov-report xml --cov-report term --cov-report html --cov-fail-under=90 - .PHONY: test-only test-only: poetry run py.test tests --no-cov @@ -20,7 +16,8 @@ build: poetry build .PHONY: mypy -mypy: poetry run mypy src +mypy: + poetry run mypy src .PHONY: black-check black-check: @@ -39,7 +36,11 @@ isort: poetry run isort --ac src .PHONY: check -check: isort-check black-check mypy +check: code-style isort-check black-check mypy .PHONY: format format: isort black + +.PHONY: test +test: check + poetry run py.test tests --cov=. --cov-report xml --cov-report term --cov-report html --cov-fail-under=90 diff --git a/src/awesome_git_mosaic/adapters/console/console_adapter.py b/src/awesome_git_mosaic/adapters/console/console_adapter.py index c01b9e9..0bbdca7 100644 --- a/src/awesome_git_mosaic/adapters/console/console_adapter.py +++ b/src/awesome_git_mosaic/adapters/console/console_adapter.py @@ -8,14 +8,20 @@ CONSOLE_PIXEL = "▉" CONSOLE_SPACE = " " -CONSOLE_BG = '░' +CONSOLE_BG = "░" class ConsoleAdapter: def __init__(self, charmap: Optional["Charmap"] = None): self.charmap = charmap or BasicCharmap() - def output(self, message: str, with_spaces: bool = True, background: bool = False, inverted: bool = False) -> str: + def output( + self, + message: str, + with_spaces: bool = True, + background: bool = False, + inverted: bool = False, + ) -> str: lines = self.charmap.translate(message, with_spaces, inverted) bg = CONSOLE_BG if background else CONSOLE_SPACE @@ -23,9 +29,7 @@ def output(self, message: str, with_spaces: bool = True, background: bool = Fals for line in lines: output_line = "" for char in line: - output_line += ( - CONSOLE_PIXEL if self.charmap.is_pixel(char) else bg - ) + output_line += CONSOLE_PIXEL if self.charmap.is_pixel(char) else bg output.append(output_line) return "\n".join(output) diff --git a/src/awesome_git_mosaic/charmaps/basic/basic_charmap.py b/src/awesome_git_mosaic/charmaps/basic/basic_charmap.py index 8fd4ce5..40986ca 100644 --- a/src/awesome_git_mosaic/charmaps/basic/basic_charmap.py +++ b/src/awesome_git_mosaic/charmaps/basic/basic_charmap.py @@ -24,7 +24,9 @@ def __init__( model_file, char_width, char_height, char_list ) - def translate(self, string: str, with_spaces: bool = True, inverted: bool = False) -> list: + def translate( + self, string: str, with_spaces: bool = True, inverted: bool = False + ) -> list: string = unidecode(string).lower() mapped_chars = [self.chars[c] for c in string] @@ -34,7 +36,9 @@ def translate(self, string: str, with_spaces: bool = True, inverted: bool = Fals for line in range(self.char_height): line_str = space.join(["".join(char[line]) for char in mapped_chars]) if inverted: - line_str = line_str.translate(str.maketrans(f"{CHARMAP_PIXEL} ", f" {CHARMAP_PIXEL}")) + line_str = line_str.translate( + str.maketrans(f"{CHARMAP_PIXEL} ", f" {CHARMAP_PIXEL}") + ) output.append(line_str) return output diff --git a/src/awesome_git_mosaic/usecases/write_in_console.py b/src/awesome_git_mosaic/usecases/write_in_console.py index fa1398c..d0c68ea 100644 --- a/src/awesome_git_mosaic/usecases/write_in_console.py +++ b/src/awesome_git_mosaic/usecases/write_in_console.py @@ -5,6 +5,12 @@ class WriteInConsole: def __init__(self, console_adapter: ConsoleAdapter = None): self.console_adapter = console_adapter or ConsoleAdapter() - def write(self, text: str, with_spaces: bool = True, background: bool = False, inverted: bool = False): + def write( + self, + text: str, + with_spaces: bool = True, + background: bool = False, + inverted: bool = False, + ): output = self.console_adapter.output(text, with_spaces, background, inverted) print(output) diff --git a/src/awesome_git_mosaic/usecases/write_mosaic.py b/src/awesome_git_mosaic/usecases/write_mosaic.py index 9bf40a4..e2decc8 100644 --- a/src/awesome_git_mosaic/usecases/write_mosaic.py +++ b/src/awesome_git_mosaic/usecases/write_mosaic.py @@ -34,7 +34,9 @@ def write( ) for _ in range(strength): - timestamps += self.git_mosaic_adapter.output(f"{message} " * multiply, None, with_spaces, inverted) + timestamps += self.git_mosaic_adapter.output( + f"{message} " * multiply, None, with_spaces, inverted + ) timestamps.sort()