Create a get_option_groups() method to return the groups, which are now built dynamically

This commit is contained in:
Raoul Snyman 2021-08-03 00:05:22 -07:00
parent f9c2cc345e
commit ba0e53ee6a

View File

@ -345,7 +345,7 @@ HTML_OPTIONS = {
'group': 'chord'
}
}
OPTION_GROUPS = set([option['group'] for option in HTML_OPTIONS.values()])
_OPTION_GROUPS = []
def get_options(group=None):
@ -356,9 +356,21 @@ def get_options(group=None):
return {key: value for key, value in HTML_OPTIONS.items() if value['group'] == group}
def get_option_groups():
if not _OPTION_GROUPS:
for option in HTML_OPTIONS.values():
if option['group'] not in _OPTION_GROUPS:
_OPTION_GROUPS.append(option['group'])
return _OPTION_GROUPS
def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_upper=None, indent=None):
"""Build a CSS style"""
styles = ['.{name} {{'.format(name=name)]
styles = []
if name == 'default':
styles.append('html, body, * {')
else:
styles.append('.{name} {{'.format(name=name))
if font:
styles.append(' font-family: \'{font}\';'.format(font=font))
if size:
@ -377,7 +389,7 @@ def make_style(name, font=None, size=None, is_bold=None, is_centered=None, is_up
def generate_option_styles(options):
styles = []
for group in OPTION_GROUPS:
for group in get_option_groups():
kwargs = {}
for key in STYLE_KEYS:
name = '{group}_{key}'.format(group=group, key=key)