<commit_before>import pickle
import sys

from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response
from google.appengine.ext import db

from third_party.graphy.backends import google_chart_api

from stats import models


def index(request):
  return HttpResponseRedirect('list')
  #data = [2, 4, 7, 7, 4, 6, 8, 2, 1, 2, 5, 8, 8]
  #chart = google_chart_api.LineChart(data)
  #context = {'chart': chart.display.Img(300, 200)}
  #return render_to_response('stats/index.html', context)


def add(request, id, key, value):
  c = models.Chart.get_or_create(id)
  c.data[int(key)] = float(value)
  c.put()
  context = {'chart': chart}
  return render_to_response('stats/add.html', context)


def list(request):
  charts = models.Chart.get_all()
  context = {'num_charts': len(charts),
             'charts': charts,
            }
  return render_to_response('stats/list.html', context)


def show(request, id):
  chart = models.Chart.get_by_id(id)
  if chart is None:<commit_msg>hack on sys.path in yet another place<commit_after>import pickle
import sys
import os

sys.path.append(os.path.join(os.path.dirname(__file__), 'third_party'))


from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response
from google.appengine.ext import db

from third_party.graphy.backends import google_chart_api

from stats import models


def index(request):
  return HttpResponseRedirect('list') 
  #data = [2, 4, 7, 7, 4, 6, 8, 2, 1, 2, 5, 8, 8]
  #chart = google_chart_api.LineChart(data)
  #context = {'chart': chart.display.Img(300, 200)}
  #return render_to_response('stats/index.html', context)


def add(request, id, key, value):
  chart = models.Chart.get_or_create(id)
  chart.data[key] = value
  chart.put()
  context = {'chart': chart}
  return render_to_response('stats/add.html', context)


def list(request):
  charts = models.Chart.get_all()
  context = {'num_charts': len(charts),
             'charts': charts,
            }
  return render_to_response('stats/list.html', context)


def show(request, id):
  chart = models.Chart.get_by_id(id)
  if chart is None:
{'fraction_non_alphanumeric': 0.12713035467526485, 'fraction_numerical': 0.02026715799170889, 'mean_word_length': 4.471032745591939, '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': '3046193', 'n_tokens_mistral': 778, 'n_tokens_neox': 721, 'n_words': 189}