mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-06-15 11:03:26 +03:00
Update movie listers example
This commit is contained in:
parent
ece858aaf3
commit
7878466f4c
|
@ -1,4 +1,4 @@
|
||||||
"""Small script for initializing movies data."""
|
"""Script for initializing movie databases."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""A naive example of dependency injection in Python.
|
"""A naive example of dependency injection on Python.
|
||||||
|
|
||||||
Example implementation of dependency injection in Python from Martin Fowler's
|
Example implementation of dependency injection in Python from Martin Fowler's
|
||||||
article about dependency injection and inversion of control:
|
article about dependency injection and inversion of control:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""A naive example of dependency injection in Python.
|
"""A naive example of dependency injection on Python.
|
||||||
|
|
||||||
Example implementation of dependency injection in Python from Martin Fowler's
|
Example implementation of dependency injection in Python from Martin Fowler's
|
||||||
article about dependency injection and inversion of control:
|
article about dependency injection and inversion of control:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""A naive example of dependency injection in Python.
|
"""A naive example of dependency injection on Python.
|
||||||
|
|
||||||
Example implementation of dependency injection in Python from Martin Fowler's
|
Example implementation of dependency injection in Python from Martin Fowler's
|
||||||
article about dependency injection and inversion of control:
|
article about dependency injection and inversion of control:
|
||||||
|
@ -6,7 +6,7 @@ article about dependency injection and inversion of control:
|
||||||
http://www.martinfowler.com/articles/injection.html
|
http://www.martinfowler.com/articles/injection.html
|
||||||
|
|
||||||
This mini application uses ``movies`` library, that is configured to work with
|
This mini application uses ``movies`` library, that is configured to work with
|
||||||
csv file movies database.
|
sqlite movies database and csv file movies database.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
@ -55,21 +55,17 @@ def main(db_movie_lister, csv_movie_lister):
|
||||||
This program prints info about all movies that were directed by different
|
This program prints info about all movies that were directed by different
|
||||||
persons and then prints all movies that were released in 2015.
|
persons and then prints all movies that were released in 2015.
|
||||||
|
|
||||||
:param db_movie_lister: Database movie lister instance
|
:param db_movie_lister: Movie lister, configured to work with database
|
||||||
:type db_movie_lister: movies.listers.MovieLister
|
:type db_movie_lister: movies.listers.MovieLister
|
||||||
|
|
||||||
:param csv_movie_lister: Database movie lister instance
|
:param csv_movie_lister: Movie lister, configured to work with csv file
|
||||||
:type csv_movie_lister: movies.listers.MovieLister
|
:type csv_movie_lister: movies.listers.MovieLister
|
||||||
"""
|
"""
|
||||||
print db_movie_lister.movies_directed_by('Francis Lawrence')
|
for movie_lister in (db_movie_lister, csv_movie_lister):
|
||||||
print db_movie_lister.movies_directed_by('Patricia Riggen')
|
print movie_lister.movies_directed_by('Francis Lawrence')
|
||||||
print db_movie_lister.movies_directed_by('JJ Abrams')
|
print movie_lister.movies_directed_by('Patricia Riggen')
|
||||||
print db_movie_lister.movies_released_in(2015)
|
print movie_lister.movies_directed_by('JJ Abrams')
|
||||||
|
print movie_lister.movies_released_in(2015)
|
||||||
print csv_movie_lister.movies_directed_by('Francis Lawrence')
|
|
||||||
print csv_movie_lister.movies_directed_by('Patricia Riggen')
|
|
||||||
print csv_movie_lister.movies_directed_by('JJ Abrams')
|
|
||||||
print csv_movie_lister.movies_released_in(2015)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
|
@ -17,7 +17,7 @@ class MovieFinder(object):
|
||||||
"""Initializer.
|
"""Initializer.
|
||||||
|
|
||||||
:param movie_model: Movie model's factory
|
:param movie_model: Movie model's factory
|
||||||
:type movie_model: (object) -> movies.models.Movie
|
:type movie_model: movies.models.Movie
|
||||||
"""
|
"""
|
||||||
self._movie_model = movie_model
|
self._movie_model = movie_model
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class CsvMovieFinder(MovieFinder):
|
||||||
"""Initializer.
|
"""Initializer.
|
||||||
|
|
||||||
:param movie_model: Movie model's factory
|
:param movie_model: Movie model's factory
|
||||||
:type movie_model: (object) -> movies.models.Movie
|
:type movie_model: movies.models.Movie
|
||||||
|
|
||||||
:param csv_file: Path to csv file with movies data
|
:param csv_file: Path to csv file with movies data
|
||||||
:type csv_file: str
|
:type csv_file: str
|
||||||
|
|
Loading…
Reference in New Issue
Block a user