mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: add aurweb-config console script
This can be used to update config values for the entirety of a config. When config values are set through this tool, $AUR_CONFIG is overridden with a copy of the config file with all sections and options found in $AUR_CONFIG + $AUR_CONFIG_DEFAULTS. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
e558e979ff
commit
759f18ea75
4 changed files with 199 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
import configparser
|
||||
import os
|
||||
|
||||
from typing import Any
|
||||
|
||||
# Publicly visible version of aurweb. This is used to display
|
||||
# aurweb versioning in the footer and must be maintained.
|
||||
# Todo: Make this dynamic/automated.
|
||||
|
@ -52,3 +54,13 @@ def getint(section, option, fallback=None):
|
|||
def get_section(section):
|
||||
if section in _get_parser().sections():
|
||||
return _get_parser()[section]
|
||||
|
||||
|
||||
def replace_key(section: str, option: str, value: Any) -> Any:
|
||||
_get_parser().set(section, option, value)
|
||||
|
||||
|
||||
def save() -> None:
|
||||
aur_config = os.environ.get("AUR_CONFIG", "/etc/aurweb/config")
|
||||
with open(aur_config, "w") as fp:
|
||||
_get_parser().write(fp)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue