pysnt.config module#
Configuration system for PySNT
This module provides a global configuration system that allows to set and get various options that control PySNT behavior
Examples
>>> import pysnt
>>> pysnt.set_option('display.chart_format', 'svg')
>>> pysnt.get_option('display.chart_format')
'svg'
>>> pysnt.describe_option('display.chart_format')
display.chart_format: str
Default export format for SNTChart
[default: png] [currently: svg]
- get_option(key: str) Any[source]#
Get the value of a configuration option.
- Parameters:
key (str) – The option key in dot notation (e.g., ‘display.chart_format’)
- Returns:
The current value of the option
- Return type:
Any
- Raises:
OptionError – If the option key is not found
Examples
>>> import pysnt >>> pysnt.get_option('display.chart_format') 'png'
- set_option(key: str, value: Any) None[source]#
Set the value of a configuration option.
- Parameters:
key (str) – The option key in dot notation (e.g., ‘display.chart_format’)
value (Any) – The new value for the option
- Raises:
OptionError – If the option key is not found
ValueError – If the value is invalid for the option
Examples
>>> import pysnt >>> pysnt.set_option('display.chart_format', 'svg') >>> pysnt.set_option('display.max_rows', 50)
- reset_option(key: str) None[source]#
Reset an option to its default value.
- Parameters:
key (str) – The option key to reset
Examples
>>> import pysnt >>> pysnt.reset_option('display.chart_format')
- describe_option(key: str | None = None) None[source]#
Print description of one or all options.
- Parameters:
key (str, optional) – The option key to describe. If None, describes all options.
Examples
>>> import pysnt >>> pysnt.describe_option('display.chart_format') display.chart_format: str Default export format for SNTChart (svg, png, or pdf) [default: png] [currently: png]
- list_options() List[str][source]#
Get a list of all available option keys.
- Returns:
Sorted list of all option keys
- Return type:
List[str]
Examples
>>> import pysnt >>> pysnt.list_options() ['display.chart_format', 'display.max_columns', 'display.max_rows', ...]
- option_context(**kwargs)[source]#
Context manager for temporarily setting options.
- Parameters:
**kwargs – Option key-value pairs to set temporarily
Examples
>>> import pysnt >>> with pysnt.option_context(display_chart_format='svg'): ... # chart_format is temporarily 'svg' ... chart = create_chart() # function to create a new graph ... chart.save() # saves as SVG # chart_format is back to original value