(
path: Path,
colors: MutableMapping[str, str],
default_colors: Mapping[str, str],
)
| 377 | |
| 378 | |
| 379 | def load_theme( |
| 380 | path: Path, |
| 381 | colors: MutableMapping[str, str], |
| 382 | default_colors: Mapping[str, str], |
| 383 | ) -> None: |
| 384 | theme = ConfigParser() |
| 385 | with open(path) as f: |
| 386 | theme.read_file(f) |
| 387 | for k, v in chain(theme.items("syntax"), theme.items("interface")): |
| 388 | if theme.has_option("syntax", k): |
| 389 | colors[k] = theme.get("syntax", k) |
| 390 | else: |
| 391 | colors[k] = theme.get("interface", k) |
| 392 | if colors[k].lower() not in COLOR_LETTERS: |
| 393 | raise UnknownColorCode(k, colors[k]) |
| 394 | |
| 395 | # Check against default theme to see if all values are defined |
| 396 | for k, v in default_colors.items(): |
| 397 | if k not in colors: |
| 398 | colors[k] = v |
no test coverage detected