summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2020-10-09 15:11:01 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2020-10-09 15:11:01 +0200
commit627f751e0c00c0f208e0688698d90a0c186b435b (patch)
tree3cf9d7003d6c532a0be1eaf2027663493ead10c3
parent6224f650d3448301313671d4466a3f3bd67e73e0 (diff)
downloadpoezio-627f751e0c00c0f208e0688698d90a0c186b435b.tar.gz
poezio-627f751e0c00c0f208e0688698d90a0c186b435b.tar.bz2
poezio-627f751e0c00c0f208e0688698d90a0c186b435b.tar.xz
poezio-627f751e0c00c0f208e0688698d90a0c186b435b.zip
poezio/user: rework change_color to only log when necessary
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/user.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/poezio/user.py b/poezio/user.py
index 9a14e6b1..1bae612f 100644
--- a/poezio/user.py
+++ b/poezio/user.py
@@ -83,15 +83,17 @@ class User:
self.nick = nick
def change_color(self, color_name: Optional[str], deterministic=False):
- color = xhtml.colors.get(color_name)
- if color is None:
- log.error('Unknown color "%s"', color_name)
+ if color_name is None:
if deterministic:
self.set_deterministic_color()
else:
self.color = choice(get_theme().LIST_COLOR_NICKNAMES)
else:
- self.color = (color, -1)
+ color = xhtml.colors.get(color_name)
+ if color is None:
+ log.error('Unknown color "%s"', color_name)
+ else:
+ self.color = (color, -1)
def set_last_talked(self, time: datetime):
"""