Skip to content

Commit

Permalink
Fix codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
justgigio committed Nov 8, 2023
1 parent ff2b168 commit 43e1e4a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +16,8 @@ build:
poetry build

.PHONY: mypy
mypy: poetry run mypy src
mypy:
poetry run mypy src

.PHONY: black-check
black-check:
Expand All @@ -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
14 changes: 9 additions & 5 deletions src/awesome_git_mosaic/adapters/console/console_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@

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
output = []
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)
8 changes: 6 additions & 2 deletions src/awesome_git_mosaic/charmaps/basic/basic_charmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/awesome_git_mosaic/usecases/write_in_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion src/awesome_git_mosaic/usecases/write_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 43e1e4a

Please sign in to comment.