AutoArchive._configuration._core¶
Configuration component internal package.
Modules¶
configuration_component¶
ConfigurationComponent
class.
-
class
AutoArchive._configuration._core.configuration_component.
ConfigurationComponent
(interfaceAccessor)[source]¶ Bases:
AutoArchive._mainf.icomponent.IComponent
IComponent
for support of configuration options and a persistent storage.During construction it registers
IAppConfig
andIStorage
component interfaces tointerfaceAccessor
. It also creates user configuration directory and archive specifications directory if either of them does not exists.The
IAppConfig
provides access to configuration options. It is instantiated and populated during construction fromIMainfContext.appEnvironment.options
(command-line options) and from configuration files. The system configuration file is “/etc/aa/aa.conf”. The user configuration file location is determined by values ofOptions.USER_CONFIG_FILE
andOptions.USER_CONFIG_DIR
options. The user configuration directory is automatically created if it does not exists. The format of configuration files is defined by the standardconfigparser
module (without interpolation).The
IAppConfig
instance is populated in a way that same options specified in multiple sources overrides each other so that the order of precedence from highest to lowest is following: command-line, user configuration file, system configuration file. However the implementation recognizes certain types of options that does not follow this rule (seeIConfiguration.__getitem__()
).Some of the options, if not specified in neither of possible sources, has some predefined default value. The list of these options with their predefined value follows:
Options.ARCHIVER
:ArchiverTypes.TarGz
Options.DEST_DIR
:os.curdir
Options.RESTART_AFTER_LEVEL
: 10Options.ARCHIVE_SPECS_DIR
:Options.USER_CONFIG_DIR
+ “archive_specs”Options.USER_CONFIG_FILE
:Options.USER_CONFIG_DIR
+ “aa.conf”Options.USER_CONFIG_DIR
: “~/.config/aa”
IStorage
provides access to the persistent storage. It is also instantiated and populated during construction of this class. The storage utilizes local filesystem, specifically a subdirectory of user configuration directory namedstorage
. It is automatically created if it does not exists.-
run
()[source]¶ See:
IComponent.run()
.
_app_config¶
_AppConfig
class.
-
class
AutoArchive._configuration._core._app_config.
_AppConfig
[source]¶ Bases:
AutoArchive._configuration.configuration_base.ConfigurationBase
,AutoArchive._configuration.iapp_config.IAppConfig
Application’s configuration.
Provides access to application’s configuration. All configuration options that can be accessed via this class are defined as static attributes of
Options
.After construction, all options are added and initialized to
None
. It is expected that concrete values will be added using the_addOrReplaceOption()
method.-
_addOrReplaceOption
(optionName, value)[source]¶ Adds an option and its value replacing the value if already exists.
String representation of the value is expected. It will be converted to a proper type defined by the option.
Parameters: - optionName (
str
) – Option that will be added or replaced. - value (
str
) – Value of passed option with nameoptionName
.
Raises: - KeyError – If option with name
optionName
does not exists. - ValueError – If option’s value is not correct.
- optionName (
-
_cmdline_arguments_processor¶
_CmdlineArgumentsProcessor
class.
-
class
AutoArchive._configuration._core._cmdline_arguments_processor.
_CmdlineArgumentsProcessor
(optparseValues)[source]¶ Bases:
object
Processes command-line arguments and populates
IConfiguration
instance.Parameters: optparseValues ( optparse.Values
) – Command-line options and their values.-
populateConfiguration
(appConfig)[source]¶ Populates
appConfig
with options specified on the command line.Note
Options that are not defined in the
Options
class are skipped; it is assumed that they are commands for command-line UI.Parameters: appConfig ( _AppConfig
) – Configuration that should be populated.
-
_config_file_processor¶
_ConfigFileProcessor
class.
-
class
AutoArchive._configuration._core._config_file_processor.
_ConfigFileProcessor
(appEnvironment, factoryUserConfigDir, factoryUserConfigFileProvider, userConfigDir=None, userConfigFile=None)[source]¶ Bases:
object
Processes configuration files and populates
IConfiguration
instance.Parameters: - appEnvironment (
_AppEnvironment
) –_AppEnvironment
instance. - factoryUserConfigDir (
str
) – Pre-defined path to the user configuration directory. - factoryUserConfigFileProvider (
function{str, =>str}
) – Function that returns path to the user configuration file based on the passed configuration directory. - userConfigDir (
str
) – Path to the user configuration directory. - userConfigFile (
str
) – Path to the user configuration file.
-
populateConfiguration
(configuration)[source]¶ Populates
configuration
with options.Parameters: configuration ( _AppConfig
) – Configuration that should be populated.
- appEnvironment (
_file_storage¶
_FileStorage
class.
-
class
AutoArchive._configuration._core._file_storage.
_FileStorage
(userConfigDir, quiet)[source]¶ Bases:
AutoArchive._configuration.istorage.IStorage
Application’s persistent storage.
Provides access to application’s persistent storage. Any arbitrary variables can be saved to it. Data are stored in text files.
Storage content is read upon construction and cached into memory. This class does not provide any means to re-read the storage content from disk.
Parameters: userConfigDir ( str
) – Path to the user configuration directory.-
getRealms
()[source]¶ See:
IStorage.getRealms()
.
-
getValue
(variable, section=None, realm=None)[source]¶ See:
IStorage.getValue()
.
-
hasVariable
(variable, section=None, realm=None)[source]¶ See:
IStorage.hasVariable()
.
-
removeRealm
(realm)[source]¶ See:
IStorage.removeRealm()
.
-
saveValue
(variable, value, section=None, realm=None)[source]¶ See:
IStorage.saveValue()
.
-
_storage_portion¶
_StoragePortion
class.
-
class
AutoArchive._configuration._core._storage_portion.
_StoragePortion
(storage, section, realm)[source]¶ Bases:
AutoArchive._configuration.istorage_portion.IStoragePortion
Portion of the application’s persistent storage.
See also:
FileStorage
.Parameters: -
realm
¶ See:
IStoragePortion.realm
.
-
section
¶ See:
IStoragePortion.section
.
-