mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-10 16:12:26 +03:00
Fix code indentation issue
This commit is contained in:
parent
c495854f9f
commit
9ff771e28e
|
@ -29,17 +29,18 @@ We will build a CLI application that helps to search for the movies. Let's call
|
||||||
|
|
||||||
How does Movie Lister work?
|
How does Movie Lister work?
|
||||||
|
|
||||||
- Application uses a movies database to search for the movies
|
- There is a movies database
|
||||||
- Application can search the movies by:
|
|
||||||
- Director's name
|
|
||||||
- Year of the release
|
|
||||||
- Each movie has next fields:
|
- Each movie has next fields:
|
||||||
- Title
|
- Title
|
||||||
- Year of the release
|
- Year of the release
|
||||||
- Director's name
|
- Director's name
|
||||||
- The database can be in the next formats:
|
- The database is distributed in two formats:
|
||||||
- Csv
|
- Csv
|
||||||
- Sqlite
|
- Sqlite
|
||||||
|
- Application uses the movies database to search for the movies
|
||||||
|
- Application can search for the movies by:
|
||||||
|
- Director's name
|
||||||
|
- Year of the release
|
||||||
- Other database formats can be added later
|
- Other database formats can be added later
|
||||||
|
|
||||||
Movie Lister is a naive example from Martin Fowler's article about the dependency injection and
|
Movie Lister is a naive example from Martin Fowler's article about the dependency injection and
|
||||||
|
@ -51,7 +52,7 @@ Here is a class diagram of the Movie Lister application:
|
||||||
|
|
||||||
.. image:: cli-images/classes_01.png
|
.. image:: cli-images/classes_01.png
|
||||||
|
|
||||||
The responsibilities are split that way:
|
The responsibilities are split next way:
|
||||||
|
|
||||||
- ``MovieLister`` - is responsible for the search
|
- ``MovieLister`` - is responsible for the search
|
||||||
- ``MovieFinder`` - is responsible for the fetching from the database
|
- ``MovieFinder`` - is responsible for the fetching from the database
|
||||||
|
@ -677,10 +678,10 @@ Edit ``finders.py``:
|
||||||
self._database = sqlite3.connect(path)
|
self._database = sqlite3.connect(path)
|
||||||
super().__init__(movie_factory)
|
super().__init__(movie_factory)
|
||||||
|
|
||||||
def find_all(self) -> List[Movie]:
|
def find_all(self) -> List[Movie]:
|
||||||
with self._database as db:
|
with self._database as db:
|
||||||
rows = db.execute('SELECT title, year, director FROM movies')
|
rows = db.execute('SELECT title, year, director FROM movies')
|
||||||
return [self._movie_factory(*row) for row in rows]
|
return [self._movie_factory(*row) for row in rows]
|
||||||
|
|
||||||
Now we need to add the sqlite finder to the container and update lister's dependency to use it.
|
Now we need to add the sqlite finder to the container and update lister's dependency to use it.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user