Skip to content

brainhops._core.path

Internal module

brainhops._core.path is internal. It is documented here only to explain the type hints that appear in the public API. Do not import it, and do not rely on anything in it: its contents can change or disappear without notice.

Attributes

FilenameLike module-attribute

FilenameLike = PathLike | str

A PathLike or str that represents a filename.

BinaryFileLike module-attribute

BinaryFileLike = FilenameLike | tx.BinaryIO

A path to a file or a binary file object.

TextFileLike module-attribute

TextFileLike = FilenameLike | tx.TextIO

A path to a file or a text file object.

FileLike module-attribute

A path to a file or a file object.

BinaryContentLike module-attribute

BinaryContentLike = bytes | bytearray | tx.Iterable[bytes]

The content of a binary file: a bytes, bytearray or an iterable of bytes.

TextContentLike module-attribute

TextContentLike = str | tx.Iterable[str]

The content of a text file: a str or an iterable of str.

ContentLike module-attribute

The content of a text or binary file.

FileOrContentLike module-attribute

FileOrContentLike = FileLike | ContentLike

A path to a file, a file object, or the content of a file.

TextFileOrContentLike module-attribute

TextFileOrContentLike = TextFileLike | TextContentLike

A path to a text file, a text file object, or the content of a text file.

BinaryFileOrContentLike module-attribute

BinaryFileOrContentLike = BinaryFileLike | BinaryContentLike

A path to a binary file, a binary file object, or the content of a binary file.

Functions:

exists

exists(filename: FilenameLike) -> bool

Whether a file exists.

A name too long for the file system to look up names no file. Such a "name" is usually file content handed over where a path was expected, and is reported as a missing file rather than as an OSError from deep inside stat. Any other error is raised.