plesty.sdk.cache ================ .. py:module:: plesty.sdk.cache .. autoapi-nested-parse:: Cache management. Classes ------- .. autoapisummary:: plesty.sdk.cache.CachedFile Functions --------- .. autoapisummary:: plesty.sdk.cache.ensure_cache plesty.sdk.cache.gitignore plesty.sdk.cache.sdk_version Module Contents --------------- .. py:class:: CachedFile(filename: str) Function decorator for defining cached (text) files with content generated at runtime. This class also serves as a registry of files to be cached. Add the File object to the registry. :param filename: The path to the file to be cached, relative to the '.plesty' cache directory. .. py:attribute:: registry :type: ClassVar[list[CachedFile]] :value: [] Registry of instanciated CachedFile objects. .. py:attribute:: filename :type: str The path to the file to be cached, relative to the '.plesty' cache directory. .. py:attribute:: content :type: collections.abc.Callable[[], str] The decorated function that generates the content of the cached file. .. py:method:: __call__(content: collections.abc.Callable[[], str]) -> None Apply the decorator to a function. .. py:method:: generate(cache_directory: pathlib.Path) -> None Write the content of the cached file to disk. :param cache_directory: The path to the '.plesty' cache directory. .. py:method:: is_correct(cache_directory: pathlib.Path) -> bool Check whether the cached file is up-to-date by comparing the generated content with the content of the existing file on disk. :param cache_directory: The path to the '.plesty' cache directory. :returns: False, if the file does not exist on disk or its content is not up-to-date. True otherwise. .. py:function:: ensure_cache(project_directory: pathlib.Path) -> pathlib.Path Ensure that the '.plesty' cache directory exists and that all files are up-to-date. If not, (re)create the cache. :param project_directory: The path to the Python project directory. :returns: The path to the '.plesty' cache directory. .. py:function:: gitignore() -> str This file causes the entire '.plesty' cache directory to be ignored by version control. .. py:function:: sdk_version() -> str This file specifies the version number of the Plesty SDK used when creating the cache.