How to use the textfsm.terminal 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
def _SmallestColSize(self, text):
    """Finds the largest indivisible word of a string.

    ...and thus the smallest possible column width that can contain that
    word unsplit over rows.

    Args:
      text: A string of text potentially consisting of words.

    Returns:
      Integer size of the largest single word in the text.
    """
    if not text:
      return 0
    stripped = terminal.StripAnsiText(text)
    return max(len(word) for word in stripped.split())
github google / textfsm / textfsm / texttable.py View on Github external
def _SetColour(self, value_list):
    """Sets row's colour attributes to a list of values in terminal.SGR."""
    if value_list is None:
      self._color = None
      return
    colors = []
    for color in value_list:
      if color in terminal.SGR:
        colors.append(color)
      elif color in terminal.FG_COLOR_WORDS:
        colors += terminal.FG_COLOR_WORDS[color]
      elif color in terminal.BG_COLOR_WORDS:
        colors += terminal.BG_COLOR_WORDS[color]
      else:
        raise ValueError('Invalid colour specification.')
    self._color = list(set(colors))
github google / textfsm / textfsm / texttable.py View on Github external
def _SetColour(self, value_list):
    """Sets row's colour attributes to a list of values in terminal.SGR."""
    if value_list is None:
      self._color = None
      return
    colors = []
    for color in value_list:
      if color in terminal.SGR:
        colors.append(color)
      elif color in terminal.FG_COLOR_WORDS:
        colors += terminal.FG_COLOR_WORDS[color]
      elif color in terminal.BG_COLOR_WORDS:
        colors += terminal.BG_COLOR_WORDS[color]
      else:
        raise ValueError('Invalid colour specification.')
    self._color = list(set(colors))