<commit_before>import cgi
import os
import sys
import re
import urllib
import traceback
import logging
from types import InstanceType

from google.appengine.api import users, memcache
from google.appengine.ext import db, webapp
from google.appengine.ext.webapp import template
from google.appengine.api.datastore_errors import BadKeyError

import twitter
import blogsearch
import json
import yaml
import bitly
import env
import local
from model.site import Site
from model.edit import Edit
from model.user import User
from recursivedefaultdict import recursivedefaultdict
from sanitize import sanitize

template.register_template_library('template')

class NotFoundException(Exception):
  pass

class Handler(webapp.RequestHandler):
  _response_dict = None
  _url_args = None
  
  @staticmethod
  def factory(**kwargs):
    """Convenience method for subclasses of Handler."""
    return type(str(kwargs), (Handler,), kwargs)
  
  def response_dict(self, **kwargs):
    if not self._response_dict:
      self._response_dict = recursivedefaultdict()
    if kwargs:
      self._response_dict.update(**kwargs)
    return self._response_dict
    
  def get(self, *args):
    # check for trailing slashes
    match = re.compile('^(/.*[^/])/+$').search(self.request.path)
    if match and match.groups(1):
      # strip trailing slashes and redirect
      return self.redirect(match.group(1))
    # check if we can respond
    if hasattr(self.page, 'get'):
      # run the handler and get the template path<commit_msg>moved member variables init to __init__<commit_after>import cgi
import os
import sys
import re
import urllib
import traceback
import logging
from types import InstanceType

from google.appengine.api import users, memcache
from google.appengine.ext import db, webapp
from google.appengine.ext.webapp import template
from google.appengine.api.datastore_errors import BadKeyError

import twitter
import blogsearch
import json
import yaml
import bitly
import env
import local
from model.site import Site
from model.edit import Edit
from model.user import User
from recursivedefaultdict import recursivedefaultdict
from sanitize import sanitize

template.register_template_library('template')

class NotFoundException(Exception):
  pass

class Handler(webapp.RequestHandler):
  
  @staticmethod
  def factory(**kwargs):
    """Convenience method for subclasses of Handler."""
    return type(str(kwargs), (Handler,), kwargs)
  
  def __init__(self):
    self._response_dict = recursivedefaultdict()
    self._url_args = None
  
  def response_dict(self, **kwargs):
    if kwargs:
      self._response_dict.update(**kwargs)
    return self._response_dict
    
  def get(self, *args):
    # check for trailing slashes
    match = re.compile('^(/.*[^/])/+$').search(self.request.path)
    if match and match.groups(1):
      # strip trailing slashes and redirect
      return self.redirect(match.group(1))
    # check if we can respond
    if hasattr(self.page, 'get'):
      # run the handler and get the template path
{'fraction_non_alphanumeric': 0.08239576439444077, 'fraction_numerical': 0.0013236267372600927, 'mean_word_length': 4.350442477876106, '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': '3048223', 'n_tokens_mistral': 872, 'n_tokens_neox': 861, 'n_words': 285}