autowire.impl package

Submodules

autowire.impl.function module

impl.function

Function implementation classes

class autowire.impl.function.FunctionImplementation(function: function, evaluator: function)[source]

Bases: autowire.base.Implementation

Implementation with wrapping function and evaluator

Parameters:
  • function – function to be wrapped.
  • evaluator ((Function, BaseResource, BaseContext) -> ContextManager) – function evaluator for reifying.
reify(resource: autowire.base.BaseResource, context: autowire.base.BaseContext)[source]

autowire.impl.implementable module

impl.implementable

Abstract base class for implementable things.

class autowire.impl.implementable.Implementable[source]

Bases: object

Some type that can be implemented

implement(implementation: autowire.base.Implementation) → autowire.base.Implementation[source]

Implement this.

It returns given implementation so that can be used as a decorator.

Module contents

impl

Implementers.

autowire.impl.implementation(fn)[source]

Create an implmentation with function that compatible with reify method.

The implementation can be called same as original function.

autowire.impl.contextual(fn)[source]

Create an implementation with function that returns context manager.

The implementation can be called same as original function.

autowire.impl.plain(fn)[source]

Create an implementation with plain function.

The implementation can be called same as original function.

autowire.impl.autowired(argname_or_required, required=None)[source]

Resolve a required resource and inject into function implementation as keyword argument.

dependency = Resource('foo', __name__)

@autowired('dependency', dependency)
@impl.plain
def create_something(dependency):
    return create(dependency)

Resource’s name property will be used by default for keyword name.

dependency = Resource('foo', __name__)

@autowired(dependency)
@impl.plain
def create_something(foo):
    return create(foo)
class autowire.impl.Implementation[source]

Bases: object

Base implementation type

reify(resource: autowire.base.BaseResource, context: autowire.base.BaseContext)[source]
class autowire.impl.Implementable[source]

Bases: object

Some type that can be implemented

implement(implementation: autowire.base.Implementation) → autowire.base.Implementation[source]

Implement this.

It returns given implementation so that can be used as a decorator.