Skip to content

FileInfo

Base classes

Name Children Inherits
QFileInfo
PySide6.QtCore
QFileInfo(self, /) -> None

⋔ Inheritance diagram

graph TD
  2030644677["core.FileInfo"]
  1947337139["QtCore.QFileInfo"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  1947337139 --> 2030644677
  37984305 --> 1947337139
  2751680898 --> 37984305

🛈 DocStrings

Bases: QFileInfo

System-independent file information.

Source code in prettyqt/core/fileinfo.py
class FileInfo(core.QFileInfo):
    """System-independent file information."""

    def __init__(self, *args, **kwargs):
        if len(args) == 1 and isinstance(args[0], os.PathLike):
            super().__init__(os.fspath(args[0]))
        else:
            super().__init__(*args, **kwargs)

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

    @property
    def _absoluteFilePath(self) -> str:
        return self.absoluteFilePath()

    __match_args__ = ("_absoluteFilePath",)

    def __str__(self):
        return self.absoluteFilePath()

    def __fspath__(self) -> str:
        return self.absoluteFilePath()

    def __getattr__(self, attr: str) -> Any:
        return getattr(self.get_absolute_file_path(), attr)

    def __reduce__(self):
        return type(self), (self.absoluteFilePath(),)

    def get_dir(self) -> pathlib.Path:
        return pathlib.Path(self.dir().absolutePath())

    def get_absolute_file_path(self) -> pathlib.Path:
        return pathlib.Path(self.absoluteFilePath())

    def get_birth_time(self) -> core.DateTime:
        return core.DateTime(self.birthTime())

    def get_metadata_change_time(self) -> core.DateTime:
        return core.DateTime(self.metadataChangeTime())

    def get_last_modified(self) -> core.DateTime:
        return core.DateTime(self.lastModified())

    def get_last_read(self) -> core.DateTime:
        return core.DateTime(self.lastRead())

:fa-brands-github: Show source on GitHub