# Path: cliche/celery.py
# class Loader(BaseLoader):
#     def read_configuration(self):
# def get_database_engine() -> Engine:
# def get_session() -> Session:
# def close_session(task_id, task, *args, **kwargs):
# def get_raven_client() -> Client:
# def setup_raven_logging(conf=None, **kwargs):
# def report_task_failure(task_id, exception, args, kwargs,
#                         traceback, einfo, sender):
# 
# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME
# 
# Path: cliche/web/app.py
# def setup_sentry():
# def get_sentry() -> Sentry:
# def index():
# def check_login_status():
# def template_processor():
# def add_login_header(response):


import os
import contextlib
from sqlalchemy import create_engine
from sqlalchemy.pool import NullPool, StaticPool
from cliche.celery import app as celery_app
from cliche.orm import Base, Session
from cliche.web.app import app as flask_app



__all__ = ('DEFAULT_DATABASE_URL', 'get_database_url', 'get_engine',
           'get_session')


DEFAULT_DATABASE_URL = 'sqlite://'


def get_database_url(url=None):
    return url or os.environ.get(
        'CLICHE_TEST_DATABASE_URL',
        DEFAULT_DATABASE_URL
    )


def get_engine(url=None, echo=False):
    url = get_database_url(url)

# Path: cliche/celery.py
# class Loader(BaseLoader):
#     def read_configuration(self):
# def get_database_engine() -> Engine:
# def get_session() -> Session:
# def close_session(task_id, task, *args, **kwargs):
# def get_raven_client() -> Client:
# def setup_raven_logging(conf=None, **kwargs):
# def report_task_failure(task_id, exception, args, kwargs,
#                         traceback, einfo, sender):
# 
# Path: cliche/orm.py
# def make_repr(self):
# def get_alembic_config(engine):
# def initialize_database(engine):
# def get_database_revision(engine):
#     def get_revision(rev, context):
# def upgrade_database(engine, revision='head'):
#     def upgrade(rev, context):
#         def update_current_rev(old, new):
# def downgrade_database(engine, revision):
# def import_all_modules(dry_run=False):  # FIXME
# 
# Path: cliche/web/app.py
# def setup_sentry():
# def get_sentry() -> Sentry:
# def index():
# def check_login_status():
# def template_processor():
# def add_login_header(response):


# Path: tests/db.py
import os
import contextlib
from sqlalchemy import create_engine
from sqlalchemy.pool import NullPool, StaticPool
from cliche.celery import app as celery_app
from cliche.orm import Base, Session
from cliche.web.app import app as flask_app




__all__ = ('DEFAULT_DATABASE_URL', 'get_database_url', 'get_engine',
           'get_session')


DEFAULT_DATABASE_URL = 'sqlite://'


def get_database_url(url=None):
    return url or os.environ.get(
        'CLICHE_TEST_DATABASE_URL',
        DEFAULT_DATABASE_URL
    )


def get_engine(url=None, echo=False):
    url = get_database_url(url)

    flask_app.config['DATABASE_URL'] = url