Cache : cache_manager
¶
Hierarchy:
source code documentation¶
manages the NXDL cache directories of this project
A key component necessary to validate both NeXus data files and NXDL class files is a current set of the NXDL definitions.
There are two cache directories:
the source cache
the user cache
Within each of these cache directories,
there may be one or more subdirectories, each
containing the NeXus definitions subdirectories and files (*.xml
,
*.xsl
, & *.xsd
) of a specific branch, release, tag, or commit hash
from the NeXus definitions repository.
- source cache
contains default set of NeXus NXDL files
- user cache
contains additional set(s) of NeXus NXDL files, installed by user
The cache_manager calls the github_handler and is called by schema_manager and nxdl_manager.
Public interface
|
manager both source and user caches |
Internal interface
|
return the first few unique characters of the git commit hash (SHA) |
|
read a structured object from the JSON file |
|
write the structured |
|
decide if this item should be extracted from the ZIP download |
|
decide if the download should be avoided (True: avoid, False: download) |
|
download & extract NXDL files from |
return a pyRestTable table describing all known file sets in both source and user caches |
|
provides comon methods to get the QSettings path and file name |
|
manage the source directory cache of NXDL files |
|
manage the user directory cache of NXDL files |
|
describe a single set of NXDL files |
- class punx.cache_manager.Base_Cache[source]¶
provides comon methods to get the QSettings path and file name
index all NXDL file sets in this cache
fileName
()full path of the QSettings file
path
()directory containing the QSettings file
cleanup
()removes any temporary directories
- class punx.cache_manager.CacheManager(*args, **kwargs)[source]¶
manager both source and user caches
install_NXDL_file_set
(grr[, user_cache, ...])using ref as a name, get the se of NXDL files from the NeXus GitHub
select_NXDL_file_set
([ref])return the named self.default_file_set instance or raise KeyError exception if unknown
return dictionary of all NXDL file sets in both source & user caches
cleanup
()removes any temporary directories
- install_NXDL_file_set(grr, user_cache=True, ref=None, force=False)[source]¶
using ref as a name, get the se of NXDL files from the NeXus GitHub
- Parameters
grr (obj) – instance of
GitHub_Repository_Reference
user_cache (bool) –
True
: use user cache, `` False``: use source cache (default)ref (str) – name to use when requesting from GitHub, (master, commit hash such as abc1234, branch name, release name such as v3.2, or tag name)
force (bool) – update if installed is not the same SHA
- select_NXDL_file_set(ref=None)[source]¶
return the named self.default_file_set instance or raise KeyError exception if unknown
- Return obj
- table_of_caches()[source]¶
return a pyRestTable table describing all known file sets in both source and user caches
- Returns obj
instance of pyRestTable.Table with all known file sets
Example:
============= ======= ====== =================== ======= =================================== NXDL file set type cache date & time commit path ============= ======= ====== =================== ======= =================================== v3.2 tag source 2017-01-18 23:12:44 e888dac /home/user/punx/src/punx/cache/v3.2 NXroot-1.0 tag user 2016-10-24 14:58:10 e0ad63d /home/user/.config/punx/NXroot-1.0 master branch user 2016-12-20 18:30:29 85d056f /home/user/.config/punx/master Schema-3.3 release user 2017-05-02 12:33:19 4aa4215 /home/user/.config/punx/Schema-3.3 a4fd52d commit user 2016-11-19 01:07:45 a4fd52d /home/user/.config/punx/a4fd52d ============= ======= ====== =================== ======= ===================================
- punx.cache_manager.extract_from_download(grr, path)[source]¶
download & extract NXDL files from
grr
into a subdirectory ofpath
USAGE:
grr = github_handler.GitHub_Repository_Reference() grr.connect_repo() if grr.request_info() is not None: extract_from_download(grr, cache_directory)
- punx.cache_manager.get_short_sha(full_sha)[source]¶
return the first few unique characters of the git commit hash (SHA)
- Parameters
full_sha (str) – hash code from Github
- punx.cache_manager.read_json_file(filename)[source]¶
read a structured object from the JSON file
file_name
- punx.cache_manager.should_avoid_download(grr, path)[source]¶
decide if the download should be avoided (True: avoid, False: download)
- Return bool
- punx.cache_manager.should_extract_this(item, NXDL_file_endings_list, allowed_parent_directories)[source]¶
decide if this item should be extracted from the ZIP download
- Return bool
- punx.cache_manager.table_of_caches()[source]¶
return a pyRestTable table describing all known file sets in both source and user caches
- Returns obj
instance of pyRestTable.Table with all known file sets
Example:
============= ======= ====== =================== ======= =================================== NXDL file set type cache date & time commit path ============= ======= ====== =================== ======= =================================== v3.2 tag source 2017-01-18 23:12:44 e888dac /home/user/punx/src/punx/cache/v3.2 NXroot-1.0 tag user 2016-10-24 14:58:10 e0ad63d /home/user/.config/punx/NXroot-1.0 master branch user 2016-12-20 18:30:29 85d056f /home/user/.config/punx/master Schema-3.3 release user 2017-05-02 12:33:19 4aa4215 /home/user/.config/punx/Schema-3.3 a4fd52d commit user 2016-11-19 01:07:45 a4fd52d /home/user/.config/punx/a4fd52d ============= ======= ====== =================== ======= ===================================