mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Rename Objects to Dependency Injector
This commit is contained in:
parent
c9374038be
commit
6d0f892f8a
|
@ -1,3 +1,3 @@
|
|||
[run]
|
||||
include = objects/*
|
||||
include = dependency_injector/*
|
||||
omit = tests/*
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:
|
|||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of Objects nor the names of its
|
||||
* Neither the name of "Dependency Injector" nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
include objects/*
|
||||
include dependency_injector/*
|
||||
include README.rst
|
||||
include LICENSE
|
||||
include VERSION
|
||||
|
|
103
README.rst
103
README.rst
|
@ -1,58 +1,59 @@
|
|||
Objects
|
||||
=======
|
||||
Dependency Injector
|
||||
===================
|
||||
|
||||
Dependency injection framework for Python projects.
|
||||
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *PyPi* | .. image:: https://img.shields.io/pypi/v/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Latest Version |
|
||||
| | .. image:: https://img.shields.io/pypi/dm/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Downloads |
|
||||
| | .. image:: https://img.shields.io/pypi/l/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: License |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *Python versions and implementations* | .. image:: https://img.shields.io/pypi/pyversions/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Supported Python versions |
|
||||
| | .. image:: https://img.shields.io/pypi/implementation/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Supported Python implementations |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *Builds and tests coverage* | .. image:: https://travis-ci.org/rmk135/objects.svg?branch=master |
|
||||
| | :target: https://travis-ci.org/rmk135/objects |
|
||||
| | :alt: Build Status |
|
||||
| | .. image:: https://coveralls.io/repos/rmk135/objects/badge.svg |
|
||||
| | :target: https://coveralls.io/r/rmk135/objects |
|
||||
| | :alt: Coverage Status |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *PyPi* | .. image:: https://img.shields.io/pypi/v/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Latest Version |
|
||||
| | .. image:: https://img.shields.io/pypi/dm/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Downloads |
|
||||
| | .. image:: https://img.shields.io/pypi/l/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: License |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *Python versions and implementations* | .. image:: https://img.shields.io/pypi/pyversions/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Supported Python versions |
|
||||
| | .. image:: https://img.shields.io/pypi/implementation/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Supported Python implementations |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *Builds and tests coverage* | .. image:: https://travis-ci.org/rmk135/dependency_injector.svg?branch=master |
|
||||
| | :target: https://travis-ci.org/rmk135/dependency_injector |
|
||||
| | :alt: Build Status |
|
||||
| | .. image:: https://coveralls.io/repos/rmk135/dependency_injector/badge.svg |
|
||||
| | :target: https://coveralls.io/r/rmk135/dependency_injector |
|
||||
| | :alt: Coverage Status |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
|
||||
*Objects* is a dependency injection framework for Python projects.
|
||||
*Dependency Injector* is a dependency injection framework for Python projects.
|
||||
It was designed to be unified, developer's friendly tool for managing any kind
|
||||
of Python objects and their dependencies in formal, pretty way.
|
||||
|
||||
Below is a list of some key features and points of *Objects* framework:
|
||||
Below is a list of some key features and points of *Dependency Injector*
|
||||
framework:
|
||||
|
||||
- Easy, smart, pythonic style.
|
||||
- Obvious, clear structure.
|
||||
- Memory efficiency.
|
||||
- Semantic versioning.
|
||||
|
||||
Main idea of *Objects* is to keep dependencies under control.
|
||||
Main idea of *Dependency Injector* is to keep dependencies under control.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
*Objects* library is available on PyPi_::
|
||||
*Dependency Injector* library is available on PyPi_::
|
||||
|
||||
pip install objects
|
||||
pip install dependency_injector
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
*Objects* documentation is hosted on ReadTheDocs:
|
||||
*Dependency Injector* documentation is hosted on ReadTheDocs:
|
||||
|
||||
- `Stable version`_
|
||||
- `Latest version`_
|
||||
|
@ -62,16 +63,16 @@ Examples
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
"""Concept example of `Objects`."""
|
||||
"""Concept example of `Dependency Injector`."""
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import inject
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import inject
|
||||
|
||||
import sqlite3
|
||||
|
||||
|
@ -97,21 +98,21 @@ Examples
|
|||
|
||||
class Catalog(AbstractCatalog):
|
||||
|
||||
"""Catalog of objects providers."""
|
||||
"""Catalog of dependency_injector providers."""
|
||||
|
||||
database = Singleton(sqlite3.Connection,
|
||||
KwArg('database', ':memory:'),
|
||||
Attribute('row_factory', sqlite3.Row))
|
||||
""":type: (objects.Provider) -> sqlite3.Connection"""
|
||||
""":type: (dependency_injector.Provider) -> sqlite3.Connection"""
|
||||
|
||||
object_a_factory = Factory(ObjectA,
|
||||
KwArg('db', database))
|
||||
""":type: (objects.Provider) -> ObjectA"""
|
||||
""":type: (dependency_injector.Provider) -> ObjectA"""
|
||||
|
||||
object_b_factory = Factory(ObjectB,
|
||||
KwArg('a', object_a_factory),
|
||||
KwArg('db', database))
|
||||
""":type: (objects.Provider) -> ObjectB"""
|
||||
""":type: (dependency_injector.Provider) -> ObjectB"""
|
||||
|
||||
|
||||
# Catalog static provides.
|
||||
|
@ -134,26 +135,26 @@ Examples
|
|||
|
||||
example()
|
||||
|
||||
You can get more *Objects* examples in ``/examples`` directory on
|
||||
You can get more *Dependency Injector* examples in ``/examples`` directory on
|
||||
GitHub:
|
||||
|
||||
https://github.com/rmk135/objects
|
||||
https://github.com/rmk135/dependency_injector
|
||||
|
||||
|
||||
Feedback
|
||||
--------
|
||||
|
||||
Feel free to post questions, bugs, feature requests, proposals etc. on
|
||||
*Objects* GitHub Issues:
|
||||
*Dependency Injector* GitHub Issues:
|
||||
|
||||
https://github.com/rmk135/objects/issues
|
||||
https://github.com/rmk135/dependency_injector/issues
|
||||
|
||||
Your feedback is quite important!
|
||||
|
||||
|
||||
.. _PyPi: https://pypi.python.org/pypi/Objects
|
||||
.. _Stable version: http://objects.readthedocs.org/en/stable/
|
||||
.. _Latest version: http://objects.readthedocs.org/en/latest/
|
||||
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
||||
.. _Stable version: http://dependency_injector.readthedocs.org/en/stable/
|
||||
.. _Latest version: http://dependency_injector.readthedocs.org/en/latest/
|
||||
.. _SLOC: http://en.wikipedia.org/wiki/Source_lines_of_code
|
||||
.. _SOLID: http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29
|
||||
.. _IoC: http://en.wikipedia.org/wiki/Inversion_of_control
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
"""Objects.
|
||||
|
||||
Dependency management tool for Python projects.
|
||||
"""
|
||||
"""Dependency injector."""
|
||||
|
||||
from .catalog import AbstractCatalog
|
||||
from .catalog import override
|
|
@ -87,9 +87,9 @@ qthelp:
|
|||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/objects.qhcp"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/dependency_injector.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/objects.qhc"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/dependency_injector.qhc"
|
||||
|
||||
applehelp:
|
||||
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
|
||||
|
@ -104,8 +104,8 @@ devhelp:
|
|||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/objects"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/objects"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/dependency_injector"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/dependency_injector"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
Advanced usage
|
||||
==============
|
||||
|
||||
Current section of documentation describes advanced usage of *Objects*.
|
||||
Current section of documentation describes advanced usage of
|
||||
*Dependency Injector*.
|
||||
|
||||
@inject decorator
|
||||
-----------------
|
||||
|
@ -12,10 +13,10 @@ It *patches* decorated callable in such way that dependency injection will be
|
|||
done during every call of decorated callable.
|
||||
|
||||
``@inject`` decorator takes only argument that is supposed to be an
|
||||
``objects.injections.KwArg`` injection.
|
||||
``dependency_injector.injections.KwArg`` injection.
|
||||
|
||||
Any Python object will be injected *as is*, except *Objects* providers,
|
||||
that will be called to provide injectable value.
|
||||
Any Python object will be injected *as is*, except *Dependency Injector*
|
||||
providers, that will be called to provide injectable value.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Writing catalogs
|
|||
----------------
|
||||
|
||||
Catalogs have to be created by extending base catalog class
|
||||
``objects.catalog.AbstractCatalog``.
|
||||
``dependency_injector.catalog.AbstractCatalog``.
|
||||
|
||||
Providers have to be defined like catalog's attributes. Every provider in
|
||||
catalog has name. This name should follow ``some_provider`` manner, that is
|
||||
|
@ -29,10 +29,10 @@ standard naming convention for names of attributes in Python.
|
|||
.. note::
|
||||
|
||||
It might be useful to add such
|
||||
``""":type: (objects.Provider) -> Object1"""`` documentation blocks one
|
||||
line after provider definition for every provider. It will help code
|
||||
analysis tools and IDE's to understand that variable above contains some
|
||||
callable object, that returns particular instance as a result of call.
|
||||
``""":type: (dependency_injector.Provider) -> Object1"""`` documentation
|
||||
blocks one line after provider definition for every provider. It will help
|
||||
code analysis tools and IDE's to understand that variable above contains
|
||||
some callable object, that returns particular instance as a result of call.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
14
docs/conf.py
14
docs/conf.py
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Objects documentation build configuration file, created by
|
||||
# Dependency Injector documentation build configuration file, created by
|
||||
# sphinx-quickstart on Wed Apr 1 17:36:06 2015.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
|
@ -44,7 +44,7 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'Objects'
|
||||
project = u'Dependency Injector'
|
||||
copyright = u'2015, Roman Mogilatov'
|
||||
author = u'Roman Mogilatov'
|
||||
|
||||
|
@ -201,7 +201,7 @@ html_static_path = ['_static']
|
|||
#html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'objectsdoc'
|
||||
htmlhelp_basename = 'dependency_injectordoc'
|
||||
|
||||
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from
|
||||
# docs.readthedocs.org
|
||||
|
@ -234,7 +234,7 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'Objects.tex', u'Objects Documentation',
|
||||
(master_doc, 'dependency_injector.tex', u'Dependency Injector Documentation',
|
||||
u'Roman Mogilatov', 'manual'),
|
||||
]
|
||||
|
||||
|
@ -264,7 +264,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'Objects', u'Objects Documentation',
|
||||
(master_doc, 'Dependency Injector', u'Dependency Injector Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
@ -278,8 +278,8 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'Objects', u'Objects Documentation',
|
||||
author, 'Objects', 'Dependency management tool for Python projects.',
|
||||
(master_doc, 'Dependency Injector', u'Dependency Injector Documentation',
|
||||
author, 'Dependency Injector', 'Dependency management tool for Python projects.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
|
|
@ -1,46 +1,47 @@
|
|||
Objects
|
||||
=======
|
||||
Dependency Injector
|
||||
===================
|
||||
|
||||
Dependency injection framework for Python projects.
|
||||
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *PyPi* | .. image:: https://img.shields.io/pypi/v/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Latest Version |
|
||||
| | .. image:: https://img.shields.io/pypi/dm/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Downloads |
|
||||
| | .. image:: https://img.shields.io/pypi/l/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: License |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *Python versions and implementations* | .. image:: https://img.shields.io/pypi/pyversions/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Supported Python versions |
|
||||
| | .. image:: https://img.shields.io/pypi/implementation/Objects.svg |
|
||||
| | :target: https://pypi.python.org/pypi/Objects/ |
|
||||
| | :alt: Supported Python implementations |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
| *Builds and tests coverage* | .. image:: https://travis-ci.org/rmk135/objects.svg?branch=master |
|
||||
| | :target: https://travis-ci.org/rmk135/objects |
|
||||
| | :alt: Build Status |
|
||||
| | .. image:: https://coveralls.io/repos/rmk135/objects/badge.svg |
|
||||
| | :target: https://coveralls.io/r/rmk135/objects |
|
||||
| | :alt: Coverage Status |
|
||||
+---------------------------------------+-------------------------------------------------------------------+
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *PyPi* | .. image:: https://img.shields.io/pypi/v/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Latest Version |
|
||||
| | .. image:: https://img.shields.io/pypi/dm/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Downloads |
|
||||
| | .. image:: https://img.shields.io/pypi/l/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: License |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *Python versions and implementations* | .. image:: https://img.shields.io/pypi/pyversions/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Supported Python versions |
|
||||
| | .. image:: https://img.shields.io/pypi/implementation/dependency_injector.svg |
|
||||
| | :target: https://pypi.python.org/pypi/dependency_injector/ |
|
||||
| | :alt: Supported Python implementations |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
| *Builds and tests coverage* | .. image:: https://travis-ci.org/rmk135/dependency_injector.svg?branch=master |
|
||||
| | :target: https://travis-ci.org/rmk135/dependency_injector |
|
||||
| | :alt: Build Status |
|
||||
| | .. image:: https://coveralls.io/repos/rmk135/dependency_injector/badge.svg |
|
||||
| | :target: https://coveralls.io/r/rmk135/dependency_injector |
|
||||
| | :alt: Coverage Status |
|
||||
+---------------------------------------+-------------------------------------------------------------------------------+
|
||||
|
||||
*Objects* is a dependency injection framework for Python projects.
|
||||
*Dependency Injector* is a dependency injection framework for Python projects.
|
||||
It was designed to be unified, developer's friendly tool for managing any kind
|
||||
of Python objects and their dependencies in formal, pretty way.
|
||||
|
||||
Below is a list of some key features and points of *Objects* framework:
|
||||
Below is a list of some key features and points of *Dependency Injector*
|
||||
framework:
|
||||
|
||||
- Easy, smart, pythonic style.
|
||||
- Obvious, clear structure.
|
||||
- Memory efficiency.
|
||||
- Semantic versioning.
|
||||
|
||||
Main idea of *Objects* is to keep dependencies under control.
|
||||
Main idea of *Dependency Injector* is to keep dependencies under control.
|
||||
|
||||
Contents
|
||||
--------
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
This document describes all the changes in *Objects* framework that were made
|
||||
in every particular version.
|
||||
This document describes all the changes in *Dependency Injector* framework
|
||||
that were made in every particular version.
|
||||
|
||||
From version 0.7.6 *Objects* framework strictly follows `Semantic versioning`_
|
||||
From version 0.7.6 *Dependency Injector* framework strictly
|
||||
follows `Semantic versioning`_
|
||||
|
||||
|
||||
Development version
|
||||
|
@ -12,6 +13,10 @@ Development version
|
|||
|
||||
- No features.
|
||||
|
||||
0.8.0
|
||||
-----
|
||||
- ``Objects`` is renamed to ``Dependency Injector``.
|
||||
|
||||
0.7.8
|
||||
-----
|
||||
- Fixing @inject import bug in examples.
|
||||
|
|
|
@ -2,8 +2,8 @@ Feedback
|
|||
========
|
||||
|
||||
Feel free to post questions, bugs, feature requests, proposals etc. on
|
||||
*Objects* GitHub Issues:
|
||||
*Dependency Injector* GitHub Issues:
|
||||
|
||||
https://github.com/rmk135/objects/issues
|
||||
https://github.com/rmk135/dependency_injector/issues
|
||||
|
||||
Your feedback is quite important!
|
||||
|
|
|
@ -1,27 +1,28 @@
|
|||
Installation
|
||||
============
|
||||
|
||||
*Objects* framework is distributed by PyPi_.
|
||||
*Dependency Injector* framework is distributed by PyPi_.
|
||||
|
||||
Latest stable version (and all previous versions) of *Objects* framework can be
|
||||
installed from PyPi_:
|
||||
Latest stable version (and all previous versions) of *Dependency Injector*
|
||||
framework can be installed from PyPi_:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# Installing latest version:
|
||||
pip install objects
|
||||
pip install dependency_injector
|
||||
|
||||
# Installing particular version:
|
||||
pip install objects==0.7.5
|
||||
pip install dependency_injector==0.7.5
|
||||
|
||||
Sources can be cloned from GitHub_:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://github.com/rmk135/objects.git
|
||||
git clone https://github.com/rmk135/dependency_injector.git
|
||||
|
||||
Also all *Objects* releases can be downloaded from `GitHub releases page`_.
|
||||
Also all *Dependency Injector* releases can be downloaded from
|
||||
`GitHub releases page`_.
|
||||
|
||||
.. _PyPi: https://pypi.python.org/pypi/Objects
|
||||
.. _GitHub: https://github.com/rmk135/objects
|
||||
.. _GitHub releases page: https://github.com/rmk135/objects/releases
|
||||
.. _PyPi: https://pypi.python.org/pypi/dependency_injector
|
||||
.. _GitHub: https://github.com/rmk135/dependency_injector
|
||||
.. _GitHub releases page: https://github.com/rmk135/dependency_injector/releases
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
Before you have started with *Objects* framework and dependecy injection, there
|
||||
are a couple of introduction notes that might be useful.
|
||||
Before you have started with *Dependency Injector* framework and dependecy
|
||||
injection, there are a couple of introduction notes that might be useful.
|
||||
|
||||
What is DI and why is it needed?
|
||||
--------------------------------
|
||||
|
@ -43,24 +43,25 @@ ways to do dependency injection container.
|
|||
Key features
|
||||
------------
|
||||
|
||||
*Objects* is a dependency injection framework for Python projects.
|
||||
*Dependency Injector* is a dependency injection framework for Python projects.
|
||||
It was designed to be unified, developer's friendly tool for managing any kind
|
||||
of Python objects and their dependencies in formal, pretty way.
|
||||
|
||||
Below is a list of some key features and points of *Objects* framework:
|
||||
Below is a list of some key features and points of *Dependency Injector*
|
||||
framework:
|
||||
|
||||
- Easy, smart, pythonic style.
|
||||
- Obvious, clear structure.
|
||||
- Memory efficiency.
|
||||
- Semantic versioning.
|
||||
|
||||
Main idea of *Objects* is to keep dependencies under control.
|
||||
Main idea of *Dependency Injector* is to keep dependencies under control.
|
||||
|
||||
Main entities
|
||||
-------------
|
||||
|
||||
Current section describes *Objects* main entities and their interaction with
|
||||
each other.
|
||||
Current section describes *Dependency Injector* main entities and their
|
||||
interaction with each other.
|
||||
|
||||
.. image:: /images/internals.png
|
||||
:width: 100%
|
||||
|
@ -69,18 +70,20 @@ each other.
|
|||
There are 3 main entities:
|
||||
|
||||
- Providers. Providers are strategies of accesing objects. For example,
|
||||
``objects.providers.Factory`` creates new instance of provided class every
|
||||
time it is called. ``objects.providers.Singleton`` creates provided instance
|
||||
once and returns it on every next call. Providers could be overridden by
|
||||
another providers. Base class is - ``objects.providers.Provider``.
|
||||
``dependency_injector.providers.Factory`` creates new instance of provided
|
||||
class every time it is called. ``dependency_injector.providers.Singleton``
|
||||
creates provided instance once and returns it on every next call. Providers
|
||||
could be overridden by another providers. Base class is -
|
||||
``dependency_injector.providers.Provider``.
|
||||
- Injections. Injections are instructions for making dependency injections
|
||||
(there are several ways how they could be done). Injections are used mostly
|
||||
by ``objects.providers.Factory`` and ``objects.providers.Singleton``
|
||||
providers, but these are not only cases. Base class is -
|
||||
``objects.injections.Injection``.
|
||||
by ``dependency_injector.providers.Factory`` and
|
||||
``dependency_injector.providers.Singleton`` providers, but these are not only
|
||||
cases. Base class is -
|
||||
``dependency_injector.injections.Injection``.
|
||||
- Catalogs. Catalogs are collections of providers. They are used for grouping
|
||||
of providers by some principles. Base class is -
|
||||
``objects.catalog.AbstractCatalog``.
|
||||
``dependency_injector.catalog.AbstractCatalog``.
|
||||
|
||||
|
||||
.. _SLOC: http://en.wikipedia.org/wiki/Source_lines_of_code
|
||||
|
|
|
@ -1,28 +1,31 @@
|
|||
Writing custom providers
|
||||
------------------------
|
||||
|
||||
List of *Objects* providers could be widened with custom providers.
|
||||
List of *Dependency Injector* providers could be widened with custom providers.
|
||||
|
||||
Below are some tips and recommendations that have to be met:
|
||||
|
||||
1. Every custom provider has to extend base provider class -
|
||||
``objects.providers.Provider``.
|
||||
``dependency_injector.providers.Provider``.
|
||||
2. Cusom provider's ``__init__()`` could be overriden with only condition:
|
||||
parent initializer (``objects.providers.Provider.__init__()``) has
|
||||
to be called.
|
||||
parent initializer
|
||||
(``dependency_injector.providers.Provider.__init__()``) has to be called.
|
||||
3. Providing strategy has to be implemented in custom provider's
|
||||
``_provide()`` method. All ``*args`` & ``**kwargs`` that will be
|
||||
recieved by ``objects.providers.Provider.__call__()`` will be transefed
|
||||
recieved by ``dependency_injector.providers.Provider.__call__()`` will be
|
||||
transefed
|
||||
to custom provider's ``_provide()``.
|
||||
4. If custom provider is based on some standard providers, it is better to
|
||||
use delegation of standard providers, then extending of them.
|
||||
5. If custom provider defines any attributes, it is good to list them in
|
||||
``__slots__`` attribute (as *Objects* does). It can save some memory.
|
||||
``__slots__`` attribute (as *Dependency Injector* does). It can save
|
||||
some memory.
|
||||
6. If custom provider deals with injections (e.g. ``Factory``,
|
||||
``Singleton`` providers), it is strongly recommended to use
|
||||
``objects.injections.Injection`` and its subclasses:
|
||||
``objects.injections.KwArg``, ``objects.injections.Attribute`` and
|
||||
``objects.injections.Method``.
|
||||
``dependency_injector.injections.Injection`` and its subclasses:
|
||||
``dependency_injector.injections.KwArg``,
|
||||
``dependency_injector.injections.Attribute`` and
|
||||
``dependency_injector.injections.Method``.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
|
@ -18,14 +18,14 @@ Factory providers and injections
|
|||
Objects can take dependencies in different forms. Some objects take init
|
||||
arguments, other are using attributes setting or method calls to be
|
||||
initialized. It affects how such objects need to be created and initialized,
|
||||
and that is the place where ``objects.injections`` need to be used.
|
||||
and that is the place where ``dependency_injector.injections`` need to be used.
|
||||
|
||||
``Factory`` provider takes various number of positional arguments, that define
|
||||
what kind of dependency injections need to be done.
|
||||
|
||||
All of those instructions are defined in ``objects.injections`` module and are
|
||||
subclasses of ``objects.injections.Injection``. There are several types of
|
||||
injections that are used by ``Factory`` provider:
|
||||
All of those instructions are defined in ``dependency_injector.injections``
|
||||
module and are subclasses of ``dependency_injector.injections.Injection``.
|
||||
There are several types of injections that are used by ``Factory`` provider:
|
||||
|
||||
+ ``KwArg`` - injection is done by passing injectable value in object's
|
||||
``__init__()`` method in time of object's creation via keyword argument.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
Objects
|
||||
=======
|
||||
|
||||
Examples:
|
||||
|
||||
- [Concept example.](examples/concept.py)
|
||||
- [Callable provider.](examples/callable_provider.py)
|
||||
- [Config provider.](examples/config_provider.py)
|
||||
- [Delegate.](examples/delegate.py)
|
||||
- [External dependency.](examples/external_dependency.py)
|
||||
- [Overrides.](examples/overrides.py)
|
|
@ -1,9 +1,9 @@
|
|||
"""Config provider examples."""
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.providers import Config
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.providers import Config
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
class ObjectA(object):
|
||||
|
@ -19,16 +19,16 @@ class ObjectA(object):
|
|||
|
||||
class Catalog(AbstractCatalog):
|
||||
|
||||
"""Catalog of objects providers."""
|
||||
"""Catalog of dependency_injector providers."""
|
||||
|
||||
config = Config()
|
||||
""":type: (objects.Config)"""
|
||||
""":type: (dependency_injector.Config)"""
|
||||
|
||||
object_a = Factory(ObjectA,
|
||||
KwArg('fee', config.FEE),
|
||||
KwArg('price', config.PRICE),
|
||||
KwArg('timezone', config.GLOBAL.TIMEZONE))
|
||||
""":type: (objects.Provider) -> ObjectA"""
|
||||
""":type: (dependency_injector.Provider) -> ObjectA"""
|
||||
|
||||
|
||||
# Setting config value and making some tests.
|
||||
|
|
|
@ -4,10 +4,10 @@ import sqlite3
|
|||
|
||||
from flask import Flask
|
||||
|
||||
from objects.providers import Singleton
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import inject
|
||||
from dependency_injector.providers import Singleton
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import inject
|
||||
|
||||
|
||||
# Database and `ObjectA` providers.
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
"""`@inject` decorator simple example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import inject
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import inject
|
||||
|
||||
|
||||
objects_factory = Factory(object)
|
||||
dependency_injector_factory = Factory(object)
|
||||
|
||||
|
||||
@inject(KwArg('new_object', objects_factory))
|
||||
@inject(KwArg('new_object', dependency_injector_factory))
|
||||
@inject(KwArg('some_setting', 1334))
|
||||
def example_callback(new_object, some_setting):
|
||||
"""Example callback that does some asserts with input args."""
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""Operating with catalog providers example."""
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.providers import Factory
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
|
||||
class Catalog(AbstractCatalog):
|
||||
|
@ -10,16 +10,16 @@ class Catalog(AbstractCatalog):
|
|||
"""Providers catalog."""
|
||||
|
||||
provider1 = Factory(object)
|
||||
""":type: (objects.Provider) -> object"""
|
||||
""":type: (dependency_injector.Provider) -> object"""
|
||||
|
||||
provider2 = Factory(object)
|
||||
""":type: (objects.Provider) -> object"""
|
||||
""":type: (dependency_injector.Provider) -> object"""
|
||||
|
||||
provider3 = Singleton(object)
|
||||
""":type: (objects.Provider) -> object"""
|
||||
""":type: (dependency_injector.Provider) -> object"""
|
||||
|
||||
provider4 = Singleton(object)
|
||||
""":type: (objects.Provider) -> object"""
|
||||
""":type: (dependency_injector.Provider) -> object"""
|
||||
|
||||
|
||||
# Making some asserts:
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
# Creating some example classes:
|
||||
|
@ -20,11 +20,11 @@ class Catalog(AbstractCatalog):
|
|||
object1_factory = Factory(Object1,
|
||||
KwArg('arg1', 1),
|
||||
KwArg('arg2', 2))
|
||||
""":type: (objects.Provider) -> Object1"""
|
||||
""":type: (dependency_injector.Provider) -> Object1"""
|
||||
|
||||
object2_factory = Factory(Object2,
|
||||
KwArg('object1', object1_factory))
|
||||
""":type: (objects.Provider) -> Object2"""
|
||||
""":type: (dependency_injector.Provider) -> Object2"""
|
||||
|
||||
|
||||
class AnotherCatalog(AbstractCatalog):
|
||||
|
@ -32,13 +32,13 @@ class AnotherCatalog(AbstractCatalog):
|
|||
"""Another providers catalog."""
|
||||
|
||||
object2_factory = Factory(ExtendedObject2)
|
||||
""":type: (objects.Provider) -> ExtendedObject2"""
|
||||
""":type: (dependency_injector.Provider) -> ExtendedObject2"""
|
||||
|
||||
|
||||
# Overriding `Catalog` with `AnotherCatalog`:
|
||||
Catalog.override(AnotherCatalog)
|
||||
|
||||
# Creating some objects using overridden catalog:
|
||||
# Creating some dependency_injector using overridden catalog:
|
||||
object2_1 = Catalog.object2_factory()
|
||||
object2_2 = Catalog.object2_factory()
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.catalog import override
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.catalog import override
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
# Creating some example classes:
|
||||
|
@ -21,11 +21,11 @@ class Catalog(AbstractCatalog):
|
|||
object1_factory = Factory(Object1,
|
||||
KwArg('arg1', 1),
|
||||
KwArg('arg2', 2))
|
||||
""":type: (objects.Provider) -> Object1"""
|
||||
""":type: (dependency_injector.Provider) -> Object1"""
|
||||
|
||||
object2_factory = Factory(Object2,
|
||||
KwArg('object1', object1_factory))
|
||||
""":type: (objects.Provider) -> Object2"""
|
||||
""":type: (dependency_injector.Provider) -> Object2"""
|
||||
|
||||
|
||||
# Overriding `Catalog` with `AnotherCatalog`:
|
||||
|
@ -35,10 +35,10 @@ class AnotherCatalog(AbstractCatalog):
|
|||
"""Another providers catalog."""
|
||||
|
||||
object2_factory = Factory(ExtendedObject2)
|
||||
""":type: (objects.Provider) -> ExtendedObject2"""
|
||||
""":type: (dependency_injector.Provider) -> ExtendedObject2"""
|
||||
|
||||
|
||||
# Creating some objects using overridden catalog:
|
||||
# Creating some dependency_injector using overridden catalog:
|
||||
object2_1 = Catalog.object2_factory()
|
||||
object2_2 = Catalog.object2_factory()
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
# Creating some example classes:
|
||||
|
@ -19,13 +19,13 @@ class Catalog(AbstractCatalog):
|
|||
object1_factory = Factory(Object1,
|
||||
KwArg('arg1', 1),
|
||||
KwArg('arg2', 2))
|
||||
""":type: (objects.Provider) -> Object1"""
|
||||
""":type: (dependency_injector.Provider) -> Object1"""
|
||||
|
||||
object2_factory = Factory(Object2,
|
||||
KwArg('object1', object1_factory))
|
||||
""":type: (objects.Provider) -> Object2"""
|
||||
""":type: (dependency_injector.Provider) -> Object2"""
|
||||
|
||||
# Creating some objects:
|
||||
# Creating some dependency_injector:
|
||||
object2_1 = Catalog.object2_factory()
|
||||
object2_2 = Catalog.object2_factory()
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
"""Concept example of `Objects`."""
|
||||
"""Concept example of `Dependency Injector`."""
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import inject
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import inject
|
||||
|
||||
import sqlite3
|
||||
|
||||
|
@ -33,21 +33,21 @@ class ObjectB(object):
|
|||
|
||||
class Catalog(AbstractCatalog):
|
||||
|
||||
"""Catalog of objects providers."""
|
||||
"""Catalog of dependency_injector providers."""
|
||||
|
||||
database = Singleton(sqlite3.Connection,
|
||||
KwArg('database', ':memory:'),
|
||||
Attribute('row_factory', sqlite3.Row))
|
||||
""":type: (objects.Provider) -> sqlite3.Connection"""
|
||||
""":type: (dependency_injector.Provider) -> sqlite3.Connection"""
|
||||
|
||||
object_a_factory = Factory(ObjectA,
|
||||
KwArg('db', database))
|
||||
""":type: (objects.Provider) -> ObjectA"""
|
||||
""":type: (dependency_injector.Provider) -> ObjectA"""
|
||||
|
||||
object_b_factory = Factory(ObjectB,
|
||||
KwArg('a', object_a_factory),
|
||||
KwArg('db', database))
|
||||
""":type: (objects.Provider) -> ObjectB"""
|
||||
""":type: (dependency_injector.Provider) -> ObjectB"""
|
||||
|
||||
|
||||
# Catalog static provides.
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
import sys
|
||||
|
||||
from objects.providers import Callable
|
||||
from objects.providers import Delegate
|
||||
from dependency_injector.providers import Callable
|
||||
from dependency_injector.providers import Delegate
|
||||
|
||||
|
||||
# Some callable provider and few delegates of it:
|
||||
# Creating some callable provider and few delegates of it:
|
||||
callable_provider = Callable(sys.exit)
|
||||
callable_provider_delegate1 = callable_provider.delegate()
|
||||
callable_provider_delegate2 = Delegate(callable_provider)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
from passlib.hash import sha256_crypt
|
||||
|
||||
from objects.providers import Callable
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.providers import Callable
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
# Password hasher and verifier providers (hash function could be changed
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Custom `Factory` example."""
|
||||
|
||||
from objects.providers import Provider
|
||||
from objects.providers import Factory
|
||||
from dependency_injector.providers import Provider
|
||||
from dependency_injector.providers import Factory
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
"""`ExternalDependency` providers example."""
|
||||
|
||||
from objects.providers import ExternalDependency
|
||||
from objects.providers import Factory
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.providers import ExternalDependency
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
|
||||
# Importing SQLITE3 and contextlib.closing for working with cursors:
|
||||
import sqlite3
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""`Factory` providers example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from dependency_injector.providers import Factory
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Factory` providers with attribute injections example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import Attribute
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import Attribute
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Factory` providers delegation example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
class User(object):
|
||||
|
@ -11,7 +11,7 @@ class User(object):
|
|||
def __init__(self, photos_factory):
|
||||
"""Initializer.
|
||||
|
||||
:param photos_factory: (objects.providers.Factory) -> Photo
|
||||
:param photos_factory: (dependency_injector.providers.Factory) -> Photo
|
||||
"""
|
||||
self.photos_factory = photos_factory
|
||||
self._main_photo = None
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Factory` providers with init injections example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Factory` providers with init injections and context arguments example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Factory` providers with method injections example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import Method
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import Method
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Simple providers overriding example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from dependency_injector.providers import Factory
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Overriding user's model example."""
|
||||
|
||||
from objects.providers import Factory
|
||||
from objects.injections import KwArg
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.injections import KwArg
|
||||
|
||||
|
||||
class User(object):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""`Singleton` providers example."""
|
||||
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
|
||||
class UserService(object):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""`Singleton` providers delegation example."""
|
||||
|
||||
from objects.providers import Singleton
|
||||
from objects.providers import Delegate
|
||||
from dependency_injector.providers import Singleton
|
||||
from dependency_injector.providers import Delegate
|
||||
|
||||
|
||||
# Some singleton provider and few delegates of it:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""`Singleton` providers resetting example."""
|
||||
|
||||
from objects.providers import Singleton
|
||||
from dependency_injector.providers import Singleton
|
||||
|
||||
|
||||
class UserService(object):
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
"""`Static` providers example."""
|
||||
|
||||
from objects.providers import Class
|
||||
from objects.providers import Object
|
||||
from objects.providers import Function
|
||||
from objects.providers import Value
|
||||
from dependency_injector.providers import Class
|
||||
from dependency_injector.providers import Object
|
||||
from dependency_injector.providers import Function
|
||||
from dependency_injector.providers import Value
|
||||
|
||||
|
||||
# Provides class - `object`:
|
||||
|
|
8
setup.py
8
setup.py
|
@ -1,4 +1,4 @@
|
|||
"""`Objects` setup script."""
|
||||
"""`Dependency injector` setup script."""
|
||||
|
||||
import os
|
||||
from setuptools import setup
|
||||
|
@ -44,7 +44,7 @@ class PublishCommand(Command):
|
|||
os.system('git push --tags')
|
||||
|
||||
|
||||
setup(name='Objects',
|
||||
setup(name='dependency_injector',
|
||||
version=version,
|
||||
description=SHORT_DESCRIPTION,
|
||||
long_description=description,
|
||||
|
@ -52,9 +52,9 @@ setup(name='Objects',
|
|||
author_email='rmogilatov@gmail.com',
|
||||
maintainer='Roman Mogilatov',
|
||||
maintainer_email='rmogilatov@gmail.com',
|
||||
url='https://github.com/rmk135/objects',
|
||||
url='https://github.com/rmk135/dependency_injector',
|
||||
license='BSD New',
|
||||
packages=['objects'],
|
||||
packages=['dependency_injector'],
|
||||
zip_safe=True,
|
||||
install_requires=requirements,
|
||||
cmdclass={
|
||||
|
|
|
@ -1 +1 @@
|
|||
"""Objects unittests."""
|
||||
"""Dependency injector unittests."""
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
"""Objects catalog unittests."""
|
||||
"""Dependency injector catalog unittests."""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
from objects.catalog import AbstractCatalog
|
||||
from objects.catalog import override
|
||||
from dependency_injector.catalog import AbstractCatalog
|
||||
from dependency_injector.catalog import override
|
||||
|
||||
from objects.providers import Object
|
||||
from objects.providers import Value
|
||||
from dependency_injector.providers import Object
|
||||
from dependency_injector.providers import Value
|
||||
|
||||
from objects.errors import Error
|
||||
from dependency_injector.errors import Error
|
||||
|
||||
|
||||
class CatalogTests(unittest.TestCase):
|
||||
|
@ -94,4 +94,3 @@ class OverrideTests(unittest.TestCase):
|
|||
|
||||
self.assertEqual(self.Catalog.obj(), 1)
|
||||
self.assertEqual(self.Catalog.another_obj(), 2)
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""Objects injections unittests."""
|
||||
"""Dependency injector injections unittests."""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
from objects.injections import Injection
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import Method
|
||||
from objects.injections import inject
|
||||
from dependency_injector.injections import Injection
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import Method
|
||||
from dependency_injector.injections import inject
|
||||
|
||||
from objects.providers import Factory
|
||||
from dependency_injector.providers import Factory
|
||||
|
||||
from objects.errors import Error
|
||||
from dependency_injector.errors import Error
|
||||
|
||||
|
||||
class InjectionTests(unittest.TestCase):
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
"""Objects providers unittests."""
|
||||
"""Dependency injector providers unittests."""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
from objects.providers import Provider
|
||||
from objects.providers import Delegate
|
||||
from objects.providers import Factory
|
||||
from objects.providers import Singleton
|
||||
from objects.providers import ExternalDependency
|
||||
from objects.providers import Class
|
||||
from objects.providers import Object
|
||||
from objects.providers import Function
|
||||
from objects.providers import Value
|
||||
from objects.providers import Callable
|
||||
from objects.providers import Config
|
||||
from dependency_injector.providers import Provider
|
||||
from dependency_injector.providers import Delegate
|
||||
from dependency_injector.providers import Factory
|
||||
from dependency_injector.providers import Singleton
|
||||
from dependency_injector.providers import ExternalDependency
|
||||
from dependency_injector.providers import Class
|
||||
from dependency_injector.providers import Object
|
||||
from dependency_injector.providers import Function
|
||||
from dependency_injector.providers import Value
|
||||
from dependency_injector.providers import Callable
|
||||
from dependency_injector.providers import Config
|
||||
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import Method
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import Method
|
||||
|
||||
from objects.utils import is_provider
|
||||
from dependency_injector.utils import is_provider
|
||||
|
||||
from objects.errors import Error
|
||||
from dependency_injector.errors import Error
|
||||
|
||||
|
||||
class ProviderTests(unittest.TestCase):
|
||||
|
@ -142,7 +142,7 @@ class DelegateTests(unittest.TestCase):
|
|||
self.assertRaises(Error, Delegate, delegated=object())
|
||||
|
||||
def test_call(self):
|
||||
""" Test returning of delegated provider."""
|
||||
"""Test returning of delegated provider."""
|
||||
delegated1 = self.delegate()
|
||||
delegated2 = self.delegate()
|
||||
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
"""Objects utils unittests."""
|
||||
"""Dependency injector utils unittests."""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
from objects.utils import is_provider
|
||||
from objects.utils import ensure_is_provider
|
||||
from objects.utils import is_injection
|
||||
from objects.utils import ensure_is_injection
|
||||
from objects.utils import is_kwarg_injection
|
||||
from objects.utils import is_attribute_injection
|
||||
from objects.utils import is_method_injection
|
||||
from dependency_injector.utils import is_provider
|
||||
from dependency_injector.utils import ensure_is_provider
|
||||
from dependency_injector.utils import is_injection
|
||||
from dependency_injector.utils import ensure_is_injection
|
||||
from dependency_injector.utils import is_kwarg_injection
|
||||
from dependency_injector.utils import is_attribute_injection
|
||||
from dependency_injector.utils import is_method_injection
|
||||
|
||||
from objects.providers import Provider
|
||||
from dependency_injector.providers import Provider
|
||||
|
||||
from objects.injections import Injection
|
||||
from objects.injections import KwArg
|
||||
from objects.injections import Attribute
|
||||
from objects.injections import Method
|
||||
from dependency_injector.injections import Injection
|
||||
from dependency_injector.injections import KwArg
|
||||
from dependency_injector.injections import Attribute
|
||||
from dependency_injector.injections import Method
|
||||
|
||||
from objects.errors import Error
|
||||
from dependency_injector.errors import Error
|
||||
|
||||
|
||||
class IsProviderTests(unittest.TestCase):
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -33,21 +33,21 @@ basepython=python2.7
|
|||
deps=
|
||||
pylint
|
||||
commands=
|
||||
- pylint -f colorized --rcfile=./.pylintrc objects
|
||||
- pylint -f colorized --rcfile=./.pylintrc dependency_injector
|
||||
|
||||
[testenv:flake8]
|
||||
basepython=python2.7
|
||||
deps=
|
||||
flake8
|
||||
commands=
|
||||
flake8 --max-complexity=8 objects/
|
||||
flake8 --max-complexity=8 dependency_injector/
|
||||
|
||||
[testenv:pep257]
|
||||
basepython=python2.7
|
||||
deps=
|
||||
pep257
|
||||
commands=
|
||||
pep257 objects/
|
||||
pep257 dependency_injector/
|
||||
|
||||
[testenv:py26]
|
||||
basepython=python2.6
|
||||
|
|
Loading…
Reference in New Issue
Block a user