# 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
    def __init__(self, name='', email='', desc='', password=None,
                 active=True, admin=False, org=None, roles=None, timezone=None):
        self.active = active
        self.admin = admin
        self.desc = desc
        self.email = email
        self.name = name
        self.timezone = timezone

        if password:
            self.set_password(password)
        if roles is not None:
            if type(roles) is not list:
                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:  # :-/

# 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

    def __init__(self, name='', email='', desc='', password=None,
                 active=True, admin=False, org=None, roles=None, timezone=None):
        self.active = active
        self.admin = admin
        self.desc = desc
        self.email = email
        self.name = name
        self.timezone = timezone

        if password:
            self.set_password(password)
        if roles is not None:
            if type(roles) is not list:
                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():