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))
for column in ('Filter Name', 'Kind', 'Enabled', 'Settings'):
table.add_column(
column,
justify='left' if column in ('Filter Name', 'Kind') else 'center',
style='cyan',
)
columns = [
('Filter Name', 'left', 'cyan'),
('Kind', 'left', 'cyan'),
('Enabled', 'center', None),
('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:
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))
for column in ('ID', 'Group Name', 'Enabled'):
table.add_column(
column, justify='left' if column == 'Group Name' else 'center', style='cyan'
)
columns = [
('ID', 'center', '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:
table.add_row(

View File

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

View File

@ -29,8 +29,12 @@ def list_(ctx: typer.Context):
)
table = Table(title='Scenes', padding=(0, 2))
for column in ('Scene Name', 'UUID'):
table.add_column(column, justify='left', style='cyan')
columns = [
('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:
table.add_row(

View File

@ -58,10 +58,15 @@ def list_(
raise typer.Exit()
table = Table(title=f'Items in Scene: {scene_name}', padding=(0, 2))
for column in ('Item ID', 'Item Name', 'In Group', 'Enabled'):
table.add_column(
column, justify='left' if column == 'Item Name' else 'center', style='cyan'
)
columns = [
('Item ID', 'center', '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:
if is_group: