From 420a1708e014041c012418a6db88a2a7527043e1 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 22 Jul 2012 02:05:27 -0400 Subject: [PATCH] Refactor get_site() to copyvios.mako directly instead of the checker. --- pages/copyvios.mako | 11 +++++++---- pages/support/copyvios/checker.py | 9 +++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pages/copyvios.mako b/pages/copyvios.mako index f7e207c..48bb056 100644 --- a/pages/copyvios.mako +++ b/pages/copyvios.mako @@ -7,6 +7,9 @@ <%namespace module="support.misc" import="urlstrip"/>\ <% lang = orig_lang = project = name = title = url = None + site = page = result = None + + # Parse the query string. query = parse_qs(environ["QUERY_STRING"]) if "lang" in query: lang = orig_lang = query["lang"][0].decode("utf8").lower() @@ -18,13 +21,13 @@ title = query["title"][0].decode("utf8") if "url" in query: url = query["url"][0].decode("utf8") + bot = Bot(".earwigbot") all_langs, all_projects = get_sites(bot) if lang and project and title: - site, page, result = get_results(bot, lang, project, name, - all_projects, title, url, query) - else: - site = page = result = None + site = get_site(bot, lang, project, name, all_projects) + if site: + page, result = get_results(bot, site, title, url, query) %>\ <%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>

Copyvio Detector

diff --git a/pages/support/copyvios/checker.py b/pages/support/copyvios/checker.py index 47b0751..048a0fa 100644 --- a/pages/support/copyvios/checker.py +++ b/pages/support/copyvios/checker.py @@ -8,15 +8,12 @@ from earwigbot import exceptions from ..misc import open_sql_connection -def get_results(context, bot, lang, project, name, all_projects, title, url, query): - site = get_site(bot, lang, project, name, all_projects) - if not site: - return None, None, None +def get_results(context, bot, site, title, url, query): page = site.get_page(title) try: page.get() # Make sure that the page exists before we check it! except (exceptions.PageNotFoundError, exceptions.InvalidPageError): - return site, page, None + return page, None # if url: # result = get_url_specific_results(page, url) @@ -35,7 +32,7 @@ def get_results(context, bot, lang, project, name, all_projects, title, url, que result.cached = False result.tdiff = time() - tstart # END TEST BLOCK - return site, page, result + return page, result def get_url_specific_results(page, url): t_start = time()