Skip to content

Commit

Permalink
Add support for manually entered inflection tables
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaublitz committed Dec 10, 2023
1 parent 0e973aa commit 2af33a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions language_practice/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,16 @@ def chart(self):
"""
Display the chart for the current word.
"""
cache = self.cache[self.current_entry.get_word()]
if "charts" not in cache:
return
charts = self.current_entry.get_charts()
if charts is None:
cache = self.cache[self.current_entry.get_word()]
if "charts" not in cache:
return
charts = cache["charts"]

termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.settings)
print("\033c", end="")
for chart in cache["charts"]:
for chart in charts:
print(tabulate(chart, tablefmt="pretty"), end="\n\n")
tty.setraw(sys.stdin)

Expand Down
7 changes: 7 additions & 0 deletions language_practice/toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, dct):
self.aspect = dct.get("aspect")
self.usage = dct.get("usage")
self.part_of_speech = dct.get("part_of_speech")
self.charts = dct.get("charts")
except KeyError as err:
error = f"Key {err} not found"
if hasattr(self, "word"):
Expand Down Expand Up @@ -57,6 +58,12 @@ def show_word(self):

return ret

def get_charts(self):
"""
Get the inflection charts as a list of lists.
"""
return self.charts


class TomlConfig:
"""
Expand Down

0 comments on commit 2af33a1

Please sign in to comment.