aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mlog.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-05 23:22:15 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-06 06:25:12 +0000
commit1415cd2d07477158bcc03a333a78522a3c972938 (patch)
treea6f34233bfff91afffd3d28404dff299ec4dc059 /mesonbuild/mlog.py
parentf2b008f874cfdbb75e113b761abfc5df80c67a77 (diff)
downloadmeson-1415cd2d07477158bcc03a333a78522a3c972938.zip
meson-1415cd2d07477158bcc03a333a78522a3c972938.tar.gz
meson-1415cd2d07477158bcc03a333a78522a3c972938.tar.bz2
mlog: Add built-in support for quoting bolded messages
This allows us to drop wonky sep='' hacks and manual addition of spaces across the codebase.
Diffstat (limited to 'mesonbuild/mlog.py')
-rw-r--r--mesonbuild/mlog.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index d17b889..3baa07a 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -57,17 +57,21 @@ def shutdown():
class AnsiDecorator:
plain_code = "\033[0m"
- def __init__(self, text, code):
+ def __init__(self, text, code, quoted=False):
self.text = text
self.code = code
+ self.quoted = quoted
def get_text(self, with_codes):
+ text = self.text
if with_codes:
- return self.code + self.text + AnsiDecorator.plain_code
- return self.text
+ text = self.code + self.text + AnsiDecorator.plain_code
+ if self.quoted:
+ text = '"{}"'.format(text)
+ return text
-def bold(text):
- return AnsiDecorator(text, "\033[1m")
+def bold(text, quoted=False):
+ return AnsiDecorator(text, "\033[1m", quoted=quoted)
def red(text):
return AnsiDecorator(text, "\033[1;31m")