Abstract base class for pathlib.Path-like API.
tfds.core.Path(
*args
) -> _T
See pathlib.Path documentation.
Args | |
---|---|
*args
|
Paths to create |
Methods
as_posix
as_posix()
Return the string representation of the path with forward (/) slashes.
as_uri
as_uri()
Return the path as a 'file' URI.
copy
copy(
dst: PathLike, overwrite: bool = False
) -> _T
Copy the current file to the given destination.
exists
exists() -> bool
Returns True if self exists.
expanduser
expanduser() -> _T
Returns a new path with expanded ~
and ~user
constructs.
format
format(
*args, **kwargs
) -> _T
Apply str.format()
to the path.
glob
glob(
pattern: str
) -> Iterator[_T]
Yields all matching files (of any kind).
is_absolute
is_absolute()
True if the path is absolute (has both a root and, if applicable, a drive).
is_dir
is_dir() -> bool
Returns True if self is a dir.
is_file
is_file() -> bool
Returns True if self is a file.
is_relative_to
is_relative_to(
*other
) -> bool
Return True if the path is relative to another path or False.
is_reserved
is_reserved()
Return True if the path contains one of the special names reserved by the system, if any.
iterdir
iterdir() -> Iterator[_T]
Iterates over the directory.
joinpath
joinpath(
*args
)
Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored).
match
match(
path_pattern
)
Return True if this path matches the given pattern.
mkdir
mkdir(
mode: int = 511, parents: bool = False, exist_ok: bool = False
) -> None
Create a new directory at this given path.
open
open(
mode: str = 'r',
encoding: Optional[str] = None,
errors: Optional[str] = None,
**kwargs
) -> typing.IO[AnyStr]
Opens the file.
read_bytes
read_bytes() -> bytes
Reads contents of self as bytes.
read_text
read_text(
encoding: Optional[str] = None
) -> str
Reads contents of self as a string.
relative_to
relative_to(
*other
)
Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError.
rename
rename(
target: PathLike
) -> _T
Renames the path.
replace
replace(
target: PathLike
) -> _T
Overwrites the destination path.
resolve
resolve(
strict: bool = False
) -> _T
Returns the absolute path.
rglob
rglob(
pattern: str
) -> Iterator[_T]
Yields all matching files recursively (of any kind).
rmdir
rmdir() -> None
Remove the empty directory at this given path.
rmtree
rmtree(
missing_ok: bool = False
) -> None
Remove the directory, including all sub-files.
stat
stat() -> stat_utils.StatResult
Returns metadata for the file/directory.
touch
touch(
mode: int = 438, exist_ok: bool = True
) -> None
Create a file at this given path.
unlink
unlink(
missing_ok: bool = False
) -> None
Remove this file or symbolic link.
with_name
with_name(
name
)
Return a new path with the file name changed.
with_stem
with_stem(
stem
)
Return a new path with the stem changed.
with_suffix
with_suffix(
suffix
)
Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
write_bytes
write_bytes(
data: bytes
) -> int
Writes content as bytes.
write_text
write_text(
data: str, encoding: Optional[str] = None, errors: Optional[str] = None
) -> int
Writes content as str.
__eq__
__eq__(
other
)
Return self==value.
__ge__
__ge__(
other
)
Return self>=value.
__gt__
__gt__(
other
)
Return self>value.
__le__
__le__(
other
)
Return self<=value.
__lt__
__lt__(
other
)
Return self<value.
__rtruediv__
__rtruediv__(
key
)
__truediv__
__truediv__(
key
)