2020-07-14 05:45:15 +03:00
|
|
|
"""Application containers module."""
|
|
|
|
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
from dependency_injector.ext import flask
|
|
|
|
from flask import Flask
|
2020-07-18 07:40:14 +03:00
|
|
|
from flask_bootstrap import Bootstrap
|
2020-07-14 05:45:15 +03:00
|
|
|
from github import Github
|
|
|
|
|
|
|
|
from . import views, services
|
|
|
|
|
|
|
|
|
|
|
|
class ApplicationContainer(containers.DeclarativeContainer):
|
|
|
|
"""Application container."""
|
|
|
|
|
|
|
|
app = flask.Application(Flask, __name__)
|
|
|
|
|
2020-07-18 07:40:14 +03:00
|
|
|
bootstrap = flask.Extension(Bootstrap)
|
|
|
|
|
2020-07-14 05:45:15 +03:00
|
|
|
config = providers.Configuration()
|
|
|
|
|
|
|
|
github_client = providers.Factory(
|
|
|
|
Github,
|
|
|
|
login_or_token=config.github.auth_token,
|
|
|
|
timeout=config.github.request_timeout,
|
|
|
|
)
|
|
|
|
|
|
|
|
search_service = providers.Factory(
|
|
|
|
services.SearchService,
|
|
|
|
github_client=github_client,
|
|
|
|
)
|
|
|
|
|
|
|
|
index_view = flask.View(
|
|
|
|
views.index,
|
|
|
|
search_service=search_service,
|
2020-07-20 23:58:18 +03:00
|
|
|
default_query=config.search.default_query,
|
|
|
|
default_limit=config.search.default_limit,
|
2020-07-14 05:45:15 +03:00
|
|
|
)
|