<commit_before>"""Routes and create the wsgi app"""
from logging import getLogger
from libcloud.compute.types import Provider

from pyramid.config import Configurator

from mist.io.resources import Root

log = getLogger('mist.core')


def main(global_config, **settings):
    """This function returns a Pyramid WSGI application"""
    if not settings.keys():
        settings = global_config

    # import settings from settings.py
    try:
        user_config = {}
        execfile(global_config['here'] + '/settings.py',
                {'Provider':Provider},
                user_config)

        settings['keypairs'] = user_config['KEYPAIRS']
        settings['backends'] = user_config['BACKENDS']
        settings['monitoring_url'] = user_config.get('MONITORING_URL',
                                                     'https://mist.io')
        settings['js_build'] = user_config.get('JS_BUILD', False)
        settings['js_log_level'] = user_config.get('JS_LOG_LEVEL', 3)
    except:
        log.warn('Local settings.py not available or missing settings')

    config = Configurator(root_factory=Root, settings=settings)

    config.add_static_view('static', 'mist.io:static')

    config.add_route('home', '/')
    config.add_route('backends', '/backends')

    config.add_route('machines', '/backends/{backend}/machines')
    config.add_route('machine', '/backends/{backend}/machines/{machine}')
    config.add_route('machine_metadata',
                     '/backends/{backend}/machines/{machine}/metadata')
    config.add_route('machine_shell',
                     '/backends/{backend}/machines/{machine}/shell')

    config.add_route('images', '/backends/{backend}/images')
    config.add_route('image_metadata',
                     '/backends/{backend}/images/{image}/metadata')
<commit_msg>Improve how settings get populated.<commit_after>"""Routes and create the wsgi app"""
from logging import getLogger
from libcloud.compute.types import Provider

from pyramid.config import Configurator

from mist.io.resources import Root

log = getLogger('mist.core')


def main(global_config, **settings):
    """This function returns a Pyramid WSGI application"""
    if not settings.keys():
        settings = global_config

    # import settings from settings.py
    try:
        user_config = {}
        execfile(global_config['here'] + '/settings.py',
                {'Provider':Provider},
                user_config)
        settings['keypairs'] = user_config['KEYPAIRS']
        settings['backends'] = user_config['BACKENDS']
    except:
        log.error('Local settings.py not available or missing values.')
        raise TypeError

    settings['monitoring_url'] = user_config.get('MONITORING_URL',
                                                 'https://mist.io')
    settings['js_build'] = user_config.get('JS_BUILD', False)
    settings['js_log_level'] = user_config.get('JS_LOG_LEVEL', 3)

    config = Configurator(root_factory=Root, settings=settings)

    config.add_static_view('static', 'mist.io:static')

    config.add_route('home', '/')
    config.add_route('backends', '/backends')

    config.add_route('machines', '/backends/{backend}/machines')
    config.add_route('machine', '/backends/{backend}/machines/{machine}')
    config.add_route('machine_metadata',
                     '/backends/{backend}/machines/{machine}/metadata')
    config.add_route('machine_shell',
                     '/backends/{backend}/machines/{machine}/shell')

    config.add_route('images', '/backends/{backend}/images')
    config.add_route('image_metadata',
                     '/backends/{backend}/images/{image}/metadata')

{'fraction_non_alphanumeric': 0.1387822270981898, 'fraction_numerical': 0.0005485463521667581, 'mean_word_length': 3.0477247502774696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7023240', 'n_tokens_mistral': 1052, 'n_tokens_neox': 993, 'n_words': 186}