law.target.local#

Local target implementations.

Class LocalFileSystem#

class LocalFileSystem(section: str | None = None, *, base: str | None = None, **kwargs)[source]#

Bases: FileSystem, LocalFileSystem

exists(path: str | Path, *, stat: bool = False, **kwargs) bool | stat_result | None[source]#

Return True if file or directory at path exist, False otherwise

Parameters:

path (str) – a path within the FileSystem to check for existence.

isdir(path: str | Path, **kwargs) bool[source]#

Return True if the location at path is a directory. If not, return False.

Parameters:

path (str) – a path within the FileSystem to check as a directory.

Note: This method is optional, not all FileSystem subclasses implements it.

remove(path: str | Path, *, recursive: bool = True, silent: bool = True, **kwargs) bool[source]#

Remove file or directory at location path

Parameters:
  • path (str) – a path within the FileSystem to remove.

  • recursive (bool) – if the path is a directory, recursively remove the directory and all of its descendants. Defaults to True.

mkdir(path: str | Path, *, perm: int | None = None, recursive: bool = True, silent: bool = True, **kwargs) bool[source]#

Create directory at location path

Creates the directory at path and implicitly create parent directories if they do not already exist.

Parameters:
  • path (str) – a path within the FileSystem to create as a directory.

  • parents (bool) – Create parent directories when necessary. When parents=False and the parent directory doesn’t exist, raise luigi.target.MissingParentDirectory

  • raise_if_exists (bool) – raise luigi.target.FileAlreadyExists if the folder already exists.

listdir(path: str | Path, *, pattern: str | None = None, type: Literal['f', 'd'] | None = None, **kwargs) list[str][source]#

Return a list of files rooted in path.

This returns an iterable of the files rooted at path. This is intended to be a recursive listing.

Parameters:

path (str) – a path within the FileSystem to list.

Note: This method is optional, not all FileSystem subclasses implements it.

copy(src: str | Path, dst: str | Path, *, perm=None, dir_perm=None, **kwargs)[source]#

Copy a file or a directory with contents. Currently, LocalFileSystem and MockFileSystem support only single file copying but S3Client copies either a file or a directory as required.

move(src: str | Path, dst: str | Path, perm: int | None = None, dir_perm: int | None = None, **kwargs) str[source]#

Move a file, as one would expect.

Class LocalTarget#

class LocalTarget(path: str | ~pathlib.Path | None = None, fs: ~law.target.local.LocalFileSystem = LocalFileSystem(name=local_fs, 0x79e402f0fa90), *, is_tmp: bool | str = False, tmp_dir: str | ~pathlib.Path | ~law.target.local.LocalDirectoryTarget | None = None, **kwargs)[source]#

Bases: FileSystemTarget, LocalTarget

fs: FileSystem = LocalFileSystem(name=local_fs, 0x79e402f0fa90)#
open: Callable | None = None#
directory_class#

alias of LocalDirectoryTarget

file_class#

alias of LocalFileTarget

Class LocalFileTarget#

class LocalFileTarget(path: str | ~pathlib.Path | None = None, fs: ~law.target.local.LocalFileSystem = LocalFileSystem(name=local_fs, 0x79e402f0fa90), *, is_tmp: bool | str = False, tmp_dir: str | ~pathlib.Path | ~law.target.local.LocalDirectoryTarget | None = None, **kwargs)[source]#

Bases: FileSystemFileTarget, LocalTarget

Class LocalDirectoryTarget#

class LocalDirectoryTarget(path: str | ~pathlib.Path | None = None, fs: ~law.target.local.LocalFileSystem = LocalFileSystem(name=local_fs, 0x79e402f0fa90), *, is_tmp: bool | str = False, tmp_dir: str | ~pathlib.Path | ~law.target.local.LocalDirectoryTarget | None = None, **kwargs)[source]#

Bases: FileSystemDirectoryTarget, LocalTarget