Browse Source

Fixing contexts

pull/24/head
Ben Kurtovic 12 years ago
parent
commit
f58465718e
5 changed files with 11 additions and 8 deletions
  1. +3
    -0
      build.py
  2. +3
    -3
      pages/copyvios.mako
  3. +1
    -1
      pages/support/copyvios/checker.py
  4. +2
    -2
      pages/support/copyvios/highlighter.py
  5. +2
    -2
      pages/support/sites.py

+ 3
- 0
build.py View File

@@ -8,7 +8,10 @@ import shutil
page_src = """#! /usr/bin/env python page_src = """#! /usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import sys

os.chdir("..") os.chdir("..")
sys.path.insert(0, os.path.join(".", "{{pages_dir}}"))


from mako.template import Template from mako.template import Template
from mako.lookup import TemplateLookup from mako.lookup import TemplateLookup


+ 3
- 3
pages/copyvios.mako View File

@@ -2,9 +2,9 @@
from urlparse import parse_qs from urlparse import parse_qs
from earwigbot.bot import Bot from earwigbot.bot import Bot
%>\ %>\
<%namespace file="/support/copyvios/__init__.py" import="get_results, highlight_delta"/>\
<%namespace file="/support/sites.py" import="get_site, get_sites"/>\
<%namespace file="/support/misc.py" import="urlstrip"/>\
<%namespace module="support.copyvios" import="get_results, highlight_delta"/>\
<%namespace module="support.sites" import="get_site, get_sites"/>\
<%namespace module="support.misc" import="urlstrip"/>\
<% <%
lang = orig_lang = project = name = title = url = None lang = orig_lang = project = name = title = url = None
query = parse_qs(environ["QUERY_STRING"]) query = parse_qs(environ["QUERY_STRING"])


+ 1
- 1
pages/support/copyvios/checker.py View File

@@ -6,7 +6,7 @@ from time import time


from earwigbot import exceptions from earwigbot import exceptions


def get_results(bot, lang, project, name, all_projects, title, url, query):
def get_results(context, bot, lang, project, name, all_projects, title, url, query):
site = get_site(bot, lang, project, name, all_projects) site = get_site(bot, lang, project, name, all_projects)
if not site: if not site:
return None, None, None return None, None, None


+ 2
- 2
pages/support/copyvios/highlighter.py View File

@@ -2,7 +2,7 @@


from re import sub, UNICODE from re import sub, UNICODE


def highlight_delta(chain, delta):
def highlight_delta(context, chain, delta):
processed = [] processed = []
prev_prev = prev = chain.START prev_prev = prev = chain.START
i = 0 i = 0
@@ -11,7 +11,7 @@ def highlight_delta(chain, delta):
for paragraph in paragraphs: for paragraph in paragraphs:
processed_words = [] processed_words = []
words = paragraph.split(" ") words = paragraph.split(" ")
for i, word in enumerate(words, i)
for i, word in enumerate(words, i):
try: try:
next = strip_word(all_words[i+1]) next = strip_word(all_words[i+1])
except IndexError: except IndexError:


+ 2
- 2
pages/support/sites.py View File

@@ -5,7 +5,7 @@ from urlparse import urlparse


from earwigbot import exceptions from earwigbot import exceptions


def get_site(bot, lang, project, name, all_projects):
def get_site(context, bot, lang, project, name, all_projects):
if project not in [proj[0] for proj in all_projects]: if project not in [proj[0] for proj in all_projects]:
return None return None
if project == "wikimedia" and name: # Special sites: if project == "wikimedia" and name: # Special sites:
@@ -24,7 +24,7 @@ def get_site(bot, lang, project, name, all_projects):
except (exceptions.APIError, exceptions.LoginError): except (exceptions.APIError, exceptions.LoginError):
return None return None


def get_sites(bot):
def get_sites(context, bot):
max_staleness = 60 * 60 * 24 * 7 max_staleness = 60 * 60 * 24 * 7
conn = open_sql_connection(bot, "globals") conn = open_sql_connection(bot, "globals")
query1 = "SELECT update_time FROM updates WHERE update_service = ?" query1 = "SELECT update_time FROM updates WHERE update_service = ?"


Loading…
Cancel
Save