Переглянути джерело

Proper handling of unicode in some commands.

tags/v0.1^2
Ben Kurtovic 12 роки тому
джерело
коміт
fb31aa73c8
5 змінених файлів з 12 додано та 11 видалено
  1. +3
    -2
      earwigbot/commands/afc_report.py
  2. +1
    -1
      earwigbot/commands/afc_submissions.py
  3. +4
    -5
      earwigbot/commands/link.py
  4. +2
    -1
      earwigbot/tasks/afc_statistics.py
  5. +2
    -2
      earwigbot/wiki/page.py

+ 3
- 2
earwigbot/commands/afc_report.py Переглянути файл

@@ -74,12 +74,13 @@ class AFCReport(Command):
return page

def report(self, page):
url = page.url.replace("en.wikipedia.org/wiki", "enwp.org")
url = page.url.encode("utf8")
url = url.replace("en.wikipedia.org/wiki", "enwp.org")
short = self.statistics.get_short_title(page.title)
status = self.get_status(page)
user = page.get_creator()
user_name = user.name
user_url = user.get_talkpage().url
user_url = user.get_talkpage().url.encode("utf8")

msg1 = "AfC submission report for \x0302{0}\x0F ({1}):"
msg2 = "Status: \x0303{0}\x0F"


+ 1
- 1
earwigbot/commands/afc_submissions.py Переглянути файл

@@ -54,6 +54,6 @@ class AFCSubmissions(Command):
site = self.bot.wiki.get_site()
category = site.get_category("Pending AfC submissions")
members = category.get_members(limit=number + len(self.ignore_list))
urls = [member.url for member in members if member.title not in self.ignore_list]
urls = [member.url.encode("utf8") for member in members if member.title not in self.ignore_list]
pages = ", ".join(urls[:number])
self.reply(data, "{0} pending AfC subs: {1}".format(number, pages))

+ 4
- 5
earwigbot/commands/link.py Переглянути файл

@@ -35,15 +35,15 @@ class Link(Command):

if re.search("(\[\[(.*?)\]\])|(\{\{(.*?)\}\})", msg):
links = self.parse_line(msg)
links = " , ".join(links)
self.reply(data, links)
links = u" , ".join(links)
self.reply(data, links.encode("utf8"))

elif data.command == "link":
if not data.args:
self.reply(data, "what do you want me to link to?")
return
pagename = " ".join(data.args)
link = self.site.get_page(pagename).url
link = self.site.get_page(pagename).url.encode("utf8")
self.reply(data, link)

def parse_line(self, line):
@@ -68,5 +68,4 @@ class Link(Command):
return results

def parse_template(self, pagename):
pagename = "".join(("Template:", pagename))
return self.site.get_page(pagename).url
return self.site.get_page("Template:" + pagename).url

+ 2
- 1
earwigbot/tasks/afc_statistics.py Переглянути файл

@@ -269,7 +269,8 @@ class AFCStatistics(Task):
tracked = [i[0] for i in cursor.fetchall()]

category = self.site.get_category(self.pending_cat)
for title, pageid in category.get_members():
for page in category.get_members():
title, pageid = page.title, page.pageid
if title in self.ignore_list:
continue
if pageid not in tracked:


+ 2
- 2
earwigbot/wiki/page.py Переглянути файл

@@ -513,9 +513,9 @@ class Page(CopyvioMixIn):
return self._fullurl
else:
encoded = self._title.encode("utf8").replace(" ", "_")
slug = quote(encoded, safe="/:")
slug = quote(encoded, safe="/:").decode("utf8")
path = self.site._article_path.replace("$1", slug)
return ''.join((self.site.url, path))
return u"".join((self.site.url, path))

@property
def namespace(self):


Завантаження…
Відмінити
Зберегти