From a8b4c7971682d81164e2de8cb4c9c83fd208ba3e Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Mon, 6 Nov 2023 09:36:30 +0100 Subject: [PATCH] Eliminate constructor --- toot/tui/richtext.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/toot/tui/richtext.py b/toot/tui/richtext.py index 66c1f27..e46de6b 100644 --- a/toot/tui/richtext.py +++ b/toot/tui/richtext.py @@ -10,13 +10,11 @@ from typing import List, Tuple from urwid.util import decompose_tagmarkup -class ContentParser: - def __init__(self): - self.palette_names = [] - for p in PALETTE: - self.palette_names.append(p[0]) +STYLE_NAMES = [p[0] for p in PALETTE] - """Parse a limited subset of HTML and create urwid widgets.""" + +class ContentParser: + """Parse a limited subset of HTML and create urwid widgets.""" def html_to_widgets(self, html, recovery_attempt=False) -> List[urwid.Widget]: """Convert html to urwid widgets""" @@ -187,7 +185,7 @@ class ContentParser: style_name = "class_" + "_".join(clss) # return the class name, only if we # find it as a defined palette name - if style_name in self.palette_names: + if style_name in STYLE_NAMES: return style_name # fallback to returning the tag name