config: make option names optional
This commit is contained in:
@@ -77,7 +77,8 @@ skip_locale: no
|
||||
# keyword string Forwarded to the installation script as is.
|
||||
# suggested bool Optional. Whether installation defaults to yes.
|
||||
# options list A list of options, with each option having:
|
||||
# name string Option name presented to user. Translatable.
|
||||
# name string Optional. Name presented to user. Translatable.
|
||||
# Value of 'option' is used when not given.
|
||||
# option string Like 'keyword' for non-options, forwarded as-is when chosen.
|
||||
#
|
||||
# Default: [], suggested: False, description: '', icon_path: fallback icon
|
||||
@@ -96,12 +97,11 @@ additional_software:
|
||||
description : 'Select your favorite option'
|
||||
icon_path : '/etc/os-installer/icons/options-symbolic.svg'
|
||||
options :
|
||||
- option : 'Nothing'
|
||||
- name : 'Option 1'
|
||||
option : 'package_1'
|
||||
- name : 'Option 2'
|
||||
option : 'package_2'
|
||||
- name : 'Option 3'
|
||||
option : 'package_3'
|
||||
|
||||
# List of features that can additionally be selected. Very similar
|
||||
# to `additional_software`, but meant for more generic features. Can
|
||||
|
||||
@@ -33,7 +33,7 @@ def handle_choices(choices, pot_file):
|
||||
for option in options:
|
||||
if 'name' in option:
|
||||
add_to_pot(option['name'], pot_file)
|
||||
else:
|
||||
elif not 'option' in option:
|
||||
print(f'Invalid option: {option}')
|
||||
|
||||
|
||||
|
||||
@@ -40,10 +40,11 @@ def handle_choice(choice):
|
||||
|
||||
options = []
|
||||
for option in choice['options']:
|
||||
if (not 'option' in option or not 'name' in option):
|
||||
if not 'option' in option:
|
||||
print(f'Option for {name} not correctly configured: {option}')
|
||||
continue
|
||||
options.append(Option(option['name'], option['option']))
|
||||
name = option['name'] if 'name' in option else option['option']
|
||||
options.append(Option(name, option['option']))
|
||||
|
||||
if len(options) == 0:
|
||||
print(f'No valid options found for {name}')
|
||||
|
||||
Reference in New Issue
Block a user