http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10583
Revision: 10583
Author: xqt
Date: 2012-10-15 20:20:14 +0000 (Mon, 15 Oct 2012)
Log Message:
-----------
nowCommonsTemplates only used by generator; no need to hold it by instance.
Modified Paths:
--------------
trunk/pywikipedia/nowcommons.py
Modified: trunk/pywikipedia/nowcommons.py
===================================================================
--- trunk/pywikipedia/nowcommons.py 2012-10-15 19:17:19 UTC (rev 10582)
+++ trunk/pywikipedia/nowcommons.py 2012-10-15 20:20:14 UTC (rev 10583)
@@ -184,9 +184,6 @@
self.site = pywikibot.getSite()
if repr(self.site) == 'commons:commons':
sys.exit('Do not run this bot on Commons!')
- self.nowCommonsTemplates = [pywikibot.Page(self.site, title,
- defaultNamespace=10)
- for title in self.ncTemplates()]
def ncTemplates(self):
if self.site.lang in nowCommons:
@@ -225,7 +222,8 @@
continue
url_local = x.group('urllocal')
url_commons = x.group('urlcommons')
- pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % image_local)
+ pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
+ % image_local)
pywikibot.output(u'Local: %s\nCommons: %s\n'
% (url_local, url_commons))
result1 = webbrowser.open(url_local, 0, 1)
@@ -253,9 +251,12 @@
if use_hash:
gen = self.useHashGenerator()
else:
+ nowCommonsTemplates = [pywikibot.Page(self.site, title,
+ defaultNamespace=10)
+ for title in self.ncTemplates()]
gens = [pg.ReferringPageGenerator(t, followRedirects=True,
onlyTemplateInclusion=True)
- for t in self.nowCommonsTemplates]
+ for t in nowCommonsTemplates]
gen = pg.CombinedPageGenerator(gens)
gen = pg.NamespaceFilterPageGenerator(gen, [6])
gen = pg.DuplicateFilterPageGenerator(gen)
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10577
Revision: 10577
Author: xqt
Date: 2012-10-14 17:17:03 +0000 (Sun, 14 Oct 2012)
Log Message:
-----------
some i18n for input messages,
update from trunk r10134
Modified Paths:
--------------
branches/rewrite/scripts/replace.py
Modified: branches/rewrite/scripts/replace.py
===================================================================
--- branches/rewrite/scripts/replace.py 2012-10-14 17:16:30 UTC (rev 10576)
+++ branches/rewrite/scripts/replace.py 2012-10-14 17:17:03 UTC (rev 10577)
@@ -385,8 +385,13 @@
page.site.hostname(),
page.site.nice_get_address(page.title())
))
- pywikibot.input("Press Enter when finished in browser.")
- original_text = page.get(get_redirect=True, force=True)
+ i18n.input('pywikibot-enter-finished-browser')
+ try:
+ original_text = page.get(get_redirect=True, force=True)
+ except pywikibot.NoPage:
+ pywikibot.output(u'Page %s has been deleted.'
+ % page.title())
+ break
new_text = original_text
continue
if choice == 'q':
@@ -491,8 +496,7 @@
xmlStart = arg[10:]
elif arg.startswith('-xml'):
if len(arg) == 4:
- xmlFilename = pywikibot.input(
- u'Please enter the XML dump\'s filename:')
+ xmlFilename = i18n.input('pywikibot-enter-xml-filename')
else:
xmlFilename = arg[5:]
elif arg =='-sql':
@@ -574,11 +578,12 @@
replacements.append((old, new))
while True:
old = pywikibot.input(
-u'Please enter another text that should be replaced, or press Enter to start:')
+ u'Please enter another text that should be replaced,' +
+ u'\nor press Enter to start:')
if old == '':
change += ')'
break
- new = pywikibot.input(u'Please enter the new text:')
+ new = i18n.input('pywikibot-enter-new-text')
change += ' & -' + old + ' +' + new
replacements.append((old, new))
if not summary_commandline:
@@ -588,7 +593,8 @@
pywikibot.output(u'The summary message will default to: %s'
% default_summary_message)
summary_message = pywikibot.input(
-u'Press Enter to use this default message, or enter a description of the\nchanges your bot will make:')
+ u'Press Enter to use this default message, or enter a ' +
+ u'description of the\nchanges your bot will make:')
if summary_message == '':
summary_message = default_summary_message
edit_summary = summary_message
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10575
Revision: 10575
Author: xqt
Date: 2012-10-14 17:02:57 +0000 (Sun, 14 Oct 2012)
Log Message:
-----------
some i18n for input messages,
update from trunk r10134
Modified Paths:
--------------
branches/rewrite/pywikibot/pagegenerators.py
Modified: branches/rewrite/pywikibot/pagegenerators.py
===================================================================
--- branches/rewrite/pywikibot/pagegenerators.py 2012-10-14 16:48:33 UTC (rev 10574)
+++ branches/rewrite/pywikibot/pagegenerators.py 2012-10-14 17:02:57 UTC (rev 10575)
@@ -18,17 +18,17 @@
#
__version__ = '$Id$'
-import pywikibot
-from pywikibot import config
-from pywikibot import deprecate_arg
-
-import itertools
-import Queue
import re
import sys
import codecs
+import itertools
+import Queue
+import pywikibot
+from pywikibot import config
+from pywikibot import deprecate_arg, i18n
+
# ported from version 1 for backwards-compatibility
# most of these functions just wrap a Site or Page method that returns
# a generator
@@ -36,7 +36,8 @@
parameterHelp = u"""\
-cat Work on all pages which are in a specific category.
Argument can also be given as "-cat:categoryname" or
- as "-cat:categoryname|fromtitle".
+ as "-cat:categoryname|fromtitle" (using # instead of |
+ is also allowed in this one and the following)
-catr Like -cat, but also recursively includes pages in
subcategories, sub-subcategories etc. of the
@@ -203,10 +204,10 @@
def getCategoryGen(self, arg, length, recurse=False, content=False):
if len(arg) == length:
- categoryname = pywikibot.input(u'Please enter the category name:')
+ categoryname = i18n.input('pywikibot-enter-category-name')
else:
categoryname = arg[length + 1:]
-
+ categoryname = categoryname.replace('#', '|')
ind = categoryname.find('|')
startfrom = None
if ind > 0:
@@ -222,7 +223,7 @@
def setSubCategoriesGen(self, arg, length, recurse=False, content=False):
if len(arg) == length:
- categoryname = pywikibot.input(u'Please enter the category name:')
+ categoryname = i18n.input('pywikibot-enter-category-name')
else:
categoryname = arg[length + 1:]
@@ -248,18 +249,19 @@
arguments have been parsed to get the final output generator.
"""
+ site = pywikibot.getSite()
gen = None
if arg.startswith('-filelinks'):
fileLinksPageTitle = arg[11:]
if not fileLinksPageTitle:
- fileLinksPageTitle = pywikibot.input(
- u'Links to which image page should be processed?')
- if fileLinksPageTitle.startswith(pywikibot.Site().namespace(6)
+ fileLinksPageTitle = i18n.input(
+ 'pywikibot-enter-file-links-processing')
+ if fileLinksPageTitle.startswith(site.namespace(6)
+ ":"):
- fileLinksPage = pywikibot.ImagePage(pywikibot.Site(),
+ fileLinksPage = pywikibot.ImagePage(site,
fileLinksPageTitle)
else:
- fileLinksPage = pywikibot.ImagePage(pywikibot.Site(),
+ fileLinksPage = pywikibot.ImagePage(site,
'Image:' +
fileLinksPageTitle)
gen = FileLinksGenerator(fileLinksPage)
@@ -283,7 +285,7 @@
elif arg.startswith('-interwiki'):
title = arg[11:]
if not title:
- title = pywikibot.input(u'Which page should be processed?')
+ title = i18n.input('pywikibot-enter-page-processing')
page = pywikibot.Page(pywikibot.Link(title,
pywikibot.Site()))
gen = InterwikiPageGenerator(page)