Skip to main content

Constructor injection for Python

Project description

diapyr

Constructor injection for Python.

This README is auto-generated, see project wiki for details.

API

diapyr

DI

Convenience import.

types

Convenience import.

diapyr.diapyr

types
def types(*deptypes, **kwargs)

Declare that the decorated function or method expects args of the given types. Use square brackets to request all instances of a type as a list. Use this kwarg to declare the type of result returned by a factory.

DI Objects

class DI()

add
def add(*objs)

Register the given classes, factories or instances.

all
def all(type)

Return all objects of the given type, instantiating them and collaborators if necessary.

__call__
def __call__(clazz)

Return unique object of the given type, instantiating it and its collaborators if necessary.

join
def join(type)

Add a source to the parent that requests the given type from this container.

discardall
def discardall()

Discard all instances created in the current context. Each instance created not via a context manager will have its dispose method called if there is one. Normally this procedure is automatic on context exit, this method is provided for the root context which is never exited.

diapyr.start

diapyr.util

bfs
def bfs(keys)

Breadth-first search starting with the given iterable of keys, intended to be used as a decorator. If a function is decorated it should take an info object and key, and yield subsequent keys. If a class is decorated, a new instance of it is used as info object: The class should have a newdepth method that will be called before each depth, and a process method that takes a key and yields subsequent keys as in the function case. The info object is kept updated with the list of currentkeys, current depth and the set of donekeys. Note that the first currentkeys (depth 0) is exactly the passed in keys iterable, subsequent currentkeys will be non-empty lists. The process function is only invoked for keys that have not yet been processed, i.e. unique keys. When finished the decorated function/class is replaced with the last state of the info object.

setuphacks

getsetupkwargs
def getsetupkwargs(setuppath, fields)

Extract the kwargs passed to setup at the given path (typically some setup.py) that have names in the given fields.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diapyr-42.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diapyr-42-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file diapyr-42.tar.gz.

File metadata

  • Download URL: diapyr-42.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for diapyr-42.tar.gz
Algorithm Hash digest
SHA256 36c29a98c0c4e9a8969497659e42bf562e05d902f55863a67c7479aadd8d182f
MD5 309098e9373f2b3233312f0564641920
BLAKE2b-256 f7b9e1984d565473077a48e4593a22f2ad96fe128cd1c77df6c5f4d57e8bfb8f

See more details on using hashes here.

File details

Details for the file diapyr-42-py3-none-any.whl.

File metadata

  • Download URL: diapyr-42-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for diapyr-42-py3-none-any.whl
Algorithm Hash digest
SHA256 9b7ffecdbd43a3e60df1e7c0cfa26f8af50d9f4fd0d9337072f6b6553a2a8441
MD5 ceac12cca2e191c8109ca41677569ca3
BLAKE2b-256 3fee31220307613a848f79b728600d3099fe962839c0aa09bc5037446ff6784f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page