craft_parts.sources.cache module

Cache base and file cache.

class craft_parts.sources.cache.FileCache(cache_dir, *, namespace='files')[source]

Bases: object

Cache files based on the supplied key.

Parameters:
  • cache_dir (Path) –

  • namespace (str) –

cache(*, filename, key)[source]

Cache a file revision with hash in XDG cache, unless it already exists.

Parameters:
  • filename (str) – The path to the file to cache.

  • key (str) – The key to cache the file under.

Return type:

Optional[Path]

Returns:

The path to the cached file, or None if the file was not cached.

clean()[source]

Remove all files from the cache namespace.

Return type:

None

get(*, key)[source]

Get the filepath which matches the hash calculated with algorithm.

Parameters:

key (str) – The key used to cache the file.

Return type:

Optional[Path]

Returns:

The path to cached file, or None if the file is not cached.