# Path: drift/core/extensions/tenancy.py
# def drift_init_extension(app, **kwargs):
# def get_tenant_name(request_headers=None):
# def _flask_get_tenant_name():
# def _get_tenant_from_hostname(*args, **kw):
# def split_host(host):
# def _is_valid_ipv4_address(address):


import os
import os.path
import logging
import uuid
import json
import six
import textwrap
import flask_smorest
from functools import wraps
from socket import gethostname
    from pygments import highlight, util
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters import get_formatter_by_name, get_all_formatters
    from pygments.styles import get_style_by_name, get_all_styles
from flask import g, make_response, jsonify, request, current_app, url_for
from click import echo
from flask_marshmallow.fields import AbsoluteURLFor
from driftconfig.util import get_drift_config
from drift.core.extensions.tenancy import tenant_from_hostname
    from drift.flaskfactory import load_flask_config
    got_pygments = True
except ImportError:
    got_pygments = False




log = logging.getLogger(__name__)

host_name = gethostname()


def get_app_root():
    """Returns absolute path to the current application root directory."""
    return os.path.expanduser(os.environ.get('DRIFT_APP_ROOT', os.path.abspath('.')))


def get_config(ts=None, tier_name=None, tenant_name=None):
    """Wraps get_drift_config() by providing default values for tier, tenant and drift_app."""
    # Hack: Must delay import this
    # TODO: Stop using this function. Who is doing it anyways?
    if current_app:
        app_ts = current_app.extensions['driftconfig'].table_store
        if ts is not app_ts:
            log.warning("Mismatching table_store objects in get_config(): ts=%s, app ts=%s", ts, app_ts)
        ts = app_ts

    conf = get_drift_config(
        ts=ts,
        tier_name=tier_name or get_tier_name(),

# Path: drift/core/extensions/tenancy.py
# def drift_init_extension(app, **kwargs):
# def get_tenant_name(request_headers=None):
# def _flask_get_tenant_name():
# def _get_tenant_from_hostname(*args, **kw):
# def split_host(host):
# def _is_valid_ipv4_address(address):


# Path: drift/utils.py
import os
import os.path
import logging
import uuid
import json
import six
import textwrap
import flask_smorest
from functools import wraps
from socket import gethostname
    from pygments import highlight, util
    from pygments.lexers import get_lexer_by_name
    from pygments.formatters import get_formatter_by_name, get_all_formatters
    from pygments.styles import get_style_by_name, get_all_styles
from flask import g, make_response, jsonify, request, current_app, url_for
from click import echo
from flask_marshmallow.fields import AbsoluteURLFor
from driftconfig.util import get_drift_config
from drift.core.extensions.tenancy import tenant_from_hostname
    from drift.flaskfactory import load_flask_config

    got_pygments = True
except ImportError:
    got_pygments = False




log = logging.getLogger(__name__)

host_name = gethostname()


def get_app_root():
    """Returns absolute path to the current application root directory."""
    return os.path.expanduser(os.environ.get('DRIFT_APP_ROOT', os.path.abspath('.')))


def get_config(ts=None, tier_name=None, tenant_name=None):
    """Wraps get_drift_config() by providing default values for tier, tenant and drift_app."""
    # Hack: Must delay import this
    # TODO: Stop using this function. Who is doing it anyways?
    if current_app:
        app_ts = current_app.extensions['driftconfig'].table_store
        if ts is not app_ts:
            log.warning("Mismatching table_store objects in get_config(): ts=%s, app ts=%s", ts, app_ts)
        ts = app_ts

    conf = get_drift_config(
        ts=ts,
        tier_name=tier_name or get_tier_name(),

        tenant_name=tenant_name or tenant_from_hostname,