forked from Mirror/pmbootstrap
pmb.helpers.other.cache: simplify (MR 2252)
The init_cache() function just assigned some default constants, simplify this by just declaring it that way to begin with, as well as adding type hints. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
3bfc6474bb
commit
7ed08e74d3
4 changed files with 20 additions and 30 deletions
|
@ -216,9 +216,6 @@ def switch_to_channel_branch(args: PmbArgs, channel_new):
|
|||
" fix what git complained about, then try again: "
|
||||
f"{args.aports}")
|
||||
|
||||
# Invalidate all caches
|
||||
pmb.helpers.other.init_cache()
|
||||
|
||||
# Verify pmaports.cfg on new branch
|
||||
read_config(args)
|
||||
return True
|
||||
|
|
|
@ -113,7 +113,6 @@ def init(args: PmbArgs):
|
|||
fix_mirrors_postmarketos(args)
|
||||
pmb.config.merge_with_args(args)
|
||||
replace_placeholders(args)
|
||||
pmb.helpers.other.init_cache()
|
||||
|
||||
# Initialize logs (we could raise errors below)
|
||||
pmb.helpers.logging.init(args)
|
||||
|
|
|
@ -10,6 +10,7 @@ import pmb.config.init
|
|||
from pmb.core.types import PmbArgs
|
||||
import pmb.helpers.pmaports
|
||||
import pmb.helpers.run
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
def folder_size(args: PmbArgs, path: Path):
|
||||
|
@ -97,7 +98,7 @@ def migrate_work_folder(args: PmbArgs):
|
|||
logging.info("* Building chroots have a different username (#709)")
|
||||
logging.info("Migration will do the following:")
|
||||
logging.info("* Zap your chroots")
|
||||
logging.info("* Adjust '" + pmb.config.work / "config_abuild/abuild.conf'")
|
||||
logging.info(f"* Adjust '{pmb.config.work / 'config_abuild/abuild.conf'}'")
|
||||
if not pmb.helpers.cli.confirm(args):
|
||||
raise RuntimeError("Aborted.")
|
||||
|
||||
|
@ -117,8 +118,7 @@ def migrate_work_folder(args: PmbArgs):
|
|||
logging.info("Changelog:")
|
||||
logging.info("* Fix: cache_distfiles was writable for everyone")
|
||||
logging.info("Migration will do the following:")
|
||||
logging.info("* Fix permissions of '" + pmb.config.work +
|
||||
"/cache_distfiles'")
|
||||
logging.info(f"* Fix permissions of '{pmb.config.work / 'cache_distfiles'}'")
|
||||
if not pmb.helpers.cli.confirm(args):
|
||||
raise RuntimeError("Aborted.")
|
||||
|
||||
|
@ -155,7 +155,7 @@ def migrate_work_folder(args: PmbArgs):
|
|||
logging.info(" 'git' instead of using it from an Alpine chroot")
|
||||
logging.info("Migration will do the following:")
|
||||
logging.info("* Check if 'git' is installed")
|
||||
logging.info("* Change ownership to your user: " + path)
|
||||
logging.info(f"* Change ownership to your user: {path}")
|
||||
if not pmb.helpers.cli.confirm(args):
|
||||
raise RuntimeError("Aborted.")
|
||||
|
||||
|
@ -236,8 +236,8 @@ def migrate_work_folder(args: PmbArgs):
|
|||
if current != required:
|
||||
raise RuntimeError("Sorry, we can't migrate that automatically. Please"
|
||||
" run 'pmbootstrap shutdown', then delete your"
|
||||
" current work folder manually ('sudo rm -rf " +
|
||||
pmb.config.work + "') and start over with 'pmbootstrap"
|
||||
" current work folder manually ('sudo rm -rf "
|
||||
f"{pmb.config.work}') and start over with 'pmbootstrap"
|
||||
" init'. All your binary packages and caches will"
|
||||
" be lost.")
|
||||
|
||||
|
@ -281,14 +281,8 @@ def lookup(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": {},
|
||||
cache: Dict[str, Any] = {
|
||||
"apkindex": {},
|
||||
"apkbuild": {},
|
||||
"apk_min_version_checked": [],
|
||||
"apk_repository_list_updated": [],
|
||||
|
@ -296,7 +290,8 @@ def init_cache():
|
|||
"find_aport": {},
|
||||
"pmb.helpers.package.depends_recurse": {},
|
||||
"pmb.helpers.package.get": {},
|
||||
"pmb.helpers.repo.update": repo_update,
|
||||
"pmb.helpers.repo.update": {"404": [], "offline_msg_shown": False},
|
||||
"pmb.helpers.git.parse_channels_cfg": {},
|
||||
"pmb.config.pmaports.read_config": None,
|
||||
"pmb.config.pmaports.read_config_repos": None}
|
||||
"pmb.config.pmaports.read_config_repos": None,
|
||||
}
|
||||
|
|
|
@ -593,7 +593,6 @@ def package_completer(prefix, action, parser=None, parsed_args=None):
|
|||
args = parsed_args
|
||||
pmb.config.merge_with_args(args)
|
||||
pmb.helpers.args.replace_placeholders(args)
|
||||
pmb.helpers.other.init_cache()
|
||||
packages = set(
|
||||
package for package in pmb.helpers.pmaports.get_list(args)
|
||||
if package.startswith(prefix))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue