コード例 #1
0
ファイル: libraries_window.py プロジェクト: Timtam/bookstone
    def editLibrary(self, lib: Library) -> None:

        dlg: DetailsDialog = DetailsDialog(
            BackendTabs[cast(Type[Backend], type(lib.getBackend()))], lib,
            self)

        success: int = dlg.exec_()

        if not success:
            return

        lib.save()
        self.libraries_model.updateLibrary(lib)
コード例 #2
0
    def indexFolderStructure(self, lib: Library) -> Node:

        tree: Node = Node()
        tree.setDirectory()

        backend: Backend = cast(Backend, lib.getBackend())

        open: queue.Queue[Node] = queue.Queue()

        open.put(tree)

        while not open.empty():

            if QThread.currentThread().isInterruptionRequested():
                raise ThreadStoppedError()

            next: Node = open.get()

            next_path: str = next.getPath().as_posix()

            dir_list: List[str] = backend.listDirectory(next_path)

            for dir in dir_list:

                new: Node = Node()
                new.setName(dir)

                if backend.isDirectory(os.path.join(next_path, dir)):
                    new.setDirectory()
                else:
                    new.setFile()

                if new.isFile():

                    # check file extensions
                    _, ext = os.path.splitext(new.getName())

                    if not ext.lower() in getSupportedFileExtensions():
                        del new
                        continue

                next.addChild(new)

                if new.isDirectory():
                    open.put(new)

        return tree