

def LabelValueTable(self, label_list=None):
    'Returns whole table as rows of name/value pairs.\n\n    One (or more) column entries are used for the row prefix label.\n    The remaining columns are each displayed as a row entry with the\n    prefix labels appended.\n\n    Use the first column as the label if label_list is None.\n\n    Args:\n      label_list: A list of prefix labels to use.\n\n    Returns:\n      Label/Value formatted table.\n\n    Raises:\n      TableError: If specified label is not a column header of the table.\n    '
    label_list = (label_list or self._Header()[0])
    for label in label_list:
        if (label not in self._Header()):
            raise TableError(('Invalid label prefix: %s.' % label))
    sorted_list = []
    for header in self._Header():
        if (header in label_list):
            sorted_list.append(header)
    label_str = ('# LABEL %s\n' % '.'.join(label))
    body = []
    for row in self:
        label_prefix = []
        value_list = []
        for (key, value) in row.items():
            if (key in sorted_list):
                label_prefix.append(value)
            else:
                value_list.append(('%s %s' % (key, value)))
        body.append(''.join([('%s.%s\n' % ('.'.join(label_prefix), v)) for v in value_list]))
    return ('%s%s' % (label_str, ''.join(body)))

dataset/ETHPy150Open google/textfsm/texttable.py TextTable.LabelValueTable/VarMisuse@107/344 `sorted_list`->`label`