单元测试和改进
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user