<commit_before>from flask import render_template, jsonify, request
from markupsafe import Markup
from appshell import current_appshell
from appshell.markup import (element, link_button, button, xmltag,
                             form_button, glyphicon)
from appshell.urls import res_url, url_or_url_for
from appshell.templates import widgets, dropdowns, modals
import iso8601
import datetime
import json

from flask.ext.babelex import Babel, Domain

import sys
if sys.version_info >= (3,):
    unicode = str

mydomain = Domain('appshell')
_ = mydomain.gettext
lazy_gettext = mydomain.lazy_gettext

default_content_map = {True: glyphicon('ok'),
                       False: glyphicon('remove'),
                       None: glyphicon('ban-circle')}

class Column(object):
    orderable = True

    def __init__(self, 
                 name, 
                 filter=None,
                 options={},
                 orderable=None,
                 default_ordering=None,
                 convert=None,
                 data_proc=None,
                 content_map=default_content_map,
                 **kwargs):
        self.name = name
        self.id = name
        self.header = Markup("<th>{0}</th>").format(name)
        self.filter = filter
        self._options = options
        if convert:
            self.convert = convert
        self.default_ordering = default_ordering
        
        self.content_map = content_map
            
        if orderable != None:
            self.orderable = orderable
        if data_proc:
            self.get_cell_data = data_proc

    @property
    def options(self):
        o = dict(self._options)
        o["orderable"] = self.orderable
        return o

    def get_cell_html(self, row):
        return element("td", {}, self.get_cell_inner_html(row))

    def convert(self, data):
        return data
    
    def get_cell_inner_html(self, row):
        res = self.get_cell_data(row)
        res = self.convert(res)

        try:
            if res in self.content_map:
                return self.content_map[res]
        except:
            pass
        return res

    def get_json_data(self, row):
        return unicode(self.get_cell_inner_html(row))

    def get_filter_html(self, column_index, table):<commit_msg>hardcode the icon mapping as dict with True matches random one-like things<commit_after>from flask import render_template, jsonify, request
from markupsafe import Markup
from appshell import current_appshell
from appshell.markup import (element, link_button, button, xmltag,
                             form_button, glyphicon)
from appshell.urls import res_url, url_or_url_for
from appshell.templates import widgets, dropdowns, modals
import iso8601
import datetime
import json

from flask.ext.babelex import Babel, Domain

import sys
if sys.version_info >= (3,):
    unicode = str

mydomain = Domain('appshell')
_ = mydomain.gettext
lazy_gettext = mydomain.lazy_gettext

default_content_map = {}

class Column(object):
    orderable = True

    def __init__(self, 
                 name, 
                 filter=None,
                 options={},
                 orderable=None,
                 default_ordering=None,
                 convert=None,
                 data_proc=None,
                 content_map=default_content_map,
                 **kwargs):
        self.name = name
        self.id = name
        self.header = Markup("<th>{0}</th>").format(name)
        self.filter = filter
        self._options = options
        if convert:
            self.convert = convert
        self.default_ordering = default_ordering
        
        self.content_map = content_map
            
        if orderable != None:
            self.orderable = orderable
        if data_proc:
            self.get_cell_data = data_proc

    @property
    def options(self):
        o = dict(self._options)
        o["orderable"] = self.orderable
        return o

    def get_cell_html(self, row):
        return element("td", {}, self.get_cell_inner_html(row))

    def convert(self, data):
        return data
    
    def get_cell_inner_html(self, row):
        res = self.get_cell_data(row)
        res = self.convert(res)

        try:
            if res in self.content_map:
                return self.content_map[res]
        except:
            pass

        if res is True:
            res = glyphicon('ok')
        elif res is False:
            res = glyphicon('remove')
        elif res is None:
            res = glyphicon('ban-circle')
        
        return res

    def get_json_data(self, row):
        return unicode(self.get_cell_inner_html(row))

    def get_filter_html(self, column_index, table):
{'fraction_non_alphanumeric': 0.0818065615679591, 'fraction_numerical': 0.0025564550489987218, 'mean_word_length': 1.9923518164435947, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '4181508', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1296, 'n_words': 328}