zut.files.BaseAdapter

class zut.files.BaseAdapter

Bases: Generic[T_NormalizedPath]

__init__()

Methods

__init__()

copy(src, dst[, follow_symlinks])

Copy file data and file data and file's permission mode (which on Windows is only the read-only flag).

copy2(src, dst[, follow_symlinks])

Identical to copy() except that copy2() also attempts to preserve the file metadata.

copyfile(src, dst[, follow_symlinks])

Copy the contents (no metadata) in the most efficient way possible.

copymode(src, dst[, follow_symlinks])

Copy the permission bits from src to dst.

copystat(src, dst[, follow_symlinks])

Copy the read-only attribute, last access time, and last modification time from src to dst.

copytree(src, dst[, symlinks, ignore, ...])

Recursively copy a directory tree rooted at src to a directory named dst and return the destination directory.

exists(path)

makedirs(path, *[, exist_ok])

normalize_path(path)

open(path[, mode, buffering, encoding, ...])

remove(path, *[, missing_ok, tree_ok])

stat(path)

Attributes

open_context_cls

stat_cls

classmethod copy(src: str | PathLike, dst: str | PathLike, follow_symlinks=True) str

Copy file data and file data and file’s permission mode (which on Windows is only the read-only flag). Other metadata like file’s creation and modification times, are not preserved.

The destination may be a directory (in this case, the file will be copied into dst directory using the base filename from src).

If follow_symlinks is False, dst will be created as a symbolic link if src is a symbolic link. If follow_symlinks is True, dst will be a copy of the file src refers to.

classmethod copy2(src: str | PathLike, dst: str | PathLike, follow_symlinks=True) str

Identical to copy() except that copy2() also attempts to preserve the file metadata.

copy2() uses copystat() to copy the file metadata. Please see copystat() for more information about how and what metadata it copies to the dst file.

If follow_symlinks is False, dst will be created as a symbolic link if src is a symbolic link. If follow_symlinks is True, dst will be a copy of the file src refers to.

classmethod copyfile(src: str | PathLike, dst: str | PathLike, follow_symlinks=True) str

Copy the contents (no metadata) in the most efficient way possible.

If follow_symlinks is False, dst will be created as a symbolic link if src is a symbolic link. If follow_symlinks is True, dst will be a copy of the file src refers to.

classmethod copymode(src: str | PathLike, dst: str | PathLike, follow_symlinks=True) None

Copy the permission bits from src to dst. The file contents, owner, and group are unaffected.

Due to the limitations of Windows, this function only sets/unsets dst FILE_ATTRIBUTE_READ_ONLY flag based on what src attribute is set to.

If follow_symlinks is False and src and dst both refer to symbolic links, the attributes will be read and written on the symbolic links themselves (rather than the files the symbolic links refer to).

classmethod copystat(src: str | PathLike, dst: str | PathLike, follow_symlinks=True) None

Copy the read-only attribute, last access time, and last modification time from src to dst. The file contents, owner, and group are unaffected.

If follow_symlinks is False and src and dst both refer to symbolic links, the attributes will be read and written on the symbolic links themselves (rather than the files the symbolic links refer to).

classmethod copytree(src: str | PathLike, dst: str | PathLike, symlinks: bool = False, ignore: Callable[[str, list[str]], list[str]] | None = None, ignore_dangling_symlinks: bool = False, dirs_exist_ok: bool = False) str

Recursively copy a directory tree rooted at src to a directory named dst and return the destination directory.

Permissions and times of directories are copied with copystat(), individual files are copied using copy2().

If symlinks is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false, the contents of the files pointed to by symbolic links are copied. If the file pointed by the symlink doesn’t exist, an exception will be added. You can set ignore_dangling_symlinks to true if you want to silence this exception. Notice that this has no effect on platforms that don’t support os.symlink.

If dirs_exist_ok is false (the default) and dst already exists, an error is raised. If dirs_exist_ok is true, the copying operation will continue if it encounters existing directories, and files within the dst tree will be overwritten by corresponding files from the src tree.

If ignore is given, it must be a callable of the form ignore(src, names) -> ignored_names. It will be called recursively and will receive as its arguments the directory being visited (src) and a list of its content (names). It must return a subset of the items of names that must be ignored in the copy process.