textual_shell.configure
MissingSection
MissingSetting
add_section(section_name, section, path)
Add a section to the config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
dict[str, str]
|
The section name. |
required |
path
|
str
|
The path to the config |
required |
Source code in src/textual_shell/configure.py
check_section(section, path)
Check if a section exists in the config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
The section of the config. |
required |
path
|
str
|
The path to the config. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
exists |
bool
|
True if it exists else False. |
Source code in src/textual_shell/configure.py
create_config(path, config={})
Create a default config for the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path to create the config file. |
required |
Source code in src/textual_shell/configure.py
get_config(path)
Load the config into a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
The path to the config. |
required |
Source code in src/textual_shell/configure.py
get_section(section_name, path)
Get the section sub dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section_name
|
str
|
The section of the config. |
required |
path
|
str
|
The path to the config. |
required |
Raises:
| Type | Description |
|---|---|
MissingSection
|
Exception for missing section |
Source code in src/textual_shell/configure.py
get_setting(section_name, setting_name, path)
Get the setting sub dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section_name
|
str
|
The section of the config. |
required |
setting_name
|
str
|
The setting to retrieve the value for. |
required |
path
|
str
|
The path to the config. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
setting |
dict
|
The description and value of a setting. |
Raises:
| Type | Description |
|---|---|
MissingSetting
|
Exception for missing setting. |
Source code in src/textual_shell/configure.py
get_setting_description(section, setting, path)
Retrieve the description of a setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
The section of the config. |
required |
setting
|
str
|
The setting to retrieve the value for. |
required |
path
|
str
|
The path to the config. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
description |
str
|
The description of the setting. |
Source code in src/textual_shell/configure.py
get_setting_options(section, setting, path)
Get the options for a specific setting if they exist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
The section of the config. |
required |
setting
|
str
|
The setting to retrieve the value for. |
required |
path
|
str
|
The path to the config. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
options |
list[str] | dict[str, str]
|
The options can either be a list of possible values, or a dictionary where the keys are the values that will be displayed and the value will be the actual value. |
Source code in src/textual_shell/configure.py
get_setting_value(section, setting, path)
Get the value of the setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
The section of the config. |
required |
setting
|
str
|
The setting to retrieve the value for. |
required |
path
|
str
|
The path to the config. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
value |
str
|
The value of the setting. |
Source code in src/textual_shell/configure.py
update_setting(section, setting, path, value=None)
Update the value of a setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
section
|
str
|
The section of the config. |
required |
setting
|
str
|
The setting to retrieve the value for. |
required |
path
|
str
|
The path to the config. |
required |
value
|
str
|
The new value. |
None
|