AutoArchive._infrastructure

Infrastructure, common and multi-layer classes, helpers.

Modules

py_additions

Various enhancements to Python.

class AutoArchive._infrastructure.py_additions.Enum(*names)[source]

Bases: collections.abc.Iterable

Simple enum class.

Example Usage:

codes = Enum("FOO", "BAR", "BAZ") # codes.BAZ will be 2 and so on and str.BAZ will be "BAZ"
Parameters:names (Iterator<str>) – Iterable of Enum members.
class AutoArchive._infrastructure.py_additions.event(eventFunction)[source]

Bases: object

Decorator that declares a function as an event.

Implements a C#-like events (a call dispatchers). Decorating a function or method with this decorator declares it as an event. In order to subscribe a handler function to the event, one should use the “+=” operator and to unsubscribe the “-=” operator. Such event can be fired by a calling the decorated function. This will dispatch the event to all subscribers, i.e. subscribed handler methods are called.

Note

Decorated function should implement only pass as its body.

Note

Decorated function can take any number of parameters or keyword parameters. Subscriber functions has to take same parameters as the event.

Example usage:

class Button:
   # ...
   @event
   def clicked(self, some_parameter):
       "Fired when the button was clicked."
       pass
   def _fireClicked(self, some_parameter):
       clicked(some_parameter)
   # ...

class Ui:
    def __init__(self, button):
        button.clicked += self._onButtonClicked
    def _onButtonClicked(self, some_parameter):
        "Handle the button click."
        # play a sound...
Parameters:eventFunction (function) – Decorated function or method that becomes an event.
class AutoArchive._infrastructure.py_additions.classproperty[source]

Bases: property

Decorator that makes the decorated method a class property.

class AutoArchive._infrastructure.py_additions.staticproperty[source]

Bases: property

Decorator that makes the decorated method a static property.

utils

Utils and Constants classes.

class AutoArchive._infrastructure.utils.Utils[source]

Bases: object

Various utility methods.

classmethod fatalExit(msg, appName=None)[source]

Prints msg to standard error and exits with exit code 2.

classmethod printError(msg, appName=None)[source]

Prints msg as an error to standard error.

classmethod printWarning(msg, appName=None)[source]

Prints msg as a warning to standard error.

static uniq(decorated)[source]

Decorator that filters out duplicate elements from an iterable returned by decorated function.

class AutoArchive._infrastructure.utils.Constants[source]

Bases: object

Defines various “global” constants.

DEBUG = 'true'

Debugging support.

_app_environment

AppEnvironment class

class AutoArchive._infrastructure._app_environment.AppEnvironment(executableName, options, arguments)[source]

Bases: object

Container class for various application-related information.

Parameters:
  • executableName (str) – Name of the startup script.
  • options (optparse.Values) – Options passed on the command line.
  • arguments (list<str>) – Arguments passed on the command line.
arguments

Command line arguments.

Return type:list<str>
executableName

Name of the script that was used to start this application.

Return type:str
options

Command line options.

Return type:optparse.Values

_application_context

ApplicationContext class.

class AutoArchive._infrastructure._application_context.ApplicationContext(appEnvironment, configuration, storage)[source]

Bases: object

Provides access to a various program-related objects.

Parameters:
  • appEnvironment (object) – Object that will be made available via appEnvironment property.
  • configuration (IConfiguration) – Application configuration.
  • storage (FileStorage) – Application storage.
appEnvironment

Gets the application environment object.

Return type:object
configuration

Gets access to application configuration.

Return type:ConfigurationBase

Warning

Can be None

storage

Gets access to application persistent storage.

Return type:FileStorage

Warning

Can be None