|
1 | 1 | import os.path |
2 | 2 | import sys |
3 | | -from pathlib import Path |
4 | 3 |
|
5 | 4 | import fsspec |
6 | 5 | from PyQt5.QtWidgets import ( |
@@ -38,6 +37,8 @@ def __init__(self, path=None, parent=None): |
38 | 37 | if path is None: |
39 | 38 | # implicitly local |
40 | 39 | path = os.path.expanduser("~") |
| 40 | + self.fs: fsspec.AbstractFileSystem |
| 41 | + self.path: str |
41 | 42 | self.fs, self.path = fsspec.url_to_fs(path) |
42 | 43 | self.addDockWidget(Qt.BottomDockWidgetArea, self.library) |
43 | 44 |
|
@@ -80,7 +81,11 @@ def __init__(self, path=None, parent=None): |
80 | 81 | self.populate_tree() |
81 | 82 |
|
82 | 83 | def path_set(self): |
83 | | - self.fs, _ = fsspec.url_to_fs(self.path_text.text()) |
| 84 | + try: |
| 85 | + self.fs, _ = fsspec.url_to_fs(self.path_text.text()) |
| 86 | + except Exception: |
| 87 | + self.statusBar().showMessage("filesystem instantiation failed") |
| 88 | + return |
84 | 89 | self.path = self.path_text.text() |
85 | 90 | self.populate_tree() |
86 | 91 |
|
@@ -119,7 +124,10 @@ def add_children(self, parent_item, path): |
119 | 124 | # Add dummy child to make it expandable |
120 | 125 | dummy = QTreeWidgetItem(child_item) |
121 | 126 | dummy.setText(0, "Loading...") |
122 | | - if item["name"] in library.entries: |
| 127 | + if ( |
| 128 | + item["name"] in library.entries |
| 129 | + or self.fs.unstrip_protocol(item["name"]) in library.entries |
| 130 | + ): |
123 | 131 | child_item.setIcon( |
124 | 132 | 0, style.standardIcon(QStyle.SP_FileDialogInfoView) |
125 | 133 | ) |
@@ -234,7 +242,9 @@ def refresh(self): |
234 | 242 | data = library.filter(self.dia.search_criteria) |
235 | 243 | for path in sorted(data): |
236 | 244 | self.list.addTopLevelItem( |
237 | | - QTreeWidgetItem([path, " ".join(library.entries[path].specs)]) |
| 245 | + QTreeWidgetItem( |
| 246 | + [path, library.entries[path].text_summary().rsplit(":", 1)[-1]] |
| 247 | + ) |
238 | 248 | ) |
239 | 249 | self.show() |
240 | 250 |
|
|
0 commit comments