Skip to content

Commit

Permalink
Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
trag1c committed Dec 1, 2022
1 parent ebb7d41 commit b4f9db7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/dahlia/dahlia.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def __hash__(self) -> int:
return hash((self.depth, self.no_reset, self.marker))

def __repr__(self) -> str:
return f"Dahlia(depth={self.depth}, no_reset={self.no_reset}, marker={self.marker!r})"
return (
f"Dahlia(depth={self.depth}, "
f"no_reset={self.no_reset}, marker={self.marker!r})"
)

@property
def depth(self) -> int:
Expand Down Expand Up @@ -116,7 +119,7 @@ def convert(self, string: str) -> str:
if not (string.endswith(self.__reset) or self.no_reset):
string += self.__reset
for code, bg, color in _find_codes(string, self.__patterns):
string = string.replace(code, self.__get_ansi(color, bg))
string = string.replace(code, self.__get_ansi(color, bg=bg))
return string

def input(self, prompt: str) -> str:
Expand Down Expand Up @@ -193,7 +196,7 @@ def test(self) -> None:
+ "&r&ll&r&mm&r&nn&r&oo".replace("&", self.marker)
)

def __get_ansi(self, code: str, bg: bool) -> str:
def __get_ansi(self, code: str, *, bg: bool) -> str:
formats = BG_FORMAT_TEMPLATES if bg else FORMAT_TEMPLATES
if len(code) == 6:
r, g, b = (int(code[i : i + 2], 16) for i in range(0, 6, 2))
Expand Down

0 comments on commit b4f9db7

Please sign in to comment.