util: replace toml imports with our util module

This commit is contained in:
Achilleas Koutsou 2024-08-15 14:17:25 +02:00 committed by Michael Vogt
parent 292d4ad0fe
commit bce908e4a2

View file

@ -188,17 +188,12 @@ def get_host_storage():
""" """
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
# importing this at the top level will break the buildroot # importing this at the top level will break the buildroot
try: from osbuild.util import toml
import tomllib as toml
except ImportError:
import tomli as toml
config_paths = ("/etc/containers/storage.conf", "/usr/share/containers/storage.conf") config_paths = ("/etc/containers/storage.conf", "/usr/share/containers/storage.conf")
for conf_path in config_paths: for conf_path in config_paths:
try: try:
with open(conf_path, "rb") as conf_file: return toml.load_from_file(conf_path)
storage_conf = toml.load(conf_file)
return storage_conf
except FileNotFoundError: except FileNotFoundError:
pass pass