<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cherrypy
from slideshow.lib import queue, template

class Ajax(object):
    @cherrypy.expose
    def rename(self, id, value):
        id = int(id[6:]) # remove prefix
        c = cherrypy.thread_data.db.cursor()
        q = queue.from_id(c, id)
        
        if q is None:
            return ''
        
        q.rename(c, value)
        cherrypy.thread_data.db.commit()
        return value
    
    @cherrypy.expose
    def remove(self, id):
        id = int(id)
        
        c = cherrypy.thread_data.db.cursor()
        if not queue.delete(c, id):
            return 'false'
        
        cherrypy.thread_data.db.commit()
        return 'true'

class Handler(object):
    ajax = Ajax()
    
    @cherrypy.expose
    @template.output('queue/index.html', parent='queues')
    def index(self):
        queues = queue.all(cherrypy.thread_data.db.cursor())
        return template.render(queues=queues)
    
    @cherrypy.expose
    def add(self, name, submit):
        c = cherrypy.thread_data.db.cursor()
        queue.add(c, name)<commit_msg>not really sure about this one, it's from mizuki//nitroxy but not sure why<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cherrypy
from slideshow.lib import queue, template

class Ajax(object):
    @cherrypy.expose
    def rename(self, id, value):
        id = int(id[6:]) # remove prefix
        c = cherrypy.thread_data.db.cursor()
        q = queue.from_id(c, id)
        
        if q is None:
            return ''
        
        q.rename(c, value)
        cherrypy.thread_data.db.commit()
        return value
    
    @cherrypy.expose
    def remove(self, id):
        id = int(id)
        
        c = cherrypy.thread_data.db.cursor()
        if not queue.delete(c, id):
            return 'false'
        
        cherrypy.thread_data.db.commit()
        return 'true'

class Handler(object):
    ajax = Ajax()
    
    @cherrypy.expose
    @template.output('queue/index.html', parent='queues')
    def index(self):
        queues = queue.all(cherrypy.thread_data.db.cursor())
        return template.render(queues=queues)
    
    @cherrypy.expose
    def add(self, name, submit):
        name = name.decode('utf-8')
        c = cherrypy.thread_data.db.cursor()
        queue.add(c, name)
{'fraction_non_alphanumeric': 0.1250533504054631, 'fraction_numerical': 0.002134016218523261, 'mean_word_length': 2.020618556701031, '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': '5867129', 'n_tokens_mistral': 790, 'n_tokens_neox': 769, 'n_words': 165}