<commit_before>import logging
import os
import argparse
import yaml
import pymysql
from pymysql.cursors import DictCursorMixin, Cursor
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from collections import OrderedDict
from inflection import titleize
import locale

class OrderedDictCursor(DictCursorMixin, Cursor):
    dict_type = OrderedDict

def read_file_to_string(path):
    with open(path, 'r') as f:
        return f.read()

def mysql_query(sql, secrets):
    con = pymysql.connect(
        host=secrets['db-hostname'],
        port=secrets['db-port'],
        user=secrets['db-username'],
        password=secrets['<PASSWORD>'],
        charset='utf8mb4',
        db=secrets['db-schema'],
        cursorclass=pymysql.cursors.DictCursor
        )

    with con.cursor(OrderedDictCursor) as cur:
        cur.execute(sql)
        results = cur.fetchall()

    con.close()

    return results

def prettify_column(val, column):
    base = column.split('__')[-1]
    funcs = {
        'dollars_cents': lambda v: locale.currency(int(v), grouping=True),
        'name': lambda v: titleize(v),
        'city_state': lambda v: ','.join([titleize(v.split(',')[0]), v.split(',')[1]]),
        }
    func = funcs.get(base, str)
    return func(val)

def html_from_sql_result(result_list):
    html = ''
    if len(result_list) > 0:
        html += '<table>'
        for row_num, row in enumerate(result_list):
	    if row_num == 0:
		html += '\n    <tr>'
		for k, v in row.iteritems():
		    html += '<th>' + titleize(str(k)) + '</th>'
		html += '\n    </tr>'

            html += '\n    <tr>'
            for k, v in row.iteritems():
		html += '<td>' + prettify_column(v, k) + '</td>'
            html += '</tr>'
        html += '\n</table>'
    else:
        html = 'Query returned no results.'

    return html
<commit_msg>Remove errant newline<commit_after>import logging
import os
import argparse
import yaml
import pymysql
from pymysql.cursors import DictCursorMixin, Cursor
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from collections import OrderedDict
from inflection import titleize
import locale

class OrderedDictCursor(DictCursorMixin, Cursor):
    dict_type = OrderedDict

def read_file_to_string(path):
    with open(path, 'r') as f:
        return f.read()

def mysql_query(sql, secrets):
    con = pymysql.connect(
        host=secrets['db-hostname'],
        port=secrets['db-port'],
        user=secrets['db-username'],
        password=secrets['<PASSWORD>'],
        charset='utf8mb4',
        db=secrets['db-schema'],
        cursorclass=pymysql.cursors.DictCursor
        )

    with con.cursor(OrderedDictCursor) as cur:
        cur.execute(sql)
        results = cur.fetchall()

    con.close()

    return results

def prettify_column(val, column):
    base = column.split('__')[-1]
    funcs = {
        'dollars_cents': lambda v: locale.currency(int(v), grouping=True),
        'name': lambda v: titleize(v),
        'city_state': lambda v: ','.join([titleize(v.split(',')[0]), v.split(',')[1]]),
        }
    func = funcs.get(base, str)
    return func(val)

def html_from_sql_result(result_list):
    html = ''
    if len(result_list) > 0:
        html += '<table>'
        for row_num, row in enumerate(result_list):
	    if row_num == 0:
		html += '\n    <tr>'
		for k, v in row.iteritems():
		    html += '<th>' + titleize(str(k)) + '</th>'
		html += '</tr>'

	    html += '\n    <tr>'
	    for k, v in row.iteritems():
		html += '<td>' + prettify_column(v, k) + '</td>'
            html += '</tr>'
        html += '\n</table>'
    else:
        html = 'Query returned no results.'

    return html

{'fraction_non_alphanumeric': 0.14595607927155865, 'fraction_numerical': 0.003749330476700589, 'mean_word_length': 2.826844262295082, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '4795886', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1237, 'n_words': 305}