单元测试和改进
This commit is contained in:
@@ -2,17 +2,18 @@ from textual.app import App, ComposeResult
|
|||||||
from textual.widgets import Button, Header, Label, Footer
|
from textual.widgets import Button, Header, Label, Footer
|
||||||
|
|
||||||
class HeurAMSApp(App):
|
class HeurAMSApp(App):
|
||||||
#CSS_PATH = "question02.tcss"
|
|
||||||
TITLE = "潜进"
|
TITLE = "潜进"
|
||||||
SUB_TITLE = "启发式辅助记忆调度器"
|
SUB_TITLE = "启发式辅助记忆调度器"
|
||||||
|
BINDINGS = [("q", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
||||||
|
|
||||||
def compose(self) -> ComposeResult:
|
def compose(self) -> ComposeResult:
|
||||||
yield Header(show_clock = True)
|
yield Header(show_clock = True)
|
||||||
|
|
||||||
yield Footer(show_command_palette = True)
|
yield Footer(show_command_palette = True)
|
||||||
|
|
||||||
def on_mount(self) -> None:
|
def on_mount(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
self.exit(event.button.id)
|
self.exit(event.button.id)
|
||||||
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
from textual.widget import Widget
|
|
||||||
|
|
||||||
class FileSelector(Widget):
|
|
||||||
def __init__(self, *children: Widget, name: str | None = None, id: str | None = None, classes: str | None = None, disabled: bool = False, markup: bool = True) -> None:
|
|
||||||
super().__init__(*children, name=name, id=id, classes=classes, disabled=disabled, markup=markup)
|
|
||||||
def a(self):
|
|
||||||
file_list_widget = self.query_one("#file-list", ListView)
|
|
||||||
nucleon_path = pathlib.Path("./nucleon")
|
|
||||||
nucleon_files = sorted(
|
|
||||||
[f for f in nucleon_path.iterdir() if f.suffix == ".toml"],
|
|
||||||
key=lambda f: Glimpse(pt.NucleonUnion(f)).next_date,
|
|
||||||
reverse=True
|
|
||||||
)
|
|
||||||
|
|
||||||
if nucleon_files:
|
|
||||||
for file in nucleon_files:
|
|
||||||
text = self.item_desc_generator(pathlib.Path(file))
|
|
||||||
file_list_widget.append(ListItem(
|
|
||||||
Label(text[0] + '\n' + text[1]),
|
|
||||||
))
|
|
||||||
else:
|
|
||||||
file_list_widget.append(
|
|
||||||
ListItem(Static("在 ./nucleon/ 中未找到任何内容源数据文件.\n请放置文件后重启应用.\n或者新建空的单元集."))
|
|
||||||
)
|
|
||||||
file_list_widget.disabled = True
|
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ class Fission():
|
|||||||
if random.random() <= possibility:
|
if random.random() <= possibility:
|
||||||
self.puzzles.append(puz.puzzles[item])
|
self.puzzles.append(puz.puzzles[item])
|
||||||
|
|
||||||
def iterator(self):
|
def generate(self):
|
||||||
yield from self.puzzles
|
yield from self.puzzles
|
||||||
0
src/heurams/providers/llm/openai.py
Normal file
0
src/heurams/providers/llm/openai.py
Normal file
Reference in New Issue
Block a user