diff --git a/.gitignore b/.gitignore index f04b99cb..43967294 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,7 @@ src/dependency_injector/providers/*.so /examples/miniapps/movie-lister/wslenv2/bin /examples/miniapps/movie-lister/wslenv2/share/python-wheels /examples/miniapps/movie-lister/wslenv2 +/examples/miniapps/movie-lister/setup_venv.bat +/examples/miniapps/movie-lister/setup_venv.sh +/examples/miniapps/movie-lister/run_movie_lister.bat +/examples/miniapps/movie-lister/run_movie_lister.sh diff --git a/examples/miniapps/movie-lister/data/fixtures.py b/examples/miniapps/movie-lister/data/fixtures.py index 2870d04d..f3b82924 100644 --- a/examples/miniapps/movie-lister/data/fixtures.py +++ b/examples/miniapps/movie-lister/data/fixtures.py @@ -18,10 +18,9 @@ SQLITE_FILE = DIR / 'movies.db' def create_csv(movies_data, path): - with open(path, 'w') as opened_file: + with open(path, 'w', newline='') as opened_file: writer = csv.writer(opened_file) - for row in movies_data: - writer.writerow(row) + writer.writerows(movies_data) def create_sqlite(movies_data, path): diff --git a/examples/miniapps/movie-lister/movies/__main__.py b/examples/miniapps/movie-lister/movies/__main__.py index 975618f3..561a6ac5 100644 --- a/examples/miniapps/movie-lister/movies/__main__.py +++ b/examples/miniapps/movie-lister/movies/__main__.py @@ -4,8 +4,8 @@ import sys from dependency_injector.wiring import inject, Provide -from .listers import MovieLister -from .containers import Container +from movies.listers import MovieLister +from movies.containers import Container @inject diff --git a/examples/miniapps/movie-lister/movies/containers.py b/examples/miniapps/movie-lister/movies/containers.py index 9d30fbfb..4425c6a7 100644 --- a/examples/miniapps/movie-lister/movies/containers.py +++ b/examples/miniapps/movie-lister/movies/containers.py @@ -2,7 +2,7 @@ from dependency_injector import containers, providers -from . import finders, listers, entities +from movies import finders, listers, entities class Container(containers.DeclarativeContainer): diff --git a/examples/miniapps/movie-lister/movies/finders.py b/examples/miniapps/movie-lister/movies/finders.py index 3485d8c3..85601b73 100644 --- a/examples/miniapps/movie-lister/movies/finders.py +++ b/examples/miniapps/movie-lister/movies/finders.py @@ -4,7 +4,7 @@ import csv import sqlite3 from typing import Callable, List -from .entities import Movie +from movies.entities import Movie class MovieFinder: diff --git a/examples/miniapps/movie-lister/movies/listers.py b/examples/miniapps/movie-lister/movies/listers.py index 36d254c2..4da5b40b 100644 --- a/examples/miniapps/movie-lister/movies/listers.py +++ b/examples/miniapps/movie-lister/movies/listers.py @@ -1,6 +1,6 @@ """Movie listers module.""" -from .finders import MovieFinder +from movies.finders import MovieFinder class MovieLister: diff --git a/examples/miniapps/movie-lister/movies/tests.py b/examples/miniapps/movie-lister/movies/tests.py index eea04c81..af91a871 100644 --- a/examples/miniapps/movie-lister/movies/tests.py +++ b/examples/miniapps/movie-lister/movies/tests.py @@ -4,7 +4,7 @@ from unittest import mock import pytest -from .containers import Container +from movies.containers import Container @pytest.fixture diff --git a/examples/miniapps/movie-lister/run_movie_lister.bat b/examples/miniapps/movie-lister/run_movie_lister.bat deleted file mode 100644 index 6d64f1b0..00000000 --- a/examples/miniapps/movie-lister/run_movie_lister.bat +++ /dev/null @@ -1,12 +0,0 @@ -echo on -set PYTHON37=%UserProfile%\AppData\Local\Programs\Python\Python37\python.exe - -REM set variabless -set ENV_NAME=wslenv2-win -set VENV_DIR=%ENV_NAME%\Scripts -set PYTHON_VENV=%VENV_DIR%\python.exe - -Start /WAIT cmd /k "%VENV_DIR%\activate & cd & %PYTHON_VENV% data/fixtures.py & set MOVIE_FINDER_TYPE=sqlite & %PYTHON_VENV% -m movies & %VENV_DIR%\deactivate & pause & exit 0" - -REM MOVIE_FINDER_TYPE=csv -REM MOVIE_FINDER_TYPE=sqlite diff --git a/examples/miniapps/movie-lister/setup_venvt.bat b/examples/miniapps/movie-lister/setup_and_run_movie_lister.bat similarity index 69% rename from examples/miniapps/movie-lister/setup_venvt.bat rename to examples/miniapps/movie-lister/setup_and_run_movie_lister.bat index 4e45389a..6c6b942b 100644 --- a/examples/miniapps/movie-lister/setup_venvt.bat +++ b/examples/miniapps/movie-lister/setup_and_run_movie_lister.bat @@ -6,12 +6,6 @@ set ENV_NAME=wslenv2-win set VENV_DIR=%ENV_NAME%\Scripts set PYTHON_VENV=%VENV_DIR%\python.exe -REM cleanup -rd /s /q %ENV_NAME% - %PYTHON37% -m venv %ENV_NAME% -Start /WAIT cmd /k "%VENV_DIR%\activate & %PYTHON_VENV% -m pip install --upgrade pip & %PYTHON_VENV% -m pip install -r .\requirements.txt & %VENV_DIR%\deactivate & pause & exit 0" - -REM MOVIE_FINDER_TYPE=csv -REM MOVIE_FINDER_TYPE=sqlite +Start /WAIT cmd /k "%VENV_DIR%\activate & %PYTHON_VENV% -m pip install --upgrade pip & %PYTHON_VENV% -m pip install -r .\requirements.txt & set MOVIE_FINDER_TYPE=csv& %PYTHON_VENV% -m movies & set MOVIE_FINDER_TYPE=sqlite& %PYTHON_VENV% -m movies&%VENV_DIR%\deactivate & pause & exit 0" diff --git a/examples/miniapps/movie-lister/run_movie_lister.sh b/examples/miniapps/movie-lister/setup_and_run_movie_lister.sh similarity index 93% rename from examples/miniapps/movie-lister/run_movie_lister.sh rename to examples/miniapps/movie-lister/setup_and_run_movie_lister.sh index f7b2e661..9b34ac6f 100644 --- a/examples/miniapps/movie-lister/run_movie_lister.sh +++ b/examples/miniapps/movie-lister/setup_and_run_movie_lister.sh @@ -4,9 +4,11 @@ rm -rf wslenv2 python3 -m venv wslenv2 . wslenv2/bin/activate - pip install -r requirements.txt + wslenv2/bin/python data/fixtures.py MOVIE_FINDER_TYPE=csv wslenv2/bin/python -m movies MOVIE_FINDER_TYPE=sqlite wslenv2/bin/python -m movies + +source deactivate