From 41165fcdac0809ce249d3aa41667ac5b68170f1c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 21 Jul 2012 15:06:39 -0400 Subject: [PATCH] Only escape site names if they contain characters outside of the BMP. Also doing some cleanup. --- pages/copyvios.mako | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pages/copyvios.mako b/pages/copyvios.mako index 3db7430..47e36ff 100644 --- a/pages/copyvios.mako +++ b/pages/copyvios.mako @@ -143,7 +143,11 @@ if time_since_update > max_staleness: update_sites(bot.wiki.get_site(), cursor) cursor.execute(query2) - langs = [(code, name.decode("unicode_escape")) for (code, name) in cursor.fetchall()] + langs = [] + for code, name in cursor.fetchall(): + if "\U" in name: + name = name.decode("unicode_escape") + langs.append((code, name)) cursor.execute(query3) projects = cursor.fetchall() return langs, projects @@ -154,8 +158,9 @@ languages, projects = set(), set() for site in matrix.itervalues(): if isinstance(site, list): # Special sites + bad_sites = ["closed", "private", "fishbowl"] for special in site: - if "closed" not in special and "private" not in special and "fishbowl" not in special: + if all([key not in special for key in bad_sites]): full = urlparse(special["url"]).netloc if full.count(".") == 1: # No subdomain, so use "www" lang, project = "www", full.split(".")[0] @@ -174,7 +179,10 @@ this.add((project, project.capitalize())) if this: code = site["code"] - name = site["name"].encode("unicode_escape") + if "\U" in site["name"].encode("unicode_escape"): + name = site["name"].encode("unicode_escape") + else: + name = site["name"] languages.add((code, u"{0} ({1})".format(code, name))) projects |= this save_site_updates(cursor, languages, projects) @@ -374,12 +382,12 @@ % if project and lang and title and not page:
-

The given site, (project=${project}, language=${lang}) doesn't seem to exist. It may also be closed or private. Confirm its URL.

+

The given site (project=${project}, language=${lang}) doesn't seem to exist. It may also be closed or private. Confirm its URL.

% elif project and lang and title and page and not result:
-

The given page, ${page.title | h}, doesn't seem to exist.

+

The given page doesn't seem to exist: ${page.title | h}.

% elif page: