chiptools.core.cache module
- class chiptools.core.cache.FileCache(cache_path)[source]
Bases:
object
A FileCache instance can be used to create and maintain a cache of fileObjects so that file changes can be detected to allow intelligent recompilation. The FileCache accepts a project file path during creation, the cache file will be generated in the same directory as the Project file and will use a name derived from the Project file name. File objects can be added to the cache and the is_file_changed method can be used to determine if a given File object has been modified since it was last added to the cache.
Internally the cache file is stored as a Pickled dictionary of two items:
LIBRARIES : A set of libraries that were added to the cache using add_library
FILES : A dictionary of file path / file md5 sum pairs of files added using add_file
- add_file(fileObject, tool_name)[source]
Add the given fileObject to the local cache file/md5 dictionary. The FileObject MD5 and compilation time are updated by this method before it is added to the cache.
- add_library(library, tool_name)[source]
Add the given library name to the local cache dictionary library name set.
- blank_cache_element: Dict[str, Any] = {'FILES': {}, 'LIBRARIES': {}}
- cache_file_name = '_compilation.cache'
- field_id_files = 'FILES'
- field_id_libraries = 'LIBRARIES'
- initialise_cache()[source]
Initialise the FileCache by generating a new cache file and clearing the local cache dictionary.
- is_file_changed(file_object, tool_name)[source]
Compare the given md5 with the given file path from the cache, if the match return True or return False if the hashes do not match or the file does not exist.
- library_in_cache(libname, tool_name)[source]
Return True if the given libname library name is present in the local cache dictionary.
- load_cache()[source]
Load the cache file pointed to by this FileCache instance. If no cache file is present a new one will be created.