# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/auth.py
# AUTHENTICATION_NOT_NEEDED = ['/signin', '/db', '/static']
# def require_authentication():
# def is_authenticated():
# def is_password_required():
# def set_password(password):
# def delete_password():
# def sign_out():
# def authenticate(password):
# def is_password_valid(password):
# def digest(password, salt):
# def template_context():
# def show_sign_out_button():
# 
# Path: webphamerator/app/views.py
# def get_navbar(active_url, ignore_done=False):
#     def __init__(self, title, url,
#                  active=False,
#                  info=None,
#                  success=None,
#                  error=None,
#                  right_side=False):
# def databases():
#     def __init__(self, name=None, id=None, genes=None, url=None):
#     def to_dict(self):
# def database(db_id):
# def delete_database(db_id):
# def edit_database(db_id):
# def download_genbank_file(db_id, phage_id):
# def jobs():
# def jobs_page(page):
# def cancel_all_jobs():
# def job(job_id):
# def delete_job(job_id):
# def create_database():
# def import_database():
# def signin_page():
# def sign_in():
# def sign_out():
# def settings():
# def update_settings():
# def download_database(path):
# def database_root():
# class NavbarItem(object):
# class PhageViewModel(object):
# 
# Path: webphamerator/app/api.py
# def new_database():
# def import_sql_dump():
# def modify_database(database_id):
# def _prepare_genbank_files(alchemist, file_ids, phages_from_other_databases):
# def list_databases():
# def list_phages(database_id):
# def database_name_taken():
# def delete_genbank_file(file_id):
# def new_genbank_file():
# def upload_file():
# def job_status(job_id):
# def mark_job_as_seen(job_id):
# 
# Path: webphamerator/app/celery_ext/celery_utils.py
# def init_celery(celery, app):
#         def __call__(self, *args, **kwargs):
#     class ContextTask(TaskBase):


import os
        import logging
from flask import (Flask)
from webphamerator.app import (
                    filters, auth, views, api, sqlalchemy_ext)
from webphamerator.app.celery_ext import celery_utils
        from logging.handlers import RotatingFileHandler


PKG_NAME = "PhamDB"


def create_app(app_name=PKG_NAME, **kwargs):
    app = Flask(app_name)

    app.config.from_object("webphamerator.config")

    if not os.path.exists(app.config['GENBANK_FILE_DIR']):
        os.makedirs(app.config['GENBANK_FILE_DIR'])
    if not os.path.exists(app.config['DATABASE_DUMP_DIR']):
        os.makedirs(app.config['DATABASE_DUMP_DIR'])

    celery = kwargs.get("celery")
    if celery is not None:
        with app.app_context():
            celery_utils.init_celery(celery, app)

    with app.app_context():
        sqlalchemy_ext.db.init_app(app)

        app.jinja_env.filters["replaceifequal"] = filters.replaceifequal

# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/auth.py
# AUTHENTICATION_NOT_NEEDED = ['/signin', '/db', '/static']
# def require_authentication():
# def is_authenticated():
# def is_password_required():
# def set_password(password):
# def delete_password():
# def sign_out():
# def authenticate(password):
# def is_password_valid(password):
# def digest(password, salt):
# def template_context():
# def show_sign_out_button():
# 
# Path: webphamerator/app/views.py
# def get_navbar(active_url, ignore_done=False):
#     def __init__(self, title, url,
#                  active=False,
#                  info=None,
#                  success=None,
#                  error=None,
#                  right_side=False):
# def databases():
#     def __init__(self, name=None, id=None, genes=None, url=None):
#     def to_dict(self):
# def database(db_id):
# def delete_database(db_id):
# def edit_database(db_id):
# def download_genbank_file(db_id, phage_id):
# def jobs():
# def jobs_page(page):
# def cancel_all_jobs():
# def job(job_id):
# def delete_job(job_id):
# def create_database():
# def import_database():
# def signin_page():
# def sign_in():
# def sign_out():
# def settings():
# def update_settings():
# def download_database(path):
# def database_root():
# class NavbarItem(object):
# class PhageViewModel(object):
# 
# Path: webphamerator/app/api.py
# def new_database():
# def import_sql_dump():
# def modify_database(database_id):
# def _prepare_genbank_files(alchemist, file_ids, phages_from_other_databases):
# def list_databases():
# def list_phages(database_id):
# def database_name_taken():
# def delete_genbank_file(file_id):
# def new_genbank_file():
# def upload_file():
# def job_status(job_id):
# def mark_job_as_seen(job_id):
# 
# Path: webphamerator/app/celery_ext/celery_utils.py
# def init_celery(celery, app):
#         def __call__(self, *args, **kwargs):
#     class ContextTask(TaskBase):


# Path: webphamerator/app/flask_app.py
import os
        import logging
from flask import (Flask)
from webphamerator.app import (
                    filters, auth, views, api, sqlalchemy_ext)
from webphamerator.app.celery_ext import celery_utils
        from logging.handlers import RotatingFileHandler



PKG_NAME = "PhamDB"


def create_app(app_name=PKG_NAME, **kwargs):
    app = Flask(app_name)

    app.config.from_object("webphamerator.config")

    if not os.path.exists(app.config['GENBANK_FILE_DIR']):
        os.makedirs(app.config['GENBANK_FILE_DIR'])
    if not os.path.exists(app.config['DATABASE_DUMP_DIR']):
        os.makedirs(app.config['DATABASE_DUMP_DIR'])

    celery = kwargs.get("celery")
    if celery is not None:
        with app.app_context():
            celery_utils.init_celery(celery, app)

    with app.app_context():
        sqlalchemy_ext.db.init_app(app)

        app.jinja_env.filters["replaceifequal"] = filters.replaceifequal

        app.jinja_env.filters["humandate"] = filters.humandate