# Path: src/main.py
# def on_shutdown():
# 
# Path: src/logcfg.py
# DEBUG_TEMPL = '  %(levelname)-7.7s %(funcName)s: %(message)s'
# PROD_TEMPL  = '%(asctime)s %(levelname)-7.7s %(funcName)s: %(message)s'
# DEBUG = logging.DEBUG
# class ColorFmtr(Formatter):
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def makefunc(level):
#         def tb_func(msg, *args, **kwargs):
#     def thefunc(msg, *args, **kwargs):


from flask_security import UserMixin, RoleMixin
from flask_security.utils import encrypt_password, verify_password
from sqlalchemy import (
    Boolean,
    Column,
    DateTime,
    ForeignKey,
    Integer,
    String,
    Table,
    Text,
)
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy_utils import IPAddressType, TimezoneType
from . import config
from .main import app, db
from .logcfg import log
    from datetime import datetime as dt
    from sqlalchemy.exc import IntegrityError, InvalidRequestError
    import inspect
                roles = [roles]
            self.roles = roles

        if type(org) is str:
            orgobj = Orgs.query.filter_by(name=org).first()
            if orgobj:
                org = orgobj
            else:
                org = Orgs(name=org)
                db.session.add(org)
                db.session.commit()
        self.org = org

    def set_password(self, password):
        try:
            self.password = encrypt_password(password)
        except RuntimeError:  # :-/
            with app.app_context():
                self.password = encrypt_password(password)

    def check_password(self, password):
        return verify_password(password, self.password)

    def __repr__(self):
        return '<%s %r>' % (self.__class__.__name__, self.email)


def initdb_impl(**kwargs):
    ''' Make sure database is ready, and there's an admin user. '''


# Path: src/main.py
# def on_shutdown():
# 
# Path: src/logcfg.py
# DEBUG_TEMPL = '  %(levelname)-7.7s %(funcName)s: %(message)s'
# PROD_TEMPL  = '%(asctime)s %(levelname)-7.7s %(funcName)s: %(message)s'
# DEBUG = logging.DEBUG
# class ColorFmtr(Formatter):
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def makefunc(level):
#         def tb_func(msg, *args, **kwargs):
#     def thefunc(msg, *args, **kwargs):


# Path: src/models.py
from flask_security import UserMixin, RoleMixin
from flask_security.utils import encrypt_password, verify_password
from sqlalchemy import (
    Boolean,
    Column,
    DateTime,
    ForeignKey,
    Integer,
    String,
    Table,
    Text,
)
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy_utils import IPAddressType, TimezoneType
from . import config
from .main import app, db
from .logcfg import log
    from datetime import datetime as dt
    from sqlalchemy.exc import IntegrityError, InvalidRequestError
    import inspect

                roles = [roles]
            self.roles = roles

        if type(org) is str:
            orgobj = Orgs.query.filter_by(name=org).first()
            if orgobj:
                org = orgobj
            else:
                org = Orgs(name=org)
                db.session.add(org)
                db.session.commit()
        self.org = org

    def set_password(self, password):
        try:
            self.password = encrypt_password(password)
        except RuntimeError:  # :-/
            with app.app_context():
                self.password = encrypt_password(password)

    def check_password(self, password):
        return verify_password(password, self.password)

    def __repr__(self):
        return '<%s %r>' % (self.__class__.__name__, self.email)


def initdb_impl(**kwargs):
    ''' Make sure database is ready, and there's an admin user. '''


    log.debug('creating tables')