pestifer.util.cacheable_object module¶
Implements the general-purpose CacheableObject class and the TarBytesFS class.
- class pestifer.util.cacheable_object.CacheableObject(resource_root: str | Path, *, cache_dir: str | Path | object | None = None, force_rebuild: bool = False, ignore_suffixes: Iterable[str] = (), resource_label: str | None = None, **kwargs)[source]¶
Bases:
objectBase/mixin providing native cache/de-cache behavior controlled by resource mtimes.
Subclasses must implement:
_build_from_resources(self, resource_root: Path) -> Noneto populate self from files in resource_root.Behavior:
On __init__, compare cache mtime to newest file mtime under
resource_root.If cache is fresh, hydrate
selffrom cache and setself.from_cache = True.Else, call
_build_from_resources(...), ensureself.from_cache = False, and write cache.
- APP_NAME = 'pestifer'¶
- APP_VERSION = '2.5.2'¶
- CACHE_COMPRESS = ('gzip', 3)¶
- CACHE_PREFIX = 'cacheobj'¶
- VERSION_SCOPE = 'major.minor'¶
- class pestifer.util.cacheable_object.TarBytesFS(tar_bytes: bytes, compression: str | None = None)[source]¶
Bases:
objectA class for handling tarred bytes as a filesystem.
- compression¶
- classmethod from_file(path: str | Path, compression: str | None = None)[source]¶
Initializes a TarBytesFS instance from a file.
- open(path: str, mode: str = 'rb')[source]¶
Opens a file in the tarred filesystem and returns a context handle to that file.
- tar_bytes¶