Overview

Path PyPoE/poe/file/shared/cache.py
Version 1.0.0a0
Revision $Id: 5ea9fe7986eed9718fcd927eaa1d8ec1498edb24 $
Author Omega_K2

Description

All file caches classes will inherit AbstractFileCache.

Warning

None of the abstract classes found here should be instantiated directly.

See also:

Agreement

See PyPoE/LICENSE

Documentation

class PyPoE.poe.file.shared.cache.AbstractFileCache(path_or_ggpk=None, files=None, files_shortcut=True, instance_options=None, read_options=None)[source]

Bases: PyPoE.shared.mixins.ReprMixin

Variables:
__init__(path_or_ggpk=None, files=None, files_shortcut=True, instance_options=None, read_options=None)[source]
Parameters:
  • path_or_ggpk (str | GGPKFile) – The root path (i.e. relative to content.ggpk) where the files are stored or a PyPoE.poe.file.ggpk.GGPKFile instance
  • files (Iterable) – Iterable of files that will be loaded right away
  • files_shortcut (bool) – Whether to use the shortcut function, i.e. self.__getitem__
  • instance_options (dict[str, object]) – options to pass to the file’s __init__ method
  • read_options (dict[str, object]) – options to pass to the file instance’s read method
Raises:
_create_instance(file_name, *args, **kwargs)[source]

Creates a new instance for the given file name

Parameters:file_name (str) – Name to the file to pass on
Returns:
Return type:File instance
_get_file_instance_args(file_name, *args, **kwargs)[source]

Returns a dictionary of keyword arguments to pass to the file’s __init__ method upon initial reading.

Parameters:file_name (str) – Name of the file
Returns:Dictionary of keyword arguments
Return type:dict[str, object]
_get_read_args(file_name, *args, **kwargs)[source]

Returns a dictionary of keyword arguments to pass to the file’s read method upon initial reading.

In particular it sets file_path_or_raw based on how the cache was instantiated.

Parameters:file_name (str) – Name of the file
Returns:Dictionary of keyword arguments
Return type:dict[str, object]
get_file(file_name, *args, **kwargs)[source]

Returns the the specified file from the cache.

If the file does not exist, read it from the path specified on cache creation, add it to the cache and then return it.

Parameters:file_name (str) – File to retrieve
Returns:read file instance
Return type:AbstractFileReadOnly
path_or_ggpk

The path or PyPoE.poe.file.ggpk.GGPKFile instance the cache was created with