ape.plugins.base_plugin.SubConfiguration

class ape.plugins.base_plugin.SubConfiguration(source, section_name, allow_extras=False, configspec_source=None, updatable=True, constants=None)

Abstract base class for configurations

SubConfiguration constructor

Param:
  • source: ConfigObj section
  • section_name: section-name in the configuration
  • allow_extras: if True, check_rep only raises errors on error
  • configspec_source: string with configuration specification (use to override the default)
  • updatable: if True, allows updating from other sections
  • constants: object with same properties as SubConfigurationConstants
__init__(source, section_name, allow_extras=False, configspec_source=None, updatable=True, constants=None)

SubConfiguration constructor

Param:
  • source: ConfigObj section
  • section_name: section-name in the configuration
  • allow_extras: if True, check_rep only raises errors on error
  • configspec_source: string with configuration specification (use to override the default)
  • updatable: if True, allows updating from other sections
  • constants: object with same properties as SubConfigurationConstants

Methods

__init__(source, section_name[, ...]) SubConfiguration constructor
check_extra_values([warn_user]) checks the configuration for values not in the configspec
check_rep() Calls process_errors
log_error(error[, message]) Logs the error in bold red
process_errors() processes configuration, validation_outcome and logs the errors
update(section) Uses ‘updates_section’ to build configuration from other section

Attributes

configspec A configspec built from configspec_source for validation
configspec_source abstract: implement as configspec string
configuration validates and sets the configuration using the source configuration
constants object with string constants (see SubConfigurationConstants)
logger
return:A logging object.
plugin_name Gets the plugin name from the section
sample
validation_outcome Outcome of validating the configuration
validator validator for the configuration
check_extra_values(warn_user=True)

checks the configuration for values not in the configspec

Returns:True if extra values, false otherwise
check_rep()

Calls process_errors

Raise:ConfigurationError if errors are found (or there are unknown options and not allow_extras)
log_error(error, message='')

Logs the error in bold red

Param:
  • error: error type (prefix in red and bold)
  • message: descriptive message (red but not bold)
process_errors()

processes configuration, validation_outcome and logs the errors

Returns:True if there were errors (same as not self.validation_outcome)
update(section)

Uses ‘updates_section’ to build configuration from other section

Param:
  • section: plugin-section to update
Returns:

section merged with this section or original if appropriate

configspec

A configspec built from configspec_source for validation

configspec_source

abstract: implement as configspec string

configuration

validates and sets the configuration using the source configuration

Precondition:self.configspec has full configspec including section name
Returns:validated configuration for this section
constants

object with string constants (see SubConfigurationConstants)

logger
Returns:A logging object.
plugin_name

Gets the plugin name from the section

Returns:plugin-name if found or ‘<non-plugin>’
validation_outcome

Outcome of validating the configuration

validator

validator for the configuration

Navigation