arcache.cache module¶
This provides a handy image cache for PIL heavy TKInter work.
- class arcache.cache.Cache(config_file: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/arcache/checkouts/latest/arcache/default.ini'), debug: bool = False)[source]¶
Bases:
object
This provides the LRU cache logic.
- cache_loaded = False¶
- clear(persistent: bool = False)[source]¶
This allows us to clear the cache contents, if persistent is set to True the saved cache file will also be removed.
- load_image()[source]¶
This will load an image file into data and cleanup the file instance.
Take careful note of the image open, load, update, and close operations used here. If this process is improperly altered it will result in significant memory leakage.
- class arcache.cache.SlugCache(config_file: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/arcache/checkouts/latest/arcache/default.ini'), debug: bool = False)[source]¶
Bases:
arcache.cache.Cache
This will allow us to store and update our images to reduce cpu overhead.
- from_memory = False¶
- provide(callback, *args, **kwargs) <module 'PIL.Image' from '/home/docs/checkouts/readthedocs.org/user_builds/arcache/envs/latest/lib/python3.9/site-packages/PIL/Image.py'> [source]¶
- This will check to see if the callback output is already in the cache and if so return it,
Otherwise the callback will be executed, the results returned, and then cached.
- arcache.cache.clean_args(args: list, kwargs: dict, exclusive: bool = False) dict [source]¶
Removes keys to prevent errors.
- arcache.cache.config(config_file: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/arcache/checkouts/latest/arcache/default.ini'), section: str = 'cache') <module 'configparser' from '/home/docs/.asdf/installs/python/3.9.7/lib/python3.9/configparser.py'> [source]¶
This will grab our settings. TODO: We should move this into our larger config parser deal at a later time. :return: configparser
- arcache.cache.get_args(args: list, kwargs: dict, clean: bool = False) list [source]¶
This will fetch arguments and jazz.
- arcache.cache.get_name()[source]¶
This created a name based on passed arguments (handy for caching by config).
- arcache.cache.prep_env(config_file: pathlib.Path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/arcache/checkouts/latest/arcache/default.ini'), reload: bool = False) pathlib.Path [source]¶
This will get our filesystem setup for saving and transforming resources.
- arcache.cache.slugify(value, allow_unicode=False)[source]¶
Taken from https://github.com/django/django/blob/master/django/utils/text.py Convert to ASCII if ‘allow_unicode’ is False. Convert spaces or repeated dashes to single dashes. Remove characters that aren’t alphanumerics, underscores, or hyphens. Convert to lowercase. Also strip leading and trailing whitespace, dashes, and underscores.