34def _get_table_value(table: bytes, key: bytes) -> bytes:
35 """Get the value for a key in a table/multiline output.
36
37 Some commands return something like a table of key/values. There
38 may be even empty lines on this table. This searches for the
39 first line with a specific key (hopefully there's only one line
40 with such key) and returns the associated value.
41 """
42
43 match = re.search(b"(?:^|\r\n) *" + key + b": (.*)\r\n", table)
44 if match is None:
46 "failed to find key %s on table: %s" % (key, table)
47 )
48 return match.group(1)
49
50