How to use the textfsm.terminal.AnsiText function in textfsm

To help you get started, we’ve selected a few textfsm 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 google / textfsm / textfsm / texttable.py View on Github external
row_list.append(' '*smallest[key])
        row_list.append('\n')

      if color and row.color is not None:
        body_list.append(
            terminal.AnsiText(''.join(row_list)[:-1],
                              command_list=row.color))
        body_list.append('\n')
      else:
        body_list.append(''.join(row_list))

      first_line = False

    header = ''.join(header_list) + '='*total_width
    if color and self._Header().color is not None:
      header = terminal.AnsiText(header, command_list=self._Header().color)
    # Add double line delimiter between header and main body.
    if display_header:
      return '%s\n%s' % (header, ''.join(body_list))
    return '%s' % ''.join(body_list)
github google / textfsm / textfsm / texttable.py View on Github external
# Our current line was not wrapped, so clear flag.
          prev_muli_line = False

      row_list = []
      for row_idx in range(row_count):
        for key in _FilteredCols():
          try:
            row_list.append(result_dict[key][row_idx])
          except IndexError:
            # If no value than use whitespace of equal size.
            row_list.append(' '*smallest[key])
        row_list.append('\n')

      if color and row.color is not None:
        body_list.append(
            terminal.AnsiText(''.join(row_list)[:-1],
                              command_list=row.color))
        body_list.append('\n')
      else:
        body_list.append(''.join(row_list))

      first_line = False

    header = ''.join(header_list) + '='*total_width
    if color and self._Header().color is not None:
      header = terminal.AnsiText(header, command_list=self._Header().color)
    # Add double line delimiter between header and main body.
    if display_header:
      return '%s\n%s' % (header, ''.join(body_list))
    return '%s' % ''.join(body_list)