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

config: file: add usage note to save() (MR 2252)

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-13 22:48:08 +02:00 committed by Oliver Smith
parent 8fbc3a450d
commit af826c671d
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -1,7 +1,8 @@
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from pathlib import Path, PosixPath
from typing import List
from typing import Any, List, Optional
import pmb.config
from pmb.helpers import logging
import configparser
import os
@ -104,7 +105,13 @@ def serialize(config: Config, skip_defaults=True) -> configparser.ConfigParser:
return cfg
# FIXME: we should have distinct Config and ConfigFile types
def save(output: Path, config: Config):
"""Save the config object to the specified path.
IMPORTANT: The global config (available via get_context().config)
has invocation arguments merged into it. Do NOT call save() with
the global config object."""
logging.debug(f"Save config: {output}")
output.parent.mkdir(parents=True, exist_ok=True)
output.touch(0o700, exist_ok=True)