Commit b16a7f2c authored by Lysander Trischler's avatar Lysander Trischler
Browse files

Don't crash if 'nick-colors' section is missing

parent 0b25af71
......@@ -259,3 +259,13 @@ class Config:
if os.path.isabs(path):
return path
return os.path.join(base_path, path)
def colors(self, name):
return self._cfg.get("colors", name, fallback=None)
def nick_colors(self):
if self._cfg.has_section("nick-colors"):
return self._cfg.items("nick-colors")
return []
......@@ -53,11 +53,10 @@ class Renderer:
def entry(name, fallback_fg, fallback_bg):
colors = config._cfg.get("colors", name, fallback=None)
colors = config.colors(name)
if colors is None:
return (name, fallback_fg, fallback_bg)
parsed = parse_colors(colors)
return (name, *parsed)
return (name, *parse_colors(colors))
self.palette = [
......@@ -86,7 +85,7 @@ class Renderer:
"link-normal": "link-focus",
self._nicks = set()
for nick, colors in config._cfg.items("colors.nicks"):
for nick, colors in config.nick_colors:
fg, bg = parse_colors(colors)
if not bg:
bg = "black"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment