How to use the textfsm.clitable.IndexTable 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 / clitable.py View on Github external
def __deepcopy__(self, memodict=None):
    """Returns a deepcopy of an IndexTable object."""
    clone = IndexTable()
    if hasattr(self, '_index_file'):
      # pylint: disable=protected-access
      clone._index_file = copy.deepcopy(self._index_file)
      clone._index_handle = open(clone._index_file, 'r')

    clone.index = copy.deepcopy(self.index)
    clone.compiled = copy.deepcopy(self.compiled)
    return clone
github google / textfsm / textfsm / clitable.py View on Github external
def ReadIndex(self, index_file=None):
    """Reads the IndexTable index file of commands and templates.

    Args:
      index_file: String, file where template/command mappings reside.

    Raises:
      CliTableError: A template column was not found in the table.
    """

    self.index_file = index_file or self.index_file
    fullpath = os.path.join(self.template_dir, self.index_file)
    if self.index_file and fullpath not in self.INDEX:
      self.index = IndexTable(self._PreParse, self._PreCompile, fullpath)
      self.INDEX[fullpath] = self.index
    else:
      self.index = self.INDEX[fullpath]

    # Does the IndexTable have the right columns.
    if 'Template' not in self.index.index.header:    # pylint: disable=E1103
      raise CliTableError("Index file does not have 'Template' column.")
github google / textfsm / textfsm / clitable.py View on Github external
def __copy__(self):
    """Returns a copy of an IndexTable object."""
    clone = IndexTable()
    if hasattr(self, '_index_file'):
      # pylint: disable=protected-access
      clone._index_file = self._index_file
      clone._index_handle = self._index_handle

    clone.index = self.index
    clone.compiled = self.compiled
    return clone