summaryrefslogtreecommitdiff
path: root/src/buildstream/testing/_yaml.py
blob: ccf65a1ae45d43c58d09c27b997809a915f86bd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import os

from buildstream._yaml import roundtrip_dump  # type: ignore


def generate_project(project_dir, config=None):
    if config is None:
        config = {}
    project_file = os.path.join(project_dir, "project.conf")
    if "name" not in config:
        config["name"] = os.path.basename(project_dir)
    roundtrip_dump(config, project_file)


def generate_element(element_dir, element_name, config=None):
    if config is None:
        config = {}
    element_path = os.path.join(element_dir, element_name)
    roundtrip_dump(config, element_path)