<commit_before>from __future__ import print_function, unicode_literals

from datetime import date, datetime, timedelta

import collections
import difflib
import random

from pygal import Config, Dot, DateY
from pygal.style import Style

from remysmoke.model import DBSession
from remysmoke.model.auth import User
from remysmoke.model.smoke import Cigarette

LightStyle = Style(
    background='transparent',
    plot_background='transparent',
    foreground='rgba(0, 0, 0, 0.7)',
    foreground_light='rgb(0, 0, 0)',
    foreground_dark='rgb(238,238,238)',
    colors=('rgb(31, 119, 180)', '#9f6767', '#92ac68',
            '#d0d293', '#9aacc3', '#bb77a4',
            '#77bbb5', '#777777')
)
class LineConfig(Config):
    def __init__(self, *a, **kw):
        super(LineConfig, self).__init__(*a, **kw)
        self.width, self.height = (900, 225)
        self.disable_xml_declaration = True

        self.x_label_rotation = 20
        self.order_min = 0
        self.fill = False
        self.show_dots = False
        self.include_x_axis = True
        self.no_prefix = True
        self.style = LightStyle

def punch_chart():
    users = DBSession.query(Cigarette.user).group_by(Cigarette.user).all()
    charts = dict()
    for (user,) in users:
        cigarettes = DBSession.query(Cigarette).filter_by(user=user).all()
        (name,) = DBSession.query(User.display_name) \
                           .filter_by(user_name=user).one()

        chart_data = collections.defaultdict(lambda: [0]*24)
        for cigarette in cigarettes:
            dow = cigarette.date.strftime('%A')
            hour = cigarette.date.hour
            chart_data[dow][hour] += 1

        chart = Dot(width=900, height=225, show_dots=False, style=LightStyle,
                    css=['style.css', resource], js = [],
                    x_label_rotation=20, include_x_axis=False)
        days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
        for dow in days:<commit_msg>Split LineConfig so punchcard can share.<commit_after>from __future__ import print_function, unicode_literals

from datetime import date, datetime, timedelta

import collections
import difflib
import random

from pygal import Config, Dot, DateY
from pygal.style import Style

from remysmoke.model import DBSession
from remysmoke.model.auth import User
from remysmoke.model.smoke import Cigarette

LightStyle = Style(
    background='transparent',
    plot_background='transparent',
    foreground='rgba(0, 0, 0, 0.7)',
    foreground_light='rgb(0, 0, 0)',
    foreground_dark='rgb(238,238,238)',
    colors=('rgb(31, 119, 180)', '#9f6767', '#92ac68',
            '#d0d293', '#9aacc3', '#bb77a4',
            '#77bbb5', '#777777')
)
class BaseConfig(Config):
    def __init__(self, *a, **kw):
        super(BaseConfig, self).__init__(*a, **kw)
        self.width, self.height = (900, 225)
        self.show_dots = False
        self.print_values = False
        self.style = LightStyle
        self.no_prefix = True
        self.disable_xml_declaration = True
        self.include_x_axis = True
        self.js = []


class LineConfig(BaseConfig):
    def __init__(self, *a, **kw):
        super(LineConfig, self).__init__(*a, **kw)
        self.x_label_rotation = 20
        self.order_min = 0
        self.fill = False


def punch_chart():
    users = DBSession.query(Cigarette.user).group_by(Cigarette.user).all()
    charts = dict()
    for (user,) in users:
        cigarettes = DBSession.query(Cigarette).filter_by(user=user).all()
        (name,) = DBSession.query(User.display_name) \
                           .filter_by(user_name=user).one()

        chart_data = collections.defaultdict(lambda: [0]*24)
        for cigarette in cigarettes:
            dow = cigarette.date.strftime('%A')
            hour = cigarette.date.hour
            chart_data[dow][hour] += 1

        chart = Dot(BaseConfig())
        days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
        for dow in days:
{'fraction_non_alphanumeric': 0.12940884252359663, 'fraction_numerical': 0.03427719821162444, 'mean_word_length': 2.917315175097276, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1183203', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1270, 'n_words': 288}