# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/celery_ext/tasks.py
# DB_SUCCESS = "Completed SQL database transcation."
# DB_FAILURE = "An unexpected error occurred during SQL database transaction."
# def create_database(job_id):
# def modify_database(job_id):
# def database_success(job_id):
# def database_failure(job_id):
# def database_task(job_id, task):
# def clean_job(job_record):
# def get_alchemist():
# def get_job(job_id):
# def get_database(database_id):
#     def __init__(self, job_id):
#     def handle_call(self, code, *args, **kwargs):
# class CallbackObserver(object):
# 
# Path: webphamerator/app/sqlalchemy_ext/models.py
# class Database(db.Model):
# class Job(db.Model):
# class JobOrganismToDelete(db.Model):
# class GenbankFile(db.Model):
# class Password(db.Model):
#     def url(self):
#     def mysql_name_for(cls, name):
#     def phamerator_name_for(cls, name):
#     def mysql_name(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):


import tempfile
import shutil
import os
import pham.genbank
import pham.db
import flask
from pathlib import Path
from flask import (abort, Blueprint, current_app, request)
from pdm_utils import AlchemyHandler
from webphamerator.app import sqlalchemy_ext as sqlext
from webphamerator.app import filters
from webphamerator.app.celery_ext import tasks
from webphamerator.app.sqlalchemy_ext import models
                                        database_record.mysql_name())
    except pham.db.DatabaseDoesNotExistError:
        return "Database with id {database_id} not found.", 500

    phage_dictionaries = []
    for phage in phages:
        phage_dictionaries.append({
                                    'name': phage.name,
                                    'id': phage.id,
                                    'genes': phage.genes
                                  })

    return flask.jsonify(phages=phage_dictionaries), 200


@bp.route('/api/database-name-taken', methods=['GET'])
def database_name_taken():
    """

    status codes:
        200: name is available
        409: name is not available
    """
    name = request.args.get('name')
    if name is None:
        return abort(400)

    name_slug = models.Database.phamerator_name_for(name)

    count = (sqlext.db.session.query(models.Database)

# Path: webphamerator/app/filters.py
# def replaceifequal(arg, value, replace_with):
# def humandate(timestamp):
# def isodate(date):
# def toclocktime(timedelta):
# 
# Path: webphamerator/app/celery_ext/tasks.py
# DB_SUCCESS = "Completed SQL database transcation."
# DB_FAILURE = "An unexpected error occurred during SQL database transaction."
# def create_database(job_id):
# def modify_database(job_id):
# def database_success(job_id):
# def database_failure(job_id):
# def database_task(job_id, task):
# def clean_job(job_record):
# def get_alchemist():
# def get_job(job_id):
# def get_database(database_id):
#     def __init__(self, job_id):
#     def handle_call(self, code, *args, **kwargs):
# class CallbackObserver(object):
# 
# Path: webphamerator/app/sqlalchemy_ext/models.py
# class Database(db.Model):
# class Job(db.Model):
# class JobOrganismToDelete(db.Model):
# class GenbankFile(db.Model):
# class Password(db.Model):
#     def url(self):
#     def mysql_name_for(cls, name):
#     def phamerator_name_for(cls, name):
#     def mysql_name(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):
#     def __repr__(self):


# Path: webphamerator/app/api.py
import tempfile
import shutil
import os
import pham.genbank
import pham.db
import flask
from pathlib import Path
from flask import (abort, Blueprint, current_app, request)
from pdm_utils import AlchemyHandler
from webphamerator.app import sqlalchemy_ext as sqlext
from webphamerator.app import filters
from webphamerator.app.celery_ext import tasks
from webphamerator.app.sqlalchemy_ext import models

                                        database_record.mysql_name())
    except pham.db.DatabaseDoesNotExistError:
        return "Database with id {database_id} not found.", 500

    phage_dictionaries = []
    for phage in phages:
        phage_dictionaries.append({
                                    'name': phage.name,
                                    'id': phage.id,
                                    'genes': phage.genes
                                  })

    return flask.jsonify(phages=phage_dictionaries), 200


@bp.route('/api/database-name-taken', methods=['GET'])
def database_name_taken():
    """

    status codes:
        200: name is available
        409: name is not available
    """
    name = request.args.get('name')
    if name is None:
        return abort(400)

    name_slug = models.Database.phamerator_name_for(name)

    count = (sqlext.db.session.query(models.Database)

             .filter(models.Database.name_slug == name_slug)