<commit_before>'''
Created on Aug 9, 2013

@author: david
'''
import logging.handlers
import sys

from flask import Flask

from davesite.homepage import blueprint as homeblueprint
from davesite.jlp import blueprint as jlprint

from davesite.app import menu

def create_app(name):
    app = Flask(name)
    
    try:
        app.config.from_object('davesite.app.default_config')
        app.config.from_envvar('DAVESITE_CONFIG', silent=True)
    
    
        app.register_blueprint(homeblueprint.home_page)
        app.register_blueprint(jlprint.jlp, url_prefix="/jlp")
    
        if not app.debug:
            file_handler = logging.handlers.RotatingFileHandler(app.config['ERROR_LOG_FILE'], "a", 2 * 1024 * 1024, 5)
            file_handler.setLevel(logging.WARNING)

            app.logger.addHandler(file_handler)
            
        menu_items = menu.read_menu(app.config['MENU_JSON'])
        @app.context_processor
        def menu_ctx_processor():
            
            def is_dropdown(item):
                return not isinstance(item, basestring)
            return dict(menu=menu_items,
                        is_dropdown = is_dropdown)
    except Exception:
        app.logger.exception("Error while starting app:")
        sys.exit(-1)
    
    return app<commit_msg>logging happens slightly differently now.<commit_after>'''
Created on Aug 9, 2013

@author: david
'''
import logging.handlers
import sys

from flask import Flask

from davesite.homepage import blueprint as homeblueprint
from davesite.jlp import blueprint as jlprint

from davesite.app import menu

def create_app(name):
    app = Flask(name)
    
    try:
        app.config.from_object('davesite.app.default_config')
        app.config.from_envvar('DAVESITE_CONFIG', silent=True)
    
    
        app.register_blueprint(homeblueprint.home_page)
        app.register_blueprint(jlprint.jlp, url_prefix="/jlp")
    
        if not app.debug:
            logging.basicConfig(filename = app.config['ERROR_LOG_FILE'], level = logging.WARNING,
                                format = '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]')
            
            
        menu_items = menu.read_menu(app.config['MENU_JSON'])
        @app.context_processor
        def menu_ctx_processor():
            
            def is_dropdown(item):
                return not isinstance(item, basestring)
            return dict(menu=menu_items,
                        is_dropdown = is_dropdown)
    except Exception:
        app.logger.exception("Error while starting app:")
        sys.exit(-1)
    
    return app
{'fraction_non_alphanumeric': 0.09324635456638526, 'fraction_numerical': 0.00844205679201842, 'mean_word_length': 2.4347826086956523, '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': '3192258', 'n_tokens_mistral': 803, 'n_tokens_neox': 768, 'n_words': 162}