How to use the texttable.bcolors.WHITE function in texttable

To help you get started, we’ve selected a few texttable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bufordtaylor / python-texttable / texttable.py View on Github external
def _splitit(self, line, isheader):
        """Split each element of line to fit the column width

        Each element is turned into a list, result of the wrapping of the
        string to the desired width
        """

        line_wrapped = []
        for cell, width in zip(line, self._width):
            array = []
            original_cell = cell
            lost_color = bcolors.WHITE
            for attr in bcolors_public_props():
                cell = cell.replace(
                    getattr(bcolors, attr), '').replace(bcolors.ENDC,'')
                if cell.replace(bcolors.ENDC,'') != original_cell.replace(
                        bcolors.ENDC,'') and attr != 'ENDC':
                    if not lost_color:
                        lost_color = attr
            for c in cell.split('\n'):
                if type(c) is not str:
                    try:
                        c = str(c, 'utf')
                    except UnicodeDecodeError as strerror:
                        sys.stderr.write("UnicodeDecodeError exception for string '%s': %s\n" % (c, strerror))
                        c = str(c, 'utf', 'replace')
                try:
                    array.extend(
github grow / grow / grow / deployments / indexes.py View on Github external
    @classmethod
    def _make_diff_row(cls, color, label, message):
        label = texttable.get_color_string(color, label)
        path = texttable.get_color_string(
            texttable.bcolors.WHITE, message.path)
        formatted_author = cls._format_author(message.deployed_by, True)
        deployed = str(message.deployed).split('.')[0][
            :-3] if message.deployed else ''
        return [label, path, deployed, formatted_author]
github bufordtaylor / python-texttable / texttable.py View on Github external
"""Draw a line

        Loop over a single cell length, over all the cells
        """

        line = self._splitit(line, isheader)
        space = " "
        out  = ""
        for i in range(len(line[0])):
            if self._has_border():
                out += "%s " % self._char_vert
            length = 0
            for cell, width, align in zip(line, self._width, self._align):
                length += 1
                cell_line = cell[i]
                lost_color = bcolors.WHITE
                original_cell = cell_line
                for attr in bcolors_public_props():
                    cell_line = cell_line.replace(
                        getattr(bcolors, attr), '').replace(bcolors.ENDC,''
                    )
                    if cell_line.replace(bcolors.ENDC,'') != original_cell.replace(
                            bcolors.ENDC,'') and attr != 'ENDC':
                        if not lost_color:
                            lost_color = attr
                fill = width - len(cell_line)
                try:
                    cell_line = get_color_string(
                        getattr(bcolors, lost_color),cell_line
                    )
                except AttributeError:
                    pass
github quentinhardy / odat / texttable.py View on Github external
def get_color_string(type, string):
    end = bcolors.ENDC
    if type == bcolors.WHITE:
        end = ''
    return '%s%s%s' % (type, string, end)
github bufordtaylor / python-texttable / texttable.py View on Github external
def get_color_string(type, string):
    end = bcolors.ENDC
    if type == bcolors.WHITE:
        end = ''
    return '%s%s%s' % (type, string, end)