<commit_before># -*- coding: utf-8 -*-
'''The app module, containing the app factory function.'''
from flask import Flask, render_template

from flask.ext.security import Security

def asset_path_context_processor():
    return {'asset_path': '/static/'}


def create_app(config_filename):
    ''' An application factory, as explained here:
        http://flask.pocoo.org/docs/patterns/appfactories/
    '''
    app = Flask(__name__)
    app.config.from_object(config_filename)
    register_errorhandlers(app)
    register_blueprints(app)
    app.context_processor(asset_path_context_processor)
    register_extensions(app)
    register_filters(app)
    return app


def register_errorhandlers(app):
    def render_error(error):
        # If a HTTPException, pull the `code` attribute; default to 500
        error_code = getattr(error, 'code', 500)
        return render_template("{0}.html".format(error_code)), error_code
    for errcode in [401, 404, 500]:
        app.errorhandler(errcode)(render_error)
    return None


def register_blueprints(app):
    from application.frontend.views import frontend
    app.register_blueprint(frontend)

    from application.hatch.views import hatch
    app.register_blueprint(hatch)


def register_extensions(app):
    from application.assets import env
    env.init_app(app)

    from application.models import db
    db.init_app(app)

    # flask security setup
    from application.extensions import user_datastore
    security = Security(app, user_datastore)

    # flask markdown
    from flaskext.markdown import Markdown
    markdown = Markdown(app)

    if 'SENTRY_DSN' in os.environ:
        from raven.contrib.flask import Sentry
        sentry = Sentry(app, dsn=os.environ['SENTRY_DSN'])


def register_filters(app):
    def format_date(d):
        try:
            return d.strftime('%-d %B %Y')
        except Exception as e:
            return ''

    app.jinja_env.filters['format_date'] = format_date

<commit_msg>missing import<commit_after># -*- coding: utf-8 -*-
'''The app module, containing the app factory function.'''
from flask import Flask, render_template

from flask.ext.security import Security

def asset_path_context_processor():
    return {'asset_path': '/static/'}


def create_app(config_filename):
    ''' An application factory, as explained here:
        http://flask.pocoo.org/docs/patterns/appfactories/
    '''
    app = Flask(__name__)
    app.config.from_object(config_filename)
    register_errorhandlers(app)
    register_blueprints(app)
    app.context_processor(asset_path_context_processor)
    register_extensions(app)
    register_filters(app)
    return app


def register_errorhandlers(app):
    def render_error(error):
        # If a HTTPException, pull the `code` attribute; default to 500
        error_code = getattr(error, 'code', 500)
        return render_template("{0}.html".format(error_code)), error_code
    for errcode in [401, 404, 500]:
        app.errorhandler(errcode)(render_error)
    return None


def register_blueprints(app):
    from application.frontend.views import frontend
    app.register_blueprint(frontend)

    from application.hatch.views import hatch
    app.register_blueprint(hatch)


def register_extensions(app):
    from application.assets import env
    env.init_app(app)

    from application.models import db
    db.init_app(app)

    # flask security setup
    from application.extensions import user_datastore
    security = Security(app, user_datastore)

    # flask markdown
    from flaskext.markdown import Markdown
    markdown = Markdown(app)

    import os
    if 'SENTRY_DSN' in os.environ:
        from raven.contrib.flask import Sentry
        sentry = Sentry(app, dsn=os.environ['SENTRY_DSN'])


def register_filters(app):
    def format_date(d):
        try:
            return d.strftime('%-d %B %Y')
        except Exception as e:
            return ''

    app.jinja_env.filters['format_date'] = format_date


{'fraction_non_alphanumeric': 0.09543044685685433, 'fraction_numerical': 0.008583690987124463, 'mean_word_length': 3.4617117117117115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4701292', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1176, 'n_words': 289}