2024-12-09 18:31:22 +00:00
|
|
|
"""
|
|
|
|
Protocols for supporting classes in pathlib.
|
|
|
|
"""
|
|
|
|
from typing import Protocol, runtime_checkable
|
|
|
|
|
|
|
|
|
|
|
|
@runtime_checkable
|
2025-02-08 01:16:45 +00:00
|
|
|
class _PathParser(Protocol):
|
2024-12-09 18:31:22 +00:00
|
|
|
"""Protocol for path parsers, which do low-level path manipulation.
|
|
|
|
|
|
|
|
Path parsers provide a subset of the os.path API, specifically those
|
2025-01-11 19:27:47 +00:00
|
|
|
functions needed to provide JoinablePath functionality. Each JoinablePath
|
2024-12-09 18:31:22 +00:00
|
|
|
subclass references its path parser via a 'parser' class attribute.
|
|
|
|
"""
|
|
|
|
|
|
|
|
sep: str
|
|
|
|
def split(self, path: str) -> tuple[str, str]: ...
|
|
|
|
def splitext(self, path: str) -> tuple[str, str]: ...
|
|
|
|
def normcase(self, path: str) -> str: ...
|
2025-02-08 01:16:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
@runtime_checkable
|
|
|
|
class PathInfo(Protocol):
|
|
|
|
"""Protocol for path info objects, which support querying the file type.
|
|
|
|
Methods may return cached results.
|
|
|
|
"""
|
|
|
|
def exists(self, *, follow_symlinks: bool = True) -> bool: ...
|
|
|
|
def is_dir(self, *, follow_symlinks: bool = True) -> bool: ...
|
|
|
|
def is_file(self, *, follow_symlinks: bool = True) -> bool: ...
|
|
|
|
def is_symlink(self) -> bool: ...
|