AutoArchive._infrastructure

Infrastructure, common and multi-layer classes, helpers.

Sub-Packages

Modules

py_additions

Various enhancements to Python.

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

Bases: 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.Flag[source]

Bases: object

Context management-aware boolean flag.

Example usage:

class Foo:
   def __init__(self):
       self._someFlag = Flag()

   def bar(self):
       with self._someFlag:
           # do_stuff

   def baz(self):
       if self._someFlag.isSet():
          # do_not_do_stuff
          return
isSet()[source]

Returns True if the flag is set; False otherwise.

class AutoArchive._infrastructure.py_additions.classproperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: property

Decorator that makes the decorated method a class property.

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.maxRecursion(maxDepth)[source]

Bases: ContextDecorator

Decorator that limits number of recursive calls to a function.

Parameters:

maxDepth – Recursion limit.

Raises:

RuntimeError – If recursion limit was exceeded.

class AutoArchive._infrastructure.py_additions.staticproperty(fget=None, fset=None, fdel=None, doc=None)[source]

Bases: property

Decorator that makes the decorated method a static property.

_app_environment

AppEnvironment class

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

Bases: object

Container class for various application-related information.

Parameters:
  • executableName (str) – Name of the startup script.

  • commandLineOptions (collections.abc.Mapping) – Options passed on the command line.

  • arguments (list<str>) – Arguments passed on the command line.

property arguments

Command line arguments.

Return type:

list<str>

property commandLineOptions

Command line options.

Return type:

collections.abc.Mapping

property executableName

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

Return type:

str

_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.

property appEnvironment

Gets the application environment object.

Return type:

object

property configuration

Gets access to application configuration.

Return type:

ConfigurationBase

Warning

Can be None

property storage

Gets access to application persistent storage.

Return type:

FileStorage

Warning

Can be None