diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-11-18 14:09:30 +0100 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2021-01-21 08:54:35 -0500 |
commit | 9ba7b0ebd064517832cc37f45d8f549666a06825 (patch) | |
tree | 6021e2abf757cfb3a64d427e422be292bde4334a /mesonbuild/mlog.py | |
parent | 05ab792d58860715f0bbc9986963fb30bd49ac36 (diff) | |
download | meson-9ba7b0ebd064517832cc37f45d8f549666a06825.zip meson-9ba7b0ebd064517832cc37f45d8f549666a06825.tar.gz meson-9ba7b0ebd064517832cc37f45d8f549666a06825.tar.bz2 |
mlog: add __str__ method to AnsiDecorator
Automatically colorize the text when printing the AnsiDecorator, based
on the result of mlog.colorize_console(). This is how AnsiDecorator
is used most of the time anyway.
Diffstat (limited to 'mesonbuild/mlog.py')
-rw-r--r-- | mesonbuild/mlog.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py index 0cffba7..6207d98 100644 --- a/mesonbuild/mlog.py +++ b/mesonbuild/mlog.py @@ -130,6 +130,9 @@ class AnsiDecorator: text = '"{}"'.format(text) return text + def __str__(self) -> str: + return self.get_text(colorize_console()) + def bold(text: str, quoted: bool = False) -> AnsiDecorator: return AnsiDecorator(text, "\033[1m", quoted=quoted) |