snowmobile.core.cache

Simple caching implementation for snowmobile.toml location.

Module Contents

Classes

Cache

Bare bones caching implementation for configuration file locations.

class snowmobile.core.cache.Cache

Bases: snowmobile.core.Generic

Bare bones caching implementation for configuration file locations.

file_nm

Name of file storing cached paths; defaults to snowmobile_cache.json.

Type

str

cache_dir

Path to cache directory within AppData.

Type

Path

location

Full path to snowmobile_cache.json.

Type

Path

contents

Cache contents (file path by file name).

Type

Dict

file_nm

Configuration file name; defaults to snowmobile_cache.json.

Type

str

cache_dir

Cache directory.

Type

pathlib.Path

location

Full path to snowmobile_cache.json.

Type

pathlib.Path

contents :Dict

Cached contents.

Type

Dict

save(self)ContextManager[Cache]

Writes changes to disk when exiting context of other methods.

save_item(self, item_name: str, item_value)

Caches item_value to be retrieved by item_name.

save_all(self, items: Dict)

Caches a dictionary of items

as_path(self, item_name: str)pathlib.Path

Utility to return item_name as a Path object.

clear(self, item: [List, str])

Clears an item or a list of items from the cache by name.

contains(self, item: Union[List, str])bool

Checks if an item or list of items exist in the cache.

get(self, item: str)

Fetch an item from contents.