AutoArchive._ui._cmdline¶
Cmdline UI component.
Package implements command-line user interface.
Modules¶
_user_action_executor¶
UserActionExecutor class.
- class AutoArchive._ui.cmdline._user_action_executor.UserActionExecutor(componentUi, applicationContext, archivingApplication)[source]¶
Bases:
objectTakes care of execution of a user action specified on the command line.
- Parameters:
componentUi (
CmdlineUi) – Access to user interface.applicationContext (
ApplicationContext) – Application context.archivingApplication (
ArchivingApplication) – The application interface.
- execute()[source]¶
Executes an action defined for the specified command for specified archive specification files.
Command is read from the
ApplicationContext.appEnvironment.options. Ifoptionshas an attribute that matches one of theCmdlineCommandsand the value of that attribute isTruethen the action for the matching command is executed. If there is no such attribute, then the default actioncreateis executed.Archive specification files can be specified by following ways:
By archive names passed in
ApplicationContext.appEnvironment.arguments.Archive name can not contain the string defined by
ConfigConstants.ARCHIVE_SPEC_EXTat the end otherwise it would be taken as the path to an archive specification file. Archive specification files corresponding to the names are looked up in the path defined byOptions.ARCHIVE_SPECS_DIRoption.By paths to archive specification files passed in
ApplicationContext.appEnvironment.arguments.A path must end with the string defined by
ConfigConstants.ARCHIVE_SPEC_EXT.
- Returns:
Trueif the action execution was successful;Falseotherwise.
_cmdline_ui¶
CmdlineUi class.
- class AutoArchive._ui.cmdline._cmdline_ui.CmdlineUi(appEnvironment, configuration)[source]¶
Bases:
objectImplementation of the command-line user interface.
Provides basic methods for showing messages of various importance to a user. It uses standard output and standard error as the user interface.
- Parameters:
appEnvironment (
AppEnvironment) – Application environment.configuration (
IConfiguration) – Application configuration.
- presentLine(line)[source]¶
Present a line of text to the user.
Note
The verbosity level has no effect on presenting the line.
- Parameters:
line (
str) – The text that shall be presented to the user.
- presentMultiFieldLine(multiFieldLine)[source]¶
Present a line consisting of multiple fields of text to the user.
Note
The verbosity level has no effect on presenting the line.
- Parameters:
multiFieldLine (
MultiFieldLine) – Line that shall be presented.
- setProcessingArchSpec(archSpec)[source]¶
Sets currently processed archive specification file.
- Parameters:
archSpec (
str) – The archive specification file name or path to it.
- showError(msg)[source]¶
Show an error message to (
UiMessageKinds.Error) the user.See also:
verbosity.- Parameters:
msg (
str) – The message that should be shown to the user.
- showInfo(msg)[source]¶
Show an information message (
UiMessageKinds.Info) to the user.See also:
verbosity.- Parameters:
msg (
str) – The message that should be shown to the user.
- showNotification(msg)[source]¶
Show an unintrusive notification message (
UiMessageKinds.Notification) to the user.Note
If user interface implementation does not have means to support notifications then it should be presented to the user similarly as
showInfo().See also:
verbosity.- Parameters:
msg (
str) – The message that should be shown to the user.
- showVerbose(msg)[source]¶
Show a verbose-type message (
UiMessageKinds.Verbose) to the user.Verbose messages should be shown only if user enables it. Although this method can be called regardless of current verbosity level, the concrete implementation can decide whether it will be shown or not if verbosity level is 0. It is not recommended to call this method if verbosity level is 0 due to performance reasons. Current verbosity level can be obtained via
verbosityproperty.See also:
verbosity.- Parameters:
msg (
str) – The message that should be shown to the user.
- showWarning(msg)[source]¶
Show a warning message (
UiMessageKinds.Warning) to the user.See also:
verbosity.- Parameters:
msg (
str) – The message that should be shown to the user.
- messageShown = <AutoArchive._infrastructure.py_additions.event object>¶
- property verbosity¶
Gets the verbosity level.
If verbosity level is
VerbosityLevels.Quietonly messages of kindUiMessageKinds.Errorare shown. For levelVerbosityLevels.Normalall messages kinds exceptUiMessageKinds.Verboseare shown. For levelVerbosityLevels.Verboseall message kinds are shown.- Return type:
VerbosityLevels
_cmdline_commands¶
CmdlineCommands and _CmdlineCommandsUtils static classes.
- class AutoArchive._ui.cmdline._cmdline_commands.CmdlineCommands[source]¶
Bases:
objectConstants for command-line command names.
Command-line commands are used to invoke program operations via a command-line argument. For example:
--createwill invoke a backup creation.Note
It is not allowed to change values of these constants.
- CREATE = 'create'¶
Create backup for a given archive specification file.
- LIST = 'list'¶
List all archive specification files.
- PURGE = 'purge'¶
Purge orphaned archive data.
- class AutoArchive._ui.cmdline._cmdline_commands._CmdlineCommandsUtils[source]¶
Bases:
objectVarious utility methods working with
CmdlineCommands.- static getAllCommands()[source]¶
Iterator over all known commands.
- Returns:
All options defined in
CmdlineCommands.- Return type:
Iterable<str>
- classmethod isExistingCommand(commandName)[source]¶
Check whether a command with name
commandNamedoes exists in_CmdlineCommandsUtils.- Parameters:
commandName (
str) – Name of the command which existence shall be checked.- Returns:
Trueif option with namecommandNameexists;Falseotherwise.- Return type:
bool