mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
On second thought, make that script use the specified order, not a sorted order.
This commit is contained in:
parent
9a2e6dcba5
commit
0032e4b6cf
@ -47,22 +47,16 @@ def main(password, askpass, attrs, address, port):
|
|||||||
output[attr].append(item['attributes'].get(attr, ''))
|
output[attr].append(item['attributes'].get(attr, ''))
|
||||||
|
|
||||||
# output data
|
# output data
|
||||||
print_table(output, 'entity_id')
|
print_table(output, ['entity_id'] + attrs)
|
||||||
|
|
||||||
|
|
||||||
def print_table(data, first_key):
|
def print_table(data, columns):
|
||||||
""" format and print a table of data from a dictionary """
|
""" format and print a table of data from a dictionary """
|
||||||
# get column lengths
|
# get column lengths
|
||||||
lengths = {}
|
lengths = {}
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
lengths[key] = max([len(str(val)) for val in value] + [len(key)])
|
lengths[key] = max([len(str(val)) for val in value] + [len(key)])
|
||||||
|
|
||||||
# construct the column order
|
|
||||||
columns = sorted(list(data.keys()))
|
|
||||||
ind = columns.index(first_key)
|
|
||||||
columns.pop(ind)
|
|
||||||
columns = [first_key] + columns
|
|
||||||
|
|
||||||
# print header
|
# print header
|
||||||
for item in columns:
|
for item in columns:
|
||||||
itemup = item.upper()
|
itemup = item.upper()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user