Fix how urwidgets are vendeored

Should be done inside `toot` so that it doesn't clash when people have
toot installed alongside python-urwidgets.
pull/545/head
Ivan Habunek 2025-08-25 08:28:17 +02:00
rodzic 4b22680007
commit f73de3e699
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 01DB3DD0D824504C
8 zmienionych plików z 8 dodań i 20 usunięć

Wyświetl plik

@ -48,8 +48,8 @@ packages=[
"toot.cli",
"toot.tui",
"toot.tui.richtext",
"toot.urwidgets",
"toot.utils",
"urwidgets",
]
[tool.setuptools_scm]

Wyświetl plik

@ -1,6 +1,6 @@
from urwid import Divider, Filler, Pile
from toot.tui.richtext import url_to_widget
from urwidgets import Hyperlink, TextEmbed
from toot.urwidgets import Hyperlink, TextEmbed
from toot.tui.richtext.richtext import html_to_widgets

Wyświetl plik

@ -1,18 +1,6 @@
import urwid
from .richtext import html_to_widgets, url_to_widget
from toot.tui.utils import highlight_hashtags
from toot.utils import format_content
from typing import List
try:
from .richtext import html_to_widgets, url_to_widget
except ImportError:
# Fallback if urwidgets are not available
def html_to_widgets(html: str) -> List[urwid.Widget]:
return [
urwid.Text(highlight_hashtags(line))
for line in format_content(html)
]
def url_to_widget(url: str):
return urwid.Text(("link", url))
__all__ = (
"html_to_widgets",
"url_to_widget",
)

Wyświetl plik

@ -4,10 +4,10 @@ import unicodedata
from bs4.element import NavigableString, Tag
from toot.tui.constants import PALETTE
from toot.urwidgets import Hyperlink, TextEmbed
from toot.utils import parse_html, urlencode_url
from typing import List, Tuple
from urwid.util import decompose_tagmarkup
from urwidgets import Hyperlink, TextEmbed
STYLE_NAMES = [p[0] for p in PALETTE]