Flatten indented config

Write codeMedium15 min

Your task

A CI pipeline file uses a tiny indentation format. Every non-blank line is indented by exactly 2 spaces per nesting level and contains a ":". A line whose text after the colon is empty, like "build:", opens a nested block; a line like "image: node:20" is a leaf whose value is everything after the FIRST colon, trimmed (values are never empty, and may themselves contain colons). Blank lines can appear anywhere and mean nothing. A block with no children contributes nothing. The document is well-formed. Flatten it into a dict mapping the dot-joined path of nested keys to each leaf value.

Examples

flatten_pipeline_config(lines: list[str]) -> dict[str,str]
Example 1
Inputflatten_pipeline_config(["build:", " image: node:20", " steps: install"])
Output{"build.image": "node:20", "build.steps": "install"}