textmate_grammar.utils.cache#
Module Contents#
Classes#
Interface for a Textmate cache. |
|
A simple cache implementation for storing content elements. |
|
A cache implementation using the shelve module. |
Functions#
Initialize the cache based on the given type. |
Data#
API#
- textmate_grammar.utils.cache.CACHE_DIR = 'resolve(...)'#
- class textmate_grammar.utils.cache.TextmateCache#
Bases:
typing.ProtocolInterface for a Textmate cache.
- cache_valid(filepath: pathlib.Path) bool#
Check if the cache for the given filepath is valid.
- Parameters:
filepath – The path to the file.
- Returns:
True if the cache is valid, False otherwise.
- load(filepath: pathlib.Path) textmate_grammar.elements.ContentElement#
Load the content from the specified filepath.
- Parameters:
filepath – The path to the file to load.
- Returns:
The loaded content element.
- save(filePath: pathlib.Path, element: textmate_grammar.elements.ContentElement) None#
Save the given content element to the specified file path.
- Parameters:
filePath – The file path where the content element should be saved.
element – The content element to be saved.
- Returns:
None
- class textmate_grammar.utils.cache.SimpleCache#
Bases:
textmate_grammar.utils.cache.TextmateCacheA simple cache implementation for storing content elements.
Initialization
Initialize the SimpleCache.
- cache_valid(filepath: pathlib.Path) bool#
Check if the cache is valid for the given filepath.
- Parameters:
filepath – The filepath to check.
- Returns:
True if the cache is valid, False otherwise.
- load(filepath: pathlib.Path) textmate_grammar.elements.ContentElement#
Load the content element from the cache for the given filepath.
- Parameters:
filepath – The filepath to load the content element from.
- Returns:
The loaded content element.
- save(filepath: pathlib.Path, element: textmate_grammar.elements.ContentElement) None#
Save the content element to the cache for the given filepath.
- Parameters:
filepath – The filepath to save the content element to.
element – The content element to save.
- Returns:
None
- class textmate_grammar.utils.cache.ShelveCache#
Bases:
textmate_grammar.utils.cache.TextmateCacheA cache implementation using the shelve module.
Initialization
Initialize the ShelveCache.
- cache_valid(filepath: pathlib.Path) bool#
Check if the cache is valid for the given filepath.
- Parameters:
filepath – The filepath to check.
- Returns:
True if the cache is valid, False otherwise.
- load(filepath: pathlib.Path) textmate_grammar.elements.ContentElement#
Load the content element from the cache for the given filepath.
- Parameters:
filepath – The path for the cached content element.
- Returns:
The loaded content element.
- save(filepath: pathlib.Path, element: textmate_grammar.elements.ContentElement) None#
Save the content element to the cache for the given filepath.
- Parameters:
filepath – The filepath to save the content element to.
element – The content element to save.
- textmate_grammar.utils.cache.CACHE: textmate_grammar.utils.cache.TextmateCache = 'SimpleCache(...)'#
- textmate_grammar.utils.cache.init_cache(type: str = 'simple') textmate_grammar.utils.cache.TextmateCache#
Initialize the cache based on the given type.
- Parameters:
type – The type of cache to initialize. Defaults to “simple”.
- Returns:
The initialized cache object.