AutoArchive._configuration¶
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.
Sub-Packages¶
Modules¶
configuration_base¶
ConfigurationBase class.
-
class
AutoArchive._configuration.configuration_base.ConfigurationBase[source]¶ Bases:
AutoArchive._configuration.iconfiguration.IConfigurationSee
IConfiguration
iapp_config¶
IAppConfig interface, ConfigConstants static class and ArchiveSpecInfo namedtuple.
-
class
AutoArchive._configuration.iapp_config.ArchiveSpecInfo(name, path)¶ Bases:
tupleHolds information about an archive specification file; its name and full path.
-
name¶ Alias for field number 0
-
path¶ Alias for field number 1
-
-
class
AutoArchive._configuration.iapp_config.IAppConfig[source]¶ Bases:
AutoArchive._configuration.iconfiguration.IConfiguration,AutoArchive._mainf.iinterface_accessor.IComponentInterfaceProvides access to application configuration.
-
class
AutoArchive._configuration.iapp_config.ConfigConstants[source]¶ Bases:
objectConfiguration related constants.
-
ARCHIVE_SPEC_EXT= '.aa'¶ Extension of archive specification files.
-
iconfiguration¶
IConfiguration interface.
-
class
AutoArchive._configuration.iconfiguration.IConfiguration[source]¶ Bases:
objectProvides access to configuration options.
-
__getitem__(option)[source]¶ 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
boolvalueNoneis never returned; it is converted toFalse.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 beNone).Return type: objectRaises: KeyError – If optiondoes not exists.
-
getRawValue(option)[source]¶ Gets the raw value of a configuration option or
None.Unlike the
__getitem__()this method returns the real raw value of theoption.Parameters: option ( Option) – The option for which the value should be returned.Returns: The raw value of the passed option(can beNone).Return type: objectRaises: KeyError – If optiondoes not exists.
-
istorage¶
IStorage interface.
-
class
AutoArchive._configuration.istorage.IStorage[source]¶ Bases:
AutoArchive._mainf.iinterface_accessor.IComponentInterfaceProvides access to a persistent storage.
Stored content shall not be lost between program runs.
-
createStoragePortion(section=None, realm=None)[source]¶ Returns IStoragePortion instance set to
sectionandrealm.Note
If
sectionorrealmdoes not exists the implementation should not create either of them right away but rather on first value save.Parameters: - section (
str) – Name of a section within a realm. - realm (
str) – Name of a separate storage entity (typically represented by a file).
Returns: IStoragePortioninstanceReturn type: - section (
-
getRealms()[source]¶ Returns all realms that exists in the storage.
Returns: Iterable of realm names. Return type: Iterable<str>
-
getValue(variable, section=None, realm=None)[source]¶ Returns a cached value from the persistent storage.
Parameters: - variable (
str) – The name of the variable which value shall be read. - section (
str) – Name of a section within a realm. - realm (
str) – Name of a separate storage entity (typically represented by a file).
Returns: Value of the passed
variable.Return type: strRaises: KeyError – If
variable,sectionorrealmdoes not exists.- variable (
-
hasVariable(variable, section=None, realm=None)[source]¶ Returns
Trueif the storage containsvariable.Parameters: - variable (
str) – Name of the variable which presence shall be determined. - section (
str) – Name of a section within a realm. - realm (
str) – Name of a separate storage entity (typically represented by a file).
Returns: Trueifvariableis present in the storage.Return type: bool- variable (
-
removeRealm(realm)[source]¶ Deletes the
realmincluding all information that contains from the persistent storage.Parameters: realm (
str) – Name of a separate storage entity (typically represented by a file).Raises: - KeyError – If
realmdoes not exists. - OSError – If an error occurred during the operation of removing data from a physical storage.
- KeyError – If
-
saveValue(variable, value, section=None, realm=None)[source]¶ Saves a value to the persistent storage.
A value passed as
valueparameter will be saved to the persistent storage under the name passed asvariableargument.Note
A string representation of the value is saved (str(value)).
Parameters: - variable (
str) – The name under which the value will be saved. - value (
object) – The value that shall be saved. - section (
str) – Name of a section within a realm. - realm (
str) – Name of a separate storage entity (typically represented by a file).
- variable (
-
tryRemoveVariable(variable, section=None, realm=None)[source]¶ Removes variable from the persistent storage.
If variable existed to be removed, returns
True; otherwise returnFalse.Parameters: - variable (
str) – The name of the variable which value shall be removed. - section (
str) – Name of a section within a realm. - realm (
str) – Name of a separate storage entity (typically represented by a file).
Returns: Trueif variable existed;Falseotherwise.Return type: boolRaises: KeyError – If
sectionorrealmdoes not exists.- variable (
-
istorage_portion¶
IStoragePortion interface.
-
class
AutoArchive._configuration.istorage_portion.IStoragePortion[source]¶ Bases:
objectProvides access to a part of the persistent storage.
Portion of the
IStoragethat can be accessed is defined byrealmandsection. While thesectioncan be changed dynamically,realmcan not be changed for entire lifetime of theIStoragePortion-type object.-
getValue(variable, section=None)[source]¶ Returns a cached value from the persistent storage.
Parameters: - variable – The name of the variable which value shall be read.
- section (
str) – Name of a section withinrealm.
Returns: Value of the passed
variable.Return type: strRaises: KeyError – If
variableorsectiondoes not exists.
-
hasVariable(variable, section=None)[source]¶ Returns
trueif the storage containsvariable.Parameters: - variable (
str) – Name of the variable which presence shall be determined. - section (
str) – Name of a section within a realm.
Returns: trueifvariableis present in the storage.Return type: bool- variable (
-
saveValue(variable, value, section=None)[source]¶ Saves a value to the persistent storage.
A value passed as
valueparameter will be saved to a persistent storage under the name passed asvariableargument.Note
A string representation of the value is saved (str(value)).
Parameters: - variable (
str) – The name under which the value will be saved. - value (
object) – The value that shall be saved. - section (
str) – Name of a section withinrealm.
- variable (
-
tryRemoveVariable(variable, section=None)[source]¶ Removes variable from the persistent storage.
If variable existed to be removed, returns
True; otherwise returnFalse.Parameters: - variable – The name of the variable which value shall be removed.
- section (
str) – Name of a section withinrealm.
Returns: Trueif variable existed;Falseotherwise.Return type: boolRaises: KeyError – If
sectiondoes not exists.
-
realm¶ Gets the realm in which this
IStoragePortioninstance operates.Return type: str
-
section¶ Gets or sets the section in which this
IStoragePortioninstance operates by default.Return type: str
-
options¶
Options, OptionsUtils static classes and Option class.
-
class
AutoArchive._configuration.options.Options[source]¶ Bases:
objectConstants for configuration options.
These constants should be used to access options in the
IConfigurationimplementation provided by the Configuration component.Note
It is not allowed to change values of these constants.
-
ALL= <Option all of type <class 'bool'>>¶ Operate on all configured archive specification files.
-
ARCHIVER= <Option archiver of type Tar, TarGz, TarBz2, TarXz, TarInternal, TarGzInternal, TarBz2Internal>¶ Archiver type. Guaranteed to be defined.
-
ARCHIVE_SPECS_DIR= <Option archive-specs-dir of type path>¶ Directory where archive specification files will be searched. Guaranteed to be defined.
-
COMPRESSION_LEVEL= <Option compression-level of type <class 'int'>>¶ Compression strength level.
-
DEST_DIR= <Option dest-dir of type path>¶ Directory where the backup will be created. Guaranteed to be defined.
-
FORCE_ARCHIVER= <Option force-archiver of type Tar, TarGz, TarBz2, TarXz, TarInternal, TarGzInternal, TarBz2Internal>¶ Force archiver type regardless to what is specified in the archive specification file.
-
FORCE_COMPRESSION_LEVEL= <Option force-compression-level of type <class 'int'>>¶ Force compression level regardless to what is specified in the archive specification file.
-
FORCE_DEST_DIR= <Option force-dest-dir of type path>¶ Force the directory where the backup will be created.
-
FORCE_INCREMENTAL= <Option force-incremental of type <class 'bool'>>¶ Force incremental backup regardless to what is specified in the archive specification file.
-
FORCE_RESTARTING= <Option force-restarting of type <class 'bool'>>¶ Force the backup level restarting regardless to what is specified in the archive specification file.
-
FULL_RESTART_AFTER_AGE= <Option full-restart-after-age of type <class 'int'>>¶ Number of days after which the backup level is restarted to 0.
-
FULL_RESTART_AFTER_COUNT= <Option full-restart-after-count of type <class 'int'>>¶ Number of backup level restarts after which the level is restarted to 0.
-
INCREMENTAL= <Option incremental of type <class 'bool'>>¶ Incremental backup.
-
LEVEL= <Option level of type <class 'int'>>¶ Backup level used in incremental archiving.
-
MAX_RESTART_LEVEL_SIZE= <Option max-restart-level-size of type <class 'int'>>¶ 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.
-
NO_ALL= <Option no-all of type <class 'bool'>>¶ Do not operate on all configured archive specification files.
-
NO_INCREMENTAL= <Option no-incremental of type <class 'bool'>>¶ Disable incremental backup.
-
NO_RESTARTING= <Option no-restarting of type <class 'bool'>>¶ Turns off backup level restarting.
-
QUIET= <Option quiet of type <class 'bool'>>¶ 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.
-
REMOVE_OBSOLETE_BACKUPS= <Option remove-obsolete-backups of type <class 'bool'>>¶ 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.
-
RESTARTING= <Option restarting of type <class 'bool'>>¶ Turns on backup level restarting.
-
RESTART_AFTER_AGE= <Option restart-after-age of type <class 'int'>>¶ Number of days after which the backup level is restarted. Similarly to
RESTART_AFTER_LEVELit will be restarted to level 1 or higher.
-
RESTART_AFTER_LEVEL= <Option restart-after-level of type <class 'int'>>¶ 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_CONFIG_DIR= <Option user-config-dir of type path>¶ User configuration directory. Guaranteed to be defined.
-
USER_CONFIG_FILE= <Option user-config-file of type path>¶ User configuration file. Guaranteed to be defined.
-
VERBOSE= <Option verbose of type <class 'int'>>¶ Turns on verbose output.
-
-
class
AutoArchive._configuration.options.OptionsUtils[source]¶ Bases:
objectVarious utility methods working with
Options.-
classmethod
archiverTypeToStr(archiverType)[source]¶ Converts
ArchiverTypesto string representation.Value of the
archiverTypeparameter is converted to a string representation that is accepted by thestrToOptionType()method.Parameters: archiverType ( ArchiverTypes) – Archiver type that shall be converted.Returns: String form of passed archiverType.Return type: strRaises: ValueError – If archiverTypeis not known.
-
static
getAllOptions()[source]¶ Iterator over all known options.
Returns: All options defined in Options.Return type: Iterator<Option>
-
static
getAllSpecialOptionTypes()[source]¶ Iterator over all known special option types.
Returns: All option types defined in SpecialOptionTypes.Return type: Iterator<str>
-
classmethod
getOption(optionName)[source]¶ Return option with given name.
Parameters: optionName ( str) – Name of the option that shall be returned.Returns: First option from getAllOptions()which name isoptionName.Return type: OptionRaises: KeyError – If option with name optionNamedoes not exist.
-
classmethod
isExistingOption(optionName)[source]¶ Check whether an option with name
optionNamedoes exists inOptionsUtils.Parameters: optionName ( str) – Name of the option which existence shall be checked.Returns: Trueif option with nameoptionNameexists;Falseotherwise.Return type: bool
-
classmethod
strToOptionType(option, optionValue)[source]¶ Converts string option value to its proper, defined type.
Parameters: - option (
Option) – Option which value shall be converted. - optionValue (
str) – Value to be converted.
Returns: Converted
optionValue.Return type: objectRaises: - ValueError – If
optionValuecan not be converted tooption’s type. - RuntimeError – If
option’s type is not supported.
- option (
-
classmethod
tryGetForceForm(option)[source]¶ Returns force form for
optionorNone.Parameters: option ( Option) – An option in the normal form for which the force form for shall be returned.Returns: Force form of the passed optionorNoneif it does not have a force form.Return type: Option
-
classmethod
tryGetNegationForm(option)[source]¶ Returns negation form for
optionorNone.Parameters: option ( Option) – An option in the normal form for which the negation form for shall be returned.Returns: Negation form of the passed optionorNoneif it does not have a negation form.Return type: Option
-
classmethod
-
class
AutoArchive._configuration.options.Option(name, optType)[source]¶ Bases:
objectRepresents a configuration option.
Parameters: - name (
str) – Option name. - optType (
typeorstr) – Type of the option.
- name (
-
class
AutoArchive._configuration.options.SpecialOptionTypes[source]¶ Bases:
objectConstants 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.
-
PATH= 'path'¶ A filesystem path.
-