1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-13 11:29:46 +03:00

Fix pmbootstrap config mirrors.… <NEW_VALUE> (MR 2385)

Don't fail with:
  type object 'Config' has no attribute 'mirrors.pmaports'

Fixes: issue 2420
This commit is contained in:
Oliver Smith 2024-07-28 20:45:25 +02:00
parent 08758bef90
commit 86d38d451b
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -242,7 +242,12 @@ def config(args: PmbArgs):
logging.info(f"Config changed to default: {args.name}='{def_value}'") logging.info(f"Config changed to default: {args.name}='{def_value}'")
pmb.config.save(args.config, config) pmb.config.save(args.config, config)
elif args.value is not None: elif args.value is not None:
if isinstance(getattr(Config, args.name), list): if args.name.startswith("mirrors."):
name = args.name.split(".", 1)[1]
# Ignore mypy 'error: TypedDict key must be a string literal'.
# Argparse already ensures 'name' is a valid Config.Mirrors key.
config.mirrors[name] = args.value # type: ignore
elif isinstance(getattr(Config, args.name), list):
setattr(config, args.name, args.value.split(",")) setattr(config, args.name, args.value.split(","))
else: else:
setattr(config, args.name, args.value) setattr(config, args.name, args.value)