use tuples as records to build the tables

This commit is contained in:
onyx-and-iris 2025-06-06 23:26:33 +01:00
parent 74503f17e0
commit cd7614bfd6
5 changed files with 36 additions and 22 deletions

View File

@ -52,12 +52,14 @@ def list_(
table = Table(title=f'Filters for Source: {source_name}', padding=(0, 2)) table = Table(title=f'Filters for Source: {source_name}', padding=(0, 2))
for column in ('Filter Name', 'Kind', 'Enabled', 'Settings'): columns = [
table.add_column( ('Filter Name', 'left', 'cyan'),
column, ('Kind', 'left', 'cyan'),
justify='left' if column in ('Filter Name', 'Kind') else 'center', ('Enabled', 'center', None),
style='cyan', ('Settings', 'center', 'cyan'),
) ]
for name, justify, style in columns:
table.add_column(name, justify=justify, style=style if style else None)
for filter in resp.filters: for filter in resp.filters:
resp = ctx.obj.get_source_filter_default_settings(filter['filterKind']) resp = ctx.obj.get_source_filter_default_settings(filter['filterKind'])

View File

@ -52,10 +52,13 @@ def list_(
table = Table(title=f'Groups in Scene: {scene_name}', padding=(0, 2)) table = Table(title=f'Groups in Scene: {scene_name}', padding=(0, 2))
for column in ('ID', 'Group Name', 'Enabled'): columns = [
table.add_column( ('ID', 'center', 'cyan'),
column, justify='left' if column == 'Group Name' else 'center', style='cyan' ('Group Name', 'left', 'cyan'),
) ('Enabled', 'center', None),
]
for column, justify, style in columns:
table.add_column(column, justify=justify, style=style)
for item_id, group_name, is_enabled in groups: for item_id, group_name, is_enabled in groups:
table.add_row( table.add_row(

View File

@ -25,12 +25,12 @@ def list_(ctx: typer.Context):
resp = ctx.obj.get_profile_list() resp = ctx.obj.get_profile_list()
table = Table(title='Profiles', padding=(0, 2)) table = Table(title='Profiles', padding=(0, 2))
for column in ('Profile Name', 'Current'): columns = [
table.add_column( ('Profile Name', 'left', 'cyan'),
column, ('Current', 'center', None),
justify='left' if column == 'Profile Name' else 'center', ]
style='cyan', for column, justify, style in columns:
) table.add_column(column, justify=justify, style=style)
for profile in resp.profiles: for profile in resp.profiles:
table.add_row( table.add_row(

View File

@ -29,8 +29,12 @@ def list_(ctx: typer.Context):
) )
table = Table(title='Scenes', padding=(0, 2)) table = Table(title='Scenes', padding=(0, 2))
for column in ('Scene Name', 'UUID'): columns = [
table.add_column(column, justify='left', style='cyan') ('Scene Name', 'left', 'cyan'),
('UUID', 'left', 'cyan'),
]
for column, justify, style in columns:
table.add_column(column, justify=justify, style=style)
for scene_name, scene_uuid in scenes: for scene_name, scene_uuid in scenes:
table.add_row( table.add_row(

View File

@ -58,10 +58,15 @@ def list_(
raise typer.Exit() raise typer.Exit()
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2)) table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
for column in ('Item ID', 'Item Name', 'In Group', 'Enabled'): columns = [
table.add_column( ('Item ID', 'center', 'cyan'),
column, justify='left' if column == 'Item Name' else 'center', style='cyan' ('Item Name', 'left', 'cyan'),
) ('In Group', 'left', 'cyan'),
('Enabled', 'center', None),
]
# Add columns to the table
for column, justify, style in columns:
table.add_column(column, justify=justify, style=style)
for item_id, item_name, is_group, is_enabled in items: for item_id, item_name, is_group, is_enabled in items:
if is_group: if is_group: