Named rule presets combining formatters, styles and conditions.
Reference them with format("preset_name")
or style("preset_name").
# name + description + list of complete FormatRule descriptors. # Appears in format() suggestions if at least one rule has a formatter. # Appears in style() suggestions if at least one rule has a style. DEFAULT_RULE_PRESETS = { "accounting": { "description": "Negatives in parentheses (red), positives plain", "rules": [ { "condition": {"operator": "<", "value": 0}, "formatter": {"type": "number", "precision": 0, "prefix": "(", "suffix": ")", "absolute": True, "thousands_sep": " "}, "style": {"preset": "error"}, }, { "condition": {"operator": ">", "value": 0}, "formatter": {"type": "number", "precision": 0, "thousands_sep": " "}, }, ], }, "traffic_light": { "description": "Red / yellow / green style based on sign", "rules": [ {"condition": {"operator": "<", "value": 0}, "style": {"preset": "error"}}, {"condition": {"operator": "==", "value": 0}, "style": {"preset": "warning"}}, {"condition": {"operator": ">", "value": 0}, "style": {"preset": "success"}}, ], }, "budget_variance": { "description": "% variance: negative=error, over 10%=warning, else plain", "rules": [ { "condition": {"operator": "<", "value": 0}, "formatter": {"type": "number", "precision": 1, "suffix": "%", "multiplier": 100}, "style": {"preset": "error"}, }, { "condition": {"operator": ">", "value": 0.1}, "formatter": {"type": "number", "precision": 1, "suffix": "%", "multiplier": 100}, "style": {"preset": "warning"}, }, { "formatter": {"type": "number", "precision": 1, "suffix": "%", "multiplier": 100}, }, ], }, }