Remove not relevant "speech" example

This commit is contained in:
Roman Mogylatov 2020-09-09 21:34:30 -04:00
parent ac8212a95b
commit 5740dd6df5
6 changed files with 4 additions and 105 deletions

View File

@ -7,6 +7,10 @@ that were made in every particular version.
From version 0.7.6 *Dependency Injector* framework strictly
follows `Semantic versioning`_
Develop
-------
- Remove not relevant "speech" example.
3.42.0
------
- Update "DI in Python" documentation page.

View File

@ -1,26 +0,0 @@
"""IoC container example."""
import collections
import dependency_injector.containers as containers
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
class Container(containers.DeclarativeContainer):
"""IoC container."""
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
if __name__ == '__main__':
car1 = Container.car_factory(serial_number=1)
car2 = Container.car_factory(serial_number=2)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine

View File

@ -1,14 +0,0 @@
"""Factory provider example."""
from dependency_injector import providers
object_factory = providers.Factory(object)
if __name__ == '__main__':
object1 = object_factory()
object2 = object_factory()
assert object1 is not object2
assert isinstance(object1, object) and isinstance(object2, object)

View File

@ -1,20 +0,0 @@
"""Factory provider keyword argument injections example."""
import collections
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
if __name__ == '__main__':
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine

View File

@ -1,24 +0,0 @@
"""Overriding of factory provider example."""
import collections
import dependency_injector.providers as providers
Engine = collections.namedtuple('Engine', [])
Car = collections.namedtuple('Car', ['serial_number', 'engine'])
engine_factory = providers.Factory(Engine)
car_factory = providers.Factory(Car, engine=engine_factory)
EngineX = collections.namedtuple('EngineX', [])
engine_factory.override(providers.Factory(EngineX))
if __name__ == '__main__':
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2, engine=Engine())
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine.__class__ is EngineX
assert car2.engine.__class__ is Engine

View File

@ -1,21 +0,0 @@
"""@inject decorator example."""
from container import Container
from dependency_injector.injections import inject
@inject(car_factory=Container.car_factory.delegate())
@inject(extra_engine=Container.engine_factory)
def main(car_factory, extra_engine):
"""Run application."""
car1 = car_factory(serial_number=1)
car2 = car_factory(serial_number=2, engine=extra_engine)
assert car1.serial_number == 1 and car2.serial_number == 2
assert car1.engine is not car2.engine
assert car2.engine is extra_engine
if __name__ == '__main__':
main()