Skip to content

StorageInfo

Qt Base Class: QStorageInfo

Signature: QStorageInfo(self) -> None QStorageInfo(self, dir: Union[PySide6.QtCore.QDir, str]) -> None QStorageInfo(self, other: PySide6.QtCore.QStorageInfo) -> None QStorageInfo(self, path: str) -> None

Base classes

Name Children Inherits
QStorageInfo
PySide6.QtCore
QStorageInfo(self) -> None

⋔ Inheritance diagram

graph TD
  1473299877488["core.StorageInfo"]
  1473243763728["QtCore.QStorageInfo"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473243763728 --> 1473299877488
  1473291690208 --> 1473243763728
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: QStorageInfo

Provides information about currently mounted storage and drives.

Source code in prettyqt\core\storageinfo.py
class StorageInfo(QtCore.QStorageInfo):
    """Provides information about currently mounted storage and drives."""

    def __init__(
        self,
        path: QtCore.QStorageInfo | QtCore.QDir | datatypes.PathType | None = None,
    ):
        if path is None:
            super().__init__()
        else:
            if isinstance(path, os.PathLike):
                path = os.fspath(path)
            super().__init__(path)

    def __bool__(self):
        return self.isValid()

    def __repr__(self):
        return get_repr(self, self.rootPath())

    def get_device(self) -> str:
        return self.device().data().decode()

    def get_file_system_type(self) -> str:
        return self.fileSystemType().data().decode()

    def get_subvolume(self) -> str:
        return self.subvolume().data().decode()

    def get_root_path(self) -> pathlib.Path:
        return pathlib.Path(self.rootPath())

    @classmethod
    def get_root(cls) -> Self:
        return cls(cls.root())

    @classmethod
    def get_mounted_volumes(cls) -> list[Self]:
        return [cls(i) for i in cls.mountedVolumes()]