AutoArchive._mainf

Main framework for AutoArchive.

Mainf helps to implement architecture where an application consists of several components (which can map the logical structure). In particular, it provides a way to prevents to see eachothers package internal implementation objects and allows them to expose only public interfaces.

Each component class has to derive from IComponent interface. All IComponent classes has to be passed to MainfEngine during its initialization using the MainfEngine.addComponent() method. Components have possibility to register instances of their public interfaces implementations using the IInterfaceAccessor which is passed to them during their construction. Doing so, they make them available to other components (which can access them via the same interface).

Components should expose their interface definitions to others while classes that implements them should be hidden in private packages/modules.

Additionally, Mainf defines interface IComponentUi for a user interface that components should use to access a UI (which has to implement it).

Mainf framework is initialized by creating the MainfEngine by createMainfEngine() factory method following by populating it by component classes. Finally, calling MainfEngine.start() method, starts the application passing the appEnvironment which is an arbitrary object that will be available to components via IMainfContext component interface. Mainf in turn, instantiates all components and executes them by calling the IComponent.run() method for each.

Modules

icomponent

IComponent interface.

class AutoArchive._mainf.icomponent.IComponent(interfaceAccessor)[source]

Bases: builtins.object

Interface for components of Mainf framework.

Each component of Mainf framework has to implement this interface. Components are managed by MainfEngine and can expose their interfaces via IInterfaceAccessor.

During construction the component can get and access other’s components interfaces via interfaceAccessor. Using the same object it can register its own public interfaces as well.

See also the description of _mainf package (_mainf).

Parameters:interfaceAccessor (IInterfaceAccessor) – Can be used to get/register public interfaces.
run()[source]

Runs the component.

Executes the work that the component is meant to do.

Returns:True, if execution was successful.
Return type:bool

icomponent-ui

IComponentUi interface, UiMessageKinds and VerbosityLevels enums.

class AutoArchive._mainf.icomponent_ui.IComponentUi[source]

Bases: AutoArchive._mainf.iinterface_accessor.IComponentInterface

Basic interface for an UI implementation.

Defines basic methods for showing messages of various importance to a user.

Note

There should be at least one component that implements this interface in order to provide an UI access to other components.

See also the description of _mainf package (_mainf).

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.
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 verbosity property.

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._py_additions.event object at 0x7f690b5fce80>[source]
verbosity[source]

Gets the verbosity level.

If verbosity level is VerbosityLevels.Quiet only messages of kind UiMessageKinds.Error are shown. For level VerbosityLevels.Normal all messages kinds except UiMessageKinds.Verbose are shown. For level VerbosityLevels.Verbose all message kinds are shown.

Return type:VerbosityLevels
AutoArchive._mainf.icomponent_ui.UiMessageKinds = Verbose, Notification, Info, Warning, Error

Kinds of user messages.

AutoArchive._mainf.icomponent_ui.VerbosityLevels = Quiet, Normal, Verbose

Verbosity levels.

iinterface_accessor

IInterfaceAccessor and :class:`IComponentInterface interfaces.

class AutoArchive._mainf.iinterface_accessor.IInterfaceAccessor[source]

Bases: builtins.object

Provides access to components public interfaces.

A component can make available its provided interfaces to other components by registering them via this interface. Registered classes has to implement IComponentInterface.

See also the description of _mainf package (_mainf).

getComponentInterface(interfaceType)[source]

Provides access to registered component interfaces.

See also: registerComponentInterface().

Parameters:

interfaceType (type{IComponentInterface}) – Type of the desired interface.

Returns:

Instance of interfaceType.

Return type:

interfaceType

Raises:
  • TypeError – If interfaceType does not implement IComponentInterface.
  • KeyError – If interfaceType is not registered.
registerComponentInterface(interfaceType, instance)[source]

Registers a component public interface.

Makes an interface available to other components by registering it.

See also: unregisterComponentInterface(), getComponentInterface().

Parameters:
  • interfaceType (type{IComponentInterface}) – Type of registering instance.
  • instance (:class:.IComponentInterface) – An instance of a class implementing the interfaceType.
Raises:
  • TypeError – If interfaceType or instance does not implement IComponentInterface.
  • KeyError – If interfaceType is already registered.
unregisterComponentInterface(interfaceType)[source]

Unregister a component interface.

See also: registerComponentInterface(), getComponentInterface()

Parameters:

interfaceType (type{IComponentInterface}) – Type of the instance that should be unregistered.

Raises:
  • TypeError – If interfaceType does not implement IComponentInterface.
  • KeyError – If interfaceType is not registered.
class AutoArchive._mainf.iinterface_accessor.IComponentInterface[source]

Bases: builtins.object

Tagging interface for components provided interfaces.

See also: IInterfaceAccessor.

imainf_context

IMainfContext interface.

class AutoArchive._mainf.imainf_context.IMainfContext[source]

Bases: AutoArchive._mainf.iinterface_accessor.IComponentInterface

Provides access to a various program-related objects.

appEnvironment[source]

Gets an appEnvironment object.

This is the object that was passed to the Mainf during its initialization. It is an arbitrary object of which structure Mainf has no knowledge.

Warning

As passing the appEnvironment object to Mainf is optional this property can be None.

Return type:object

main

createMainfEngine() function.

AutoArchive._mainf.main.createMainfEngine()[source]

Creates an instance of MainfEngine.

Returns:A MainfEngine instance.
Return type:MainfEngine

Table Of Contents

Previous topic

AutoArchive

Next topic

AutoArchive._mainf._core