Skip to content

Commit

Permalink
run black
Browse files Browse the repository at this point in the history
  • Loading branch information
Proteusiq committed Aug 1, 2023
1 parent 4298c3b commit 1117503
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
31 changes: 10 additions & 21 deletions saa/luga/de/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from saa.core.language import Luga


@dataclass(init=False, eq=False, repr=False, frozen=False)
class Deutsch(Luga):
time = {
Expand All @@ -15,7 +16,7 @@ class Deutsch(Luga):
connect_format = "{2}{1}{0}"
numbers = {
0: "null",
1: "ein", # ein und zwanzig / eine Minute / ein Uhr
1: "ein", # ein und zwanzig / eine Minute / ein Uhr
2: "zwei",
3: "drei",
4: "vier",
Expand All @@ -42,36 +43,24 @@ class Deutsch(Luga):

@staticmethod
def time_logic(hour, minute) -> tuple[int, int, str, str]:

is_to = "to" if minute >= 30 else "past"
time_indicator = "Minuten" if minute not in (1,59) else "Minute"


time_indicator = "Minuten" if minute not in (1, 59) else "Minute"

if is_to == "to":
hour += 1
minute = 60 - minute

return hour, minute, is_to, time_indicator



@staticmethod
def post_logic(text:str) -> str:
def post_logic(text: str) -> str:
if text in ("viertel nach ein", "viertel vor ein", "halb ein"):
text += "s"


if text in ("viertel nach ein",
"viertel vor ein",
"halb ein"):
text+="s"
text = text.replace("ein Minute", "eine Minute").replace("null", "zwölf")

text = (text
.replace("ein Minute", "eine Minute")
.replace("null", "zwölf")
)

return text

class Language(Deutsch):
pass


class Language(Deutsch):
pass
4 changes: 1 addition & 3 deletions tests/test_clock/test_clock_de.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
(time(hour=13, minute=45), Deutsch, "viertel vor zwei"),
(time(hour=13, minute=15), Deutsch, "viertel nach eins"),
(time(hour=13, minute=30), Deutsch, "halb zwei"),
(time(hour=12, minute=45), Deutsch, "viertel vor eins"),
(time(hour=12, minute=45), Deutsch, "viertel vor eins"),
(time(hour=13, minute=0), Deutsch, "ein Uhr"),
(time(hour=13, minute=13), Deutsch, "dreizehn Minuten nach ein Uhr"),
]


@pytest.mark.parametrize("test_input, language, test_output", test_cases)
def test_clocks(test_input, language, test_output):

clock = Watch(language=language)
assert test_output == clock(test_input)

Expand All @@ -44,6 +43,5 @@ def test_clocks(test_input, language, test_output):

@pytest.mark.parametrize("test_input, language, test_output", test_plural_cases)
def test_cases(test_input, language, test_output):

clock = Watch(language=language)
assert test_output == clock(test_input)
2 changes: 1 addition & 1 deletion tests/test_clock/test_clock_sw.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(time(hour=13, minute=30), Swahili, "saa saba na nusu mchana"),
(time(hour=20, minute=0), Swahili, "saa mbili usiku"),
(time(hour=19, minute=25), Swahili, "saa moja na dakika ishirini na tano jioni"),
(time(hour=19, minute=41), Swahili,"saa mbili kasoro dakika kumi na tisa usiku"),
(time(hour=19, minute=41), Swahili, "saa mbili kasoro dakika kumi na tisa usiku"),
]


Expand Down

0 comments on commit 1117503

Please sign in to comment.