Dir
Qt Base Class: QDir
Signature: QDir(self, arg__1: Union[PySide6.QtCore.QDir, str]) -> None
QDir(self, path: Union[str, bytes, os.PathLike, NoneType]) -> None
QDir(self, path: Union[str, bytes, os.PathLike], nameFilter: str, sort: PySide6.QtCore.QDir.SortFlag = Instance(QDir.SortFlags(QDir.SortFlag.Name | QDir.SortFlag.IgnoreCase)), filter: PySide6.QtCore.QDir.Filter = Instance(QDir.Filter.AllEntries)) -> None
Base classes
Name |
Children |
Inherits |
QDir PySide6.QtCore QDir(self, arg__1: Union[PySide6.QtCore.QDir, str]) -> None |
|
|
⋔ Inheritance diagram
graph TD
1473299866752["core.Dir"]
1473288939840["QtCore.QDir"]
1473291690208["Shiboken.Object"]
140713234304496["builtins.object"]
1473288939840 --> 1473299866752
1473291690208 --> 1473288939840
140713234304496 --> 1473291690208
🛈 DocStrings
Bases: QDir
Access to directory structures and their contents.
Source code in prettyqt\core\dir.py
| class Dir(core.QDir):
"""Access to directory structures and their contents."""
def __getattr__(self, attr: str):
return getattr(self.to_path(), attr)
def __repr__(self):
return get_repr(self, self.absolutePath())
def __str__(self):
return self.absolutePath()
def __reduce__(self):
return type(self), (self.absolutePath(),)
def __truediv__(self, other: datatypes.PathType) -> pathlib.Path:
return self.to_path() / os.fspath(other)
def __fspath__(self) -> str:
return self.absolutePath()
def __bool__(self):
return self.exists()
def __abs__(self) -> str:
return self.absolutePath()
@property
def _absolutePath(self) -> str:
return self.absolutePath()
__match_args__ = ("_absolutePath",)
def to_path(self) -> pathlib.Path:
return pathlib.Path(self.absolutePath())
def set_filter(self, *filters: FilterStr):
flags = FILTERS.merge_flags(filters)
self.setFilter(flags)
def get_filter(self) -> list[FilterStr]:
return FILTERS.get_list(self.filter())
def get_entry_info_list(
self, sort_mode: SortFlagStr = "no_sort", filters: FilterStr = "none"
) -> list[core.FileInfo]:
return [
core.FileInfo(i)
for i in self.entryInfoList(
sort=SORT_FLAG[sort_mode],
filters=self.Filter.AllEntries | FILTERS[filters],
)
]
def get_entry_list(
self, sort_mode: SortFlagStr = "no_sort", filters: FilterStr = "none"
) -> list[pathlib.Path]:
return [
pathlib.Path(i)
for i in self.entryList(sort=SORT_FLAG[sort_mode], filters=FILTERS[filters])
]
@classmethod
def get_current(cls) -> Self:
return cls(cls.current())
@classmethod
def get_home(cls) -> Self:
return cls(cls.home())
@classmethod
def get_current_path(cls) -> pathlib.Path:
return pathlib.Path(cls.currentPath())
@classmethod
def get_home_path(cls) -> pathlib.Path:
return pathlib.Path(cls.homePath())
@classmethod
def get_temp_path(cls) -> pathlib.Path:
return pathlib.Path(cls.tempPath())
@classmethod
def get_drives(cls) -> list[core.FileInfo]:
return [core.FileInfo(i) for i in cls.drives()]
@classmethod
def add_search_path(cls, prefix: str, path: datatypes.PathType):
cls.addSearchPath(prefix, os.fspath(path))
@classmethod
def set_search_paths(cls, prefix: str, paths: Iterable[datatypes.PathType]):
cls.setSearchPaths(prefix, [os.fspath(p) for p in paths])
|