mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-26 14:42:56 +00:00
Strip multi-word rich tags when rich is not installed (#1807)
Without `rich` installed, `kasa` prints tags like `[bold red]Only discover is available without --host or --alias[/bold red]` verbatim. The fallback in `kasa/cli/common.py` strips only single-word tags (`\[/?[a-z]+]`), and `error()` uses the two-word `[bold red]`. The pattern is changed to `\[/?[a-z]+(?: [a-z]+)*]`, so space-separated lowercase words are stripped too.
This commit is contained in:
@@ -34,7 +34,7 @@ except ImportError:
|
||||
# but only lower case tags to avoid stripping out
|
||||
# raw data from the device that is printed from
|
||||
# the device state.
|
||||
rich_formatting = re.compile(r"\[/?[a-z]+]")
|
||||
rich_formatting = re.compile(r"\[/?[a-z]+(?: [a-z]+)*]")
|
||||
|
||||
def _strip_rich_formatting(echo_func):
|
||||
"""Strip rich formatting from messages."""
|
||||
|
||||
Reference in New Issue
Block a user