<commit_before>import functools

from flask import Flask, render_template, request, Response, make_response
import requests

from open511.converter import json_doc_to_xml, xml_to_json, FORMATS, FORMATS_LIST, open511_convert
from open511.validator import validate, Open511ValidationError
from open511.utils.serialization import deserialize, serialize

app = Flask(__name__)
 
def no_cache(f):<commit_msg>Add email error logging<commit_after>import functools
import logging
import os

from flask import Flask, render_template, request, Response, make_response
import requests

from open511.converter import json_doc_to_xml, xml_to_json, FORMATS, FORMATS_LIST, open511_convert
from open511.validator import validate, Open511ValidationError
from open511.utils.serialization import deserialize, serialize

app = Flask(__name__)

if os.environ.get('OPEN511_EMAIL_ERRORS'):
    from logging.handlers import SMTPHandler
    if os.environ.get('MANDRILL_USERNAME'):
        # Automatically support Mandrill config
        mailhost = 'smtp.mandrillapp.com'
        mailport = '587'
        username = os.environ.get('MANDRILL_USERNAME')
        password = <PASSWORD>('MANDRILL_APIKEY')
    else:
        mailhost = os.environ.get('SMTP_SERVER')
        mailport = os.environ.get('SMTP_SERVER_PORT', 25)
        username = os.environ.get('SMTP_USERNAME')
        password = <PASSWORD>('SMTP_PASSWORD')
    mail_config = dict(
        mailhost=(mailhost,mailport),
        fromaddr=os.environ.get('OPEN511_EMAIL_ERRORS_FROM', '<EMAIL>'),
        toaddrs=[os.environ['OPEN511_EMAIL_ERRORS']],
        subject='Open511 Validator server error'
    )
    if username and password:
        mail_config['credentials'] = (username, password)
    mail_handler = SMTPHandler(**mail_config)
    mail_handler.setLevel(logging.ERROR)
    app.logger.addHandler(mail_handler)
 
def no_cache(f):
{'fraction_non_alphanumeric': 0.09051955008034279, 'fraction_numerical': 0.025174076057846814, 'mean_word_length': 4.677811550151976, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6585313', 'n_tokens_mistral': 607, 'n_tokens_neox': 579, 'n_words': 125}