30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
import configparser
|
|
import platform
|
|
from pathlib import Path
|
|
|
|
CONFIG_FILE = Path.home() / ".config/userman/userman.conf"
|
|
|
|
def load_config():
|
|
config = configparser.ConfigParser(allow_no_value=True)
|
|
config.read(str(CONFIG_FILE))
|
|
|
|
options = config["options"] if "options" in config else {}
|
|
|
|
return {
|
|
"db_path": Path(options.get("DBPath", "~/.local/share/userman/db")).expanduser(),
|
|
"cache_dir": Path(options.get("CacheDir", "~/.cache/userman/pkg")).expanduser(),
|
|
"gpg_dir": Path(options.get("GPGDir", "~/.config/userman/gnupg")).expanduser(),
|
|
"hook_dir": Path(options.get("HookDir", "~/.config/userman/hooks")).expanduser(),
|
|
"log_file": Path(options.get("LogFile", "~/.local/share/userman/pacman.log")).expanduser(),
|
|
"root_dir": Path(options.get("RootDir", "~")).expanduser(),
|
|
"arch": options.get("Architecture", "auto").replace("auto", platform.machine()),
|
|
}
|
|
|
|
def get_repos() -> dict:
|
|
config = configparser.ConfigParser(allow_no_value=True)
|
|
config.read(str(CONFIG_FILE))
|
|
return {
|
|
section: config[section]["server"]
|
|
for section in config.sections()
|
|
if section.lower() != "options" and "server" in config[section]
|
|
} |