config_parser

Overview

This particular file allows for the use of a configuration file for a plugin (known as config.cfg), which is created from a default configuration file (known as default_config.cfg).

These configuration files have the following format:

  • Lines beginning with # are comments, and are not interpreted by the underlying parser. These can be used to inform users about an option’s default value, allowed values, and purpose.

  • Lines beginning with ## are default-only comments, meaning that they will not be copied from default_config.cfg into config.cfg when creating a duplicated configuration file. These can be used to discourage users from editing the default_config.cfg file, among other reasons.

  • Lines not preceded by a # or a ## are interpreted to have both an option’s name and its value, separated by an assignment operator (=).

Here is an example of a valid default_config.cfg file:

## DO NOT EDIT OR DELETE THIS FILE! If you need to make changes, then copy this file, save it as "config.cfg" in the
## plugin root directory, and edit that file instead!

log_sensitive_data=False
# Default Value: False
# Allowed Values:
#   - True
#   - False
# If set to true, this setting will add sensitive information to the log file generated by this plugin. Since this
# information can compromise the security of your account, this setting is best left to false, unless you are
# debugging the plugin.

Within a plugin (preferably in a file designated to constants, like consts.py), the defined setting can then be accessed like this:

CONFIG_OPTIONS = get_config_options([
    Option(option_name="log_sensitive_data")
])

LOG_SENSITIVE_DATA = CONFIG_OPTIONS["log_sensitive_data"]

For more details regarding accessing the user’s defined configuration settings, see the documentation below.

Documentation