blessings is now a dependency
This commit is contained in:
parent
76d2acf8a9
commit
6f83747699
|
@ -1,3 +1,6 @@
|
|||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[tool.mypy]
|
||||
ignore_missing_imports = true
|
||||
|
|
|
@ -16,6 +16,7 @@ classifiers =
|
|||
packages = tlfi
|
||||
python_requires = >= 3.7
|
||||
setup_requires = setuptools >= 38.3.0
|
||||
install_requires = blessings ~= 1.6
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
|
|
|
@ -15,17 +15,10 @@ import sys
|
|||
from pathlib import Path
|
||||
from typing import Generator
|
||||
|
||||
from blessings import Terminal
|
||||
from bs4 import BeautifulSoup, NavigableString
|
||||
|
||||
try:
|
||||
from blessings import Terminal
|
||||
t = Terminal()
|
||||
except ImportError:
|
||||
class DummyTerminal:
|
||||
def __getattr__(self, _):
|
||||
return ""
|
||||
t = DummyTerminal()
|
||||
|
||||
T = Terminal()
|
||||
TAG_STRIP_RE = re.compile(r"\s+")
|
||||
|
||||
|
||||
|
@ -84,17 +77,17 @@ def parse_tag(tag) -> str:
|
|||
if tag.name == "span":
|
||||
classes = tag.get("class") or []
|
||||
if "tlf_cdefinition" in classes:
|
||||
content = f"{t.yellow}{content}{t.normal}"
|
||||
content = f"{T.yellow}{content}{T.normal}"
|
||||
if "tlf_cdomaine" in classes:
|
||||
content = f"{t.red}{content}{t.normal}"
|
||||
content = f"{T.red}{content}{T.normal}"
|
||||
if "tlf_csyntagme" in classes:
|
||||
content = f"{t.green}{content}{t.normal}"
|
||||
content = f"{T.green}{content}{T.normal}"
|
||||
if "tlf_cmot" in classes:
|
||||
content = f"{t.reverse}{content}{t.normal}"
|
||||
content = f"{T.reverse}{content}{T.normal}"
|
||||
if tag.name == "b":
|
||||
content = f"{t.bold}{content}{t.normal}"
|
||||
content = f"{T.bold}{content}{T.normal}"
|
||||
if tag.name == "i":
|
||||
content = f"{t.italic}{content}{t.no_italic}"
|
||||
content = f"{T.italic}{content}{T.no_italic}"
|
||||
return content
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue