betty.fs module

Provide file system utilities.

betty.fs.CACHE_DIRECTORY_PATH = PosixPath('/home/docs/.betty/cache')

Define the path to the cache directory.

Deprecated since version 0.3.3: This constant is deprecated as of Betty 0.3.3, and will be removed in Betty 0.4.x. Instead, use betty.cache.file.BinaryFileCache.

class betty.fs.FileSystem(*paths)[source]

Bases: object

Parameters:
*paths

clear()[source]
Return type:

None

async copy2(source_path, destination_path)[source]
Parameters:
source_path

destination_path

Return type:

pathlib.Path

async copytree(source_path, destination_path)[source]
Parameters:
source_path

destination_path

Return type:

typing.AsyncIterable[pathlib.Path]

open(*file_paths)[source]
Parameters:
*file_paths

Return type:

betty.fs._Open

property paths : Sequence[tuple[Path, str | None]]
prepend(path, fs_encoding=None)[source]
Parameters:
path

fs_encoding=None

Return type:

None

betty.fs.hashfile(path)[source]

Get a hash for a file.

This function relies on the file path and last modified time for uniqueness. File contents are ignored.

Parameters:
path

Return type:

str

async betty.fs.iterfiles(path)[source]

Recursively iterate over any files found in a directory.

Parameters:
path

Return type:

typing.AsyncIterable[pathlib.Path]