simdb.config.config module¶
-
class simdb.config.config.Config(file_name=
None)[source]¶ Bases:
object-
CONFIG_FILE_NAME : str =
'simdb.cfg'¶
-
NOTHING =
<simdb.config.config.Config._NothingSentinel object>¶
- property api_version : str¶
- property config_directory : Path¶
Returns the directory that the local user configuration file is loaded from. @return:
- property debug : bool¶
Returns the debug status flag.
- property default_remote : str | None¶
Returns the default remote used by the SimDB client.
- delete_option(name: str) None[source]¶
Delete the option with the given name from the configuration.
@param name: the name of the option to delete
- delete_section(name: str) None[source]¶
Delete the section with the given name from the configuration.
This will also delete all options contained in this section.
@param name: the name of the section to delete
- get_option(name: str, default: int | float | bool | str | None | _NothingSentinel = <simdb.config.config.Config._NothingSentinel object>) int | float | bool | str[source]¶
Returns the value for the option with the given name from the configuration.
@param name: the name of the option to return @param default: the value to return if the option is not found in the
configuration
- @return: the value of the found option, or the default if given and the option
is not found
@raise KeyError if the option is not found and no default is given
-
get_section(name: str, default: dict[str, int | float | bool | str] | None =
None) dict[str, int | float | bool | str][source]¶ Returns the section from the configuration with the given name.
@param name: the name of the section to find @param default: a dictionary that will be returned if the section is not found @return: the section corresponding to the given name, or the default if given
and the section is not found
@raise KeyError if the section is not found and no default is given
- get_string_option(name: str, default: str | None | _NothingSentinel = <simdb.config.config.Config._NothingSentinel object>) str[source]¶
Returns the value for the option with the given name from the configuration but also ensures the resulting value is a string.
@see get_option @raise TypeError if the found value was not a string
- list_options() list[str][source]¶
List all the options found in the configuration.
@return: the values found as a list of “name: value” strings
-
load(file: TextIO | None =
None) None[source]¶ Load the configuration.
This loads the configuration from the given file and the site config and user config files.
The location of these files are either specified by SIMDB_USER_CONFIG_PATH and SIMDB_SITE_CONFIG_PATH environmental variables or in the appdirs.site_config_dir(‘simdb’) and appdirs.user_config_dir(‘simdb’).
The user config file is loaded after the site config file and will overwrite any settings specified. The given file is loaded after both the site and user config files.
- save() None[source]¶
Save the current state of the configuration to a configuration file in the users configuration directory.
- set_option(name: str, value: int | float | bool | str) None[source]¶
Set the option with the given name to the given value.
@param name: the name of the option to set @param value: the value to set the option to
- property user_config_path : Path¶
- property verbose : bool¶
Returns the SimDB client verbosity flag.
-
CONFIG_FILE_NAME : str =