debian-forge/osbuild/formats/v1.py
Christian Kellner b49ee53d0a formats/v1: add type hints
Add type hints to most arguments and return types to aid editors
and type checking.
2021-01-09 18:09:47 +01:00

33 lines
943 B
Python

# Version 1 of the manifest description
from typing import Dict
from ..pipeline import Pipeline, detect_host_runner
def load_build(description: Dict, sources_options: Dict):
pipeline = description.get("pipeline")
if pipeline:
build_pipeline = load(pipeline, sources_options)
else:
build_pipeline = None
return build_pipeline, description["runner"]
def load(description: Dict, sources_options: Dict) -> Pipeline:
build = description.get("build")
if build:
build_pipeline, runner = load_build(build, sources_options)
else:
build_pipeline, runner = None, detect_host_runner()
pipeline = Pipeline(runner, build_pipeline)
for s in description.get("stages", []):
pipeline.add_stage(s["name"], sources_options, s.get("options", {}))
a = description.get("assembler")
if a:
pipeline.set_assembler(a["name"], a.get("options", {}))
return pipeline