MCPcopy Index your code
hub / github.com/bpython/bpython / load_theme

Function load_theme

bpython/config.py:379–398  ·  view source on GitHub ↗
(
    path: Path,
    colors: MutableMapping[str, str],
    default_colors: Mapping[str, str],
)

Source from the content-addressed store, hash-verified

377
378
379def 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

Callers 1

__init__Method · 0.85

Calls 1

UnknownColorCodeClass · 0.85

Tested by

no test coverage detected