forked from Mirror/pmbootstrap
args.cache: remove (MR 2136)
Replace "args.cache" with a global variable in order to avoid passing "args" to all functions. This is a step to get rid of this args-passed-to-all-functions pattern in pmbootstrap.
This commit is contained in:
parent
f30b1cc3f2
commit
ce0f1c2d4a
23 changed files with 127 additions and 115 deletions
|
@ -275,3 +275,37 @@ def validate_hostname(hostname):
|
|||
" sign")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
"""
|
||||
pmbootstrap uses this dictionary to save the result of expensive
|
||||
results, so they work a lot faster the next time they are needed in the
|
||||
same session. Usually the cache is written to and read from in the same
|
||||
Python file, with code similar to the following:
|
||||
|
||||
def lookup(key):
|
||||
if key in pmb.helpers.other.cache["mycache"]:
|
||||
return pmb.helpers.other.cache["mycache"][key]
|
||||
ret = expensive_operation(args, key)
|
||||
pmb.helpers.other.cache["mycache"][key] = ret
|
||||
return ret
|
||||
"""
|
||||
cache = None
|
||||
|
||||
|
||||
def init_cache():
|
||||
global cache
|
||||
""" Add a caching dict (caches parsing of files etc. for the current
|
||||
session) """
|
||||
repo_update = {"404": [], "offline_msg_shown": False}
|
||||
cache = {"apkindex": {},
|
||||
"apkbuild": {},
|
||||
"apk_min_version_checked": [],
|
||||
"apk_repository_list_updated": [],
|
||||
"built": {},
|
||||
"find_aport": {},
|
||||
"pmb.helpers.package.depends_recurse": {},
|
||||
"pmb.helpers.package.get": {},
|
||||
"pmb.helpers.repo.update": repo_update,
|
||||
"pmb.helpers.git.parse_channels_cfg": {},
|
||||
"pmb.config.pmaports.read_config": None}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue