Archived
0
0

style: 代码格式化

This commit is contained in:
2025-12-13 21:47:37 +08:00
parent a0b327cdbb
commit baa7ac8ee9
64 changed files with 755 additions and 573 deletions

View File

@@ -14,6 +14,7 @@ from .base_puzzle_widget import BasePuzzleWidget
from typing import TypedDict, List
from textual.message import Message
class RecognitionConfig(TypedDict):
__origin__: str
__hint__: str
@@ -21,16 +22,35 @@ class RecognitionConfig(TypedDict):
secondary: List[str]
top_dim: List[str]
class Recognition(BasePuzzleWidget):
def __init__(self, *children: Widget, atom: pt.Atom, alia: str = "", name: str | None = None, id: str | None = None, classes: str | None = None, disabled: bool = False, markup: bool = True) -> None:
super().__init__(*children, atom=atom, name=name, id=id, classes=classes, disabled=disabled, markup=markup)
def __init__(
self,
*children: Widget,
atom: pt.Atom,
alia: str = "",
name: str | None = None,
id: str | None = None,
classes: str | None = None,
disabled: bool = False,
markup: bool = True,
) -> None:
super().__init__(
*children,
atom=atom,
name=name,
id=id,
classes=classes,
disabled=disabled,
markup=markup,
)
if alia == "":
alia = "Recognition"
self.alia = alia
def compose(self):
cfg: RecognitionConfig = self.atom.registry["orbital"]["puzzles"][self.alia]
delim = self.atom.registry['nucleon'].metadata["formation"]["delimiter"]
delim = self.atom.registry["nucleon"].metadata["formation"]["delimiter"]
replace_dict = {
", ": ",",
". ": ".",
@@ -43,8 +63,8 @@ class Recognition(BasePuzzleWidget):
f":{delim}": ":",
}
nucleon = self.atom.registry['nucleon']
metadata = self.atom.registry['nucleon'].metadata
nucleon = self.atom.registry["nucleon"]
metadata = self.atom.registry["nucleon"].metadata
primary = cfg["primary"]
with Center():
@@ -53,7 +73,7 @@ class Recognition(BasePuzzleWidget):
for old, new in replace_dict.items():
primary = primary.replace(old, new)
primary_splited = re.split(r"(?<=[,;:|])", cfg['primary'])
primary_splited = re.split(r"(?<=[,;:|])", cfg["primary"])
for item in primary_splited:
with Center():
yield Label(
@@ -68,7 +88,7 @@ class Recognition(BasePuzzleWidget):
continue
if isinstance(item, Dict):
total = ""
for j, k in item.items(): # type: ignore
for j, k in item.items(): # type: ignore
total += f"> **{j}**: {k} \n"
yield Markdown(total)
if isinstance(item, str):
@@ -79,4 +99,4 @@ class Recognition(BasePuzzleWidget):
def on_button_pressed(self, event: Button.Pressed) -> None:
if event.button.id == "ok":
self.screen.rating = 5 # type: ignore
self.screen.rating = 5 # type: ignore