Cache : cache_manager
#
Hierarchy:
source code documentation#
Manage 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
is called by
main
,
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. |
Download the NXDL definitions described by |
|
|
Download & extract NXDL file set into a subdirectory of |
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
directory containing the QSettings file
cleanup
()removes any temporary directories
- property all_file_sets#
index all NXDL file sets in this cache
- property path#
directory containing the QSettings file
- class punx.cache_manager.CacheManager(*args, **kwargs)[source]#
manager both source and user caches
select_NXDL_file_set
([ref])Return the named self.default_file_set instance.
return dictionary of all NXDL file sets in both source & user caches
cleanup
()removes any temporary directories
- property all_file_sets#
return dictionary of all NXDL file sets in both source & user caches
- select_NXDL_file_set(ref=None)[source]#
Return the named self.default_file_set instance.
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 cache date & time commit path ============= ====== =================== ======= ================================================================== a4fd52d source 2016-11-19 01:07:45 a4fd52d /home/prjemian/Documents/projects/prjemian/punx/punx/cache/a4fd52d v3.3 source 2017-07-12 10:41:12 9285af9 /home/prjemian/Documents/projects/prjemian/punx/punx/cache/v3.3 v2018.5 source 2018-05-15 16:34:19 a3045fd /home/prjemian/Documents/projects/prjemian/punx/punx/cache/v2018.5 Schema-3.4 user 2018-05-15 08:24:34 aa1ccd1 /home/prjemian/.config/punx/Schema-3.4 main user 2021-12-17 13:09:18 041c2c0 /home/prjemian/.config/punx/main ============= ====== =================== ======= ==================================================================
- punx.cache_manager.download_NeXus_zip_archive(url)[source]#
Download the NXDL definitions described by
url
.Return the downloaded content in memory.
- punx.cache_manager.download_file_set(file_set_name, cache_path, replace=False)[source]#
Download & extract NXDL file set into a subdirectory of
cache_path
.- file_set_name str :
Name of the NXDL file_set to be downloaded.
- cache_path obj :
Directory with NXDL file_sets (instance of
pathlib.Path
). (A file_set is a directory with a version of the NeXus definitions repository.)- replace bool :
If
True
and file set exists, replace it. (default:False
)
USAGE:
download_file_set(file_set_name, cache_path, replace=False)
- 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.is_extractable(item, allowed_endings, allowed_parents)[source]#
decide if this item should be extracted from the ZIP download.
- Return bool:
- punx.cache_manager.read_json_file(filename)[source]#
read a structured object from the JSON file
file_name
- 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 cache date & time commit path ============= ====== =================== ======= ================================================================== a4fd52d source 2016-11-19 01:07:45 a4fd52d /home/prjemian/Documents/projects/prjemian/punx/punx/cache/a4fd52d v3.3 source 2017-07-12 10:41:12 9285af9 /home/prjemian/Documents/projects/prjemian/punx/punx/cache/v3.3 v2018.5 source 2018-05-15 16:34:19 a3045fd /home/prjemian/Documents/projects/prjemian/punx/punx/cache/v2018.5 Schema-3.4 user 2018-05-15 08:24:34 aa1ccd1 /home/prjemian/.config/punx/Schema-3.4 main user 2021-12-17 13:09:18 041c2c0 /home/prjemian/.config/punx/main ============= ====== =================== ======= ==================================================================