Provides access to configuration options read from IMainfContext.appEnvironment.options (command-line options), user configuration file and system configuration file. For that purpose it provides IAppConfig interface.
It also provides application’s persistent storage in a form of IStorage component interface.
For more information about IAppConfig and IStorage provided interfaces see ConfigurationComponent.
Component is designed to be used as the Mainf component. For that purpose it provides IComponent implementation in a form of ConfigurationComponent class.
ConfigurationBase class.
Bases: AutoArchive._configuration.iconfiguration.IConfiguration
See IConfiguration
IAppConfig interface, ConfigConstants static class and ArchiveSpecInfo namedtuple.
Bases: builtins.tuple
Holds information about an archive specification file; its name and full path.
Alias for field number 0
Alias for field number 1
Bases: AutoArchive._configuration.iconfiguration.IConfiguration, AutoArchive._mainf.iinterface_accessor.IComponentInterface
Provides access to application configuration.
Bases: builtins.object
Configuration related constants.
Extension of archive specification files.
IConfiguration interface.
Bases: builtins.object
Provides access to configuration options.
Gets consolidated value of a configuration option.
Method takes into account values of other option forms such as negation form and force form. For example if the raw value of the option FOO is 10 and raw value of FORCE_FOO is 5 then value 5 will be returned.
The precedence order of option forms is following: force form > negation form > normal form; with force form as the highest and normal form as the lowest priority form.
For options of type bool value None is never returned; it is converted to False.
Parameters: | option (Option) – The option in the normal form for which the value should be returned. |
---|---|
Returns: | The merged value of the passed option (can be None). |
Return type: | object |
Raises KeyError: | |
If option does not exists. |
Gets the raw value of a configuration option or None.
Unlike the __getitem__() this method returns the real raw value of the option.
Parameters: | option (Option) – The option for which the value should be returned. |
---|---|
Returns: | The raw value of the passed option (can be None). |
Return type: | object |
Raises KeyError: | |
If option does not exists. |
IStorage interface.
Bases: AutoArchive._mainf.iinterface_accessor.IComponentInterface
Provides access to a persistent storage.
Stored content shall not be lost between program runs.
Returns IStoragePortion instance set to section and realm.
Note
If section or realm does not exists the implementation should not create either of them right away but rather on first value save.
Parameters: |
|
---|---|
Returns: | IStoragePortion instance |
Return type: |
Returns all realms that exists in the storage.
Returns: | Iterable of realm names. |
---|---|
Return type: | Iterable<str> |
Returns a cached value from the persistent storage.
Parameters: |
|
---|---|
Returns: | Value of the passed variable. |
Return type: | str |
Raises KeyError: | |
If variable, section or realm does not exists. |
Returns True if the storage contains variable.
Parameters: |
|
---|---|
Returns: | True if variable is present in the storage. |
Return type: | bool |
Deletes the realm including all information that contains from the persistent storage.
Parameters: | realm (str) – Name of a separate storage entity (typically represented by a file). |
---|---|
Raises: |
|
Saves a value to the persistent storage.
A value passed as value parameter will be saved to the persistent storage under the name passed as variable argument.
Note
A string representation of the value is saved (str(value)).
Parameters: |
|
---|
Removes variable from the persistent storage.
If variable existed to be removed, returns True; otherwise return False.
Parameters: |
|
---|---|
Returns: | True if variable existed; False otherwise. |
Return type: | bool |
Raises KeyError: | |
If section or realm does not exists. |
IStoragePortion interface.
Bases: builtins.object
Provides access to a part of the persistent storage.
Portion of the IStorage that can be accessed is defined by realm and section. While the section can be changed dynamically, realm can not be changed for entire lifetime of the IStoragePortion-type object.
Returns a cached value from the persistent storage.
Parameters: |
|
---|---|
Returns: | Value of the passed variable. |
Return type: | str |
Raises KeyError: | |
If variable or section does not exists. |
Returns true if the storage contains variable.
Parameters: |
|
---|---|
Returns: | true if variable is present in the storage. |
Return type: | bool |
Saves a value to the persistent storage.
A value passed as value parameter will be saved to a persistent storage under the name passed as variable argument.
Note
A string representation of the value is saved (str(value)).
Parameters: |
|
---|
Removes variable from the persistent storage.
If variable existed to be removed, returns True; otherwise return False.
Parameters: |
|
---|---|
Returns: | True if variable existed; False otherwise. |
Return type: | bool |
Raises KeyError: | |
If section does not exists. |
Gets the realm in which this IStoragePortion instance operates.
Return type: | str |
---|
Gets or sets the section in which this IStoragePortion instance operates by default.
Return type: | str |
---|
Options, OptionsUtils static classes and Option class.
Bases: builtins.object
Constants for configuration options.
These constants should be used to access options in the IConfiguration implementation provided by the Configuration component.
Note
It is not allowed to change values of these constants.
Operate on all configured archive specification files.
Archiver type. Guaranteed to be defined.
Directory where archive specification files will be searched. Guaranteed to be defined.
Compression strength level.
Directory where the backup will be created. Guaranteed to be defined.
Force archiver type regardless to what is specified in the archive specification file.
Force compression level regardless to what is specified in the archive specification file.
Force the directory where the backup will be created.
Force incremental backup regardless to what is specified in the archive specification file.
Force the backup level restarting regardless to what is specified in the archive specification file.
Number of days after which the backup level is restarted to 0.
Number of backup level restarts after which the level is restarted to 0.
Incremental backup.
Backup level used in incremental archiving.
Maximal percentage size of a backup (of level > 0) to which level is allowed restart to. The size is percentage of size of the level 0 backup file. If a backup of particular level has its size bigger than defined percentage, restart to that level will not be allowed.
Do not operate on all configured archive specification files.
Disable incremental backup.
Turns off backup level restarting.
Turns on quiet output. Only errors will be shown. If QUIET is turned on at the same level as VERBOSE (e. g. both are specified on the command line) then QUIET has higher priority than VERBOSE.
Turns on removing backups of levels that are no longer valid due to the backup level restart. All backups of the backup level higher than the one currently being created will be removed.
Turns on backup level restarting.
Number of days after which the backup level is restarted. Similarly to RESTART_AFTER_LEVEL it will be restarted to level 1 or higher.
Maximal backup level. If reached, it will be restarted back to a lower level (which is typically level 1 but it depends on MAX_RESTART_LEVEL_SIZE). Guaranteed to be defined.
User configuration directory. Guaranteed to be defined.
User configuration file. Guaranteed to be defined.
Turns on verbose output.
Bases: builtins.object
Various utility methods working with Options.
Converts ArchiverTypes to string representation.
Value of the archiverType parameter is converted to a string representation that is accepted by the strToOptionType() method.
Parameters: | archiverType (ArchiverTypes) – Archiver type that shall be converted. |
---|---|
Returns: | String form of passed archiverType. |
Return type: | str |
Raises ValueError: | |
If archiverType is not known. |
Iterator over all known options.
Returns: | All options defined in Options. |
---|---|
Return type: | Iterator<Option> |
Iterator over all known special option types.
Returns: | All option types defined in SpecialOptionTypes. |
---|---|
Return type: | Iterator<str> |
Return option with given name.
Parameters: | optionName (str) – Name of the option that shall be returned. |
---|---|
Returns: | First option from getAllOptions() which name is optionName. |
Return type: | Option |
Raises KeyError: | |
If option with name optionName does not exist. |
Check whether an option with name optionName does exists in OptionsUtils.
Parameters: | optionName (str) – Name of the option which existence shall be checked. |
---|---|
Returns: | True if option with name optionName exists; False otherwise. |
Return type: | bool |
Converts string option value to its proper, defined type.
Parameters: |
|
---|---|
Returns: | Converted optionValue. |
Return type: | object |
Raises: |
|
Returns force form for option or None.
Parameters: | option (Option) – An option in the normal form for which the force form for shall be returned. |
---|---|
Returns: | Force form of the passed option or None if it does not have a force form. |
Return type: | Option |
Returns negation form for option or None.
Parameters: | option (Option) – An option in the normal form for which the negation form for shall be returned. |
---|---|
Returns: | Negation form of the passed option or None if it does not have a negation form. |
Return type: | Option |
Bases: builtins.object
Represents a configuration option.
Parameters: |
|
---|
Bases: builtins.object
Constants for special option types.
Normally, options are of some standard type, such as int, str, etc. Some of them however, requires special handling for which the special option types are defined in this class.
Note
It is not allowed to change values of these constants.
A filesystem path.