mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-13 01:30:31 +08:00
refactoring
This commit is contained in:
parent
4d6da37f40
commit
55cbd7fec8
@ -133,20 +133,20 @@ class Storage:
|
|||||||
def get_watchable_paths(self) -> list[str]:
|
def get_watchable_paths(self) -> list[str]:
|
||||||
paths: list[str] = []
|
paths: list[str] = []
|
||||||
for (root_path, dirs, _) in os.walk(self.__path):
|
for (root_path, dirs, _) in os.walk(self.__path):
|
||||||
dirs[:] = list(self.__filter(dirs))
|
dirs[:] = list(self.__filtered(dirs))
|
||||||
paths.append(root_path)
|
paths.append(root_path)
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
def get_images(self) -> dict[str, Image]:
|
def get_images(self) -> dict[str, Image]:
|
||||||
images: dict[str, Image] = {}
|
images: dict[str, Image] = {}
|
||||||
for (root_path, dirs, files) in os.walk(self.__path):
|
for (root_path, dirs, files) in os.walk(self.__path):
|
||||||
dirs[:] = list(self.__filter(dirs))
|
dirs[:] = list(self.__filtered(dirs))
|
||||||
for file in self.__filter(files):
|
for file in self.__filtered(files):
|
||||||
name = os.path.relpath(os.path.join(root_path, file), self.__path)
|
name = os.path.relpath(os.path.join(root_path, file), self.__path)
|
||||||
images[name] = self.get_image_by_name(name)
|
images[name] = self.get_image_by_name(name)
|
||||||
return images
|
return images
|
||||||
|
|
||||||
def __filter(self, items: list[str]) -> Generator[str, None, None]:
|
def __filtered(self, items: list[str]) -> Generator[str, None, None]:
|
||||||
for item in sorted(map(str.strip, items)):
|
for item in sorted(map(str.strip, items)):
|
||||||
if not item.startswith(".") and item != "lost+found":
|
if not item.startswith(".") and item != "lost+found":
|
||||||
yield item
|
yield item
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user