Exemplo n.º 1
0
    def warning(self, message, header='WARNING', lc = 'red', raw = False):
        if type(message) == str:
            message = remove_spaces(message)

        message_line = ''
        header_line = c("\n%s\n%s\n" % (header, '=' * (self.width + 2)), lc)
        if raw:
            message_line = c("%s\n\n" % (message), lc)
        else:
            message_line = c("%s\n\n" % (textwrap.fill(str(message), 80)), lc)

        self.write(header_line + message_line)
Exemplo n.º 2
0
    def info_single(self, message, mc = 'yellow', nl_before = 0, nl_after = 0, cut_after = 80):
        if type(message) == str:
            message = remove_spaces(message)

        if cut_after:
            message_line = c("* %s\n" % (textwrap.fill(str(message), cut_after)), mc)
        else:
            message_line = c("* %s\n" % str(message), mc)

        message_line = ('\n' * nl_before) + message_line + ('\n' * nl_before)

        self.write(message_line)
Exemplo n.º 3
0
    def info_single(self, message, mc="yellow", nl_before=0, nl_after=0, cut_after=80):
        if type(message) == str:
            message = remove_spaces(message)

        if cut_after:
            message_line = c("* %s\n" % (textwrap.fill(str(message), cut_after)), mc)
        else:
            message_line = c("* %s\n" % str(message), mc)

        if self.verbose:
            sys.stderr.write("\n" * nl_before)
            sys.stderr.write(message_line)
            sys.stderr.write("\n" * nl_after)
Exemplo n.º 4
0
    def warning(self, message, header='WARNING', lc='red', raw=False, overwrite_verbose=False, nl_before=0, nl_after=0):
        if isinstance(message, str):
            message = remove_spaces(message)

        message_line = ''
        header_line = c("%s\n%s\n%s\n" % (('\n' * nl_before), header,
                                          '=' * (self.width + 2)), lc)
        if raw:
            message_line = c("%s\n\n%s" % ((message), '\n' * nl_after), lc)
        else:
            message_line = c("%s\n\n%s" % (textwrap.fill(str(message), 80), '\n' * nl_after), lc)

        self.write((header_line + message_line) if message else header_line, overwrite_verbose=overwrite_verbose)
Exemplo n.º 5
0
    def warning(self, message, header="WARNING", lc="red", raw=False):
        if type(message) == str:
            message = remove_spaces(message)

        header_line = c("\n%s\n%s\n" % (header, "=" * (self.width + 2)), lc)
        if raw:
            message_line = c("%s\n\n" % (message), lc)
        else:
            message_line = c("%s\n\n" % (textwrap.fill(str(message), 80)), lc)

        if self.verbose:
            sys.stderr.write(header_line)
            if message:
                sys.stderr.write(message_line)
Exemplo n.º 6
0
    def info(self, key, value, quiet = False, display_only = False, nl_before = 0, nl_after = 0, lc = 'cyan', mc = 'yellow'):
        if not display_only:
            self.info_dict[key] = value

        if type(value) == str:
            value = remove_spaces(value)
        if type(value) == int:
            value = pretty_print(value)

        label = constants.get_pretty_name(key)

        info_line = "%s%s %s: %s\n%s" % ('\n' * nl_before, c(label, lc),
                                         '.' * (self.width - len(label)),
                                         c(str(value), mc), '\n' * nl_after)

        self.write(info_line, quiet = quiet)
Exemplo n.º 7
0
    def info(self, key, value, quiet=False, display_only=False, lc="cyan", mc="yellow"):
        if not display_only:
            self.info_dict[key] = value

        if quiet:
            return True

        if type(value) == str:
            value = remove_spaces(value)
        if type(value) == int:
            value = pretty_print(value)

        label = constants.get_pretty_name(key)

        info_line = "%s %s: %s\n" % (c(label, lc), "." * (self.width - len(label)), c(str(value), mc))

        if self.info_file_obj:
            self.info_file_obj.write(info_line)

        if self.verbose:
            sys.stderr.write(info_line)
Exemplo n.º 8
0
    def info_single(self, message, mc='yellow', nl_before=0, nl_after=0, cut_after=80, level=1, progress=None):
        if isinstance(message, str):
            message = remove_spaces(message)

        if level not in self.single_line_prefixes:
            raise TerminalError("the `info_single` function does not know how to deal with a level of %d :/" % level)

        if cut_after:
            message_line = c("%s%s\n" % (self.single_line_prefixes[level], textwrap.fill(str(message), cut_after)), mc)
        else:
            message_line = c("%s%s\n" % (self.single_line_prefixes[level], str(message)), mc)

        message_line = ('\n' * nl_before) + message_line + ('\n' * nl_after)

        if progress:
            progress.clear()
            self.write(message_line)
            progress.update(progress.msg)

        else:
            self.write(message_line)
Exemplo n.º 9
0
    def info(self, key, value, quiet=False, display_only=False, nl_before=0, nl_after=0, lc='cyan', mc='yellow', progress=None):
        if not display_only:
            self.info_dict[key] = value

        if isinstance(value, bool):
            pass
        elif isinstance(value, str):
            value = remove_spaces(value)
        elif isinstance(value, int):
            value = pretty_print(value)

        label = constants.get_pretty_name(key)

        info_line = "%s%s %s: %s\n%s" % ('\n' * nl_before, c(label, lc),
                                         '.' * (self.width - len(label)),
                                         c(str(value), mc), '\n' * nl_after)

        if progress:
            progress.clear()
            self.write(info_line, quiet=quiet)
            progress.update(progress.msg)

        else:
            self.write(info_line, quiet=quiet)