jenkins-bot has submitted this change and it was merged.
Change subject: (bugfix) "manual" is not a dict and can't be used for translation
......................................................................
(bugfix) "manual" is not a dict and can't be used for translation
on the other hand we have these translations on mediawiki and the
L10N_msg is obsolete. Update this part from compat.
Change-Id: I9e0903f5a93dd4cd5da342a591c68c59267ffef7
---
M scripts/reflinks.py
1 file changed, 8 insertions(+), 15 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 4ec04a1..cf88bc8 100644
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -60,14 +60,10 @@
'¶ms;': pagegenerators.parameterHelp
}
-localized_msg = ('fr', ) # localized message at mediawik
+localized_msg = ('fr', 'it', 'pl') # localized message at mediawiki
# localized message at specific wikipedia site
# should be moved to mediawiki pywikibot manual
-L10N_msg = {
- 'it': u'Utente:Marco27Bot/refLinks.py',
- 'pl': u'Wikipedysta:MastiBot/refLinks',
-}
stopPage = {
@@ -404,16 +400,13 @@
self.site = pywikibot.Site()
# Check
manual = 'mw:Manual:Pywikibot/refLinks'
- if self.site.family.name == 'wikipedia':
- manual = pywikibot.translate(self.site.code, manual)
- else:
- code = None
- for alt in [self.site.code] + i18n._altlang(self.site.code):
- if alt in localized_msg:
- code = alt
- break
- if code:
- manual += '/%s' % code
+ code = None
+ for alt in [self.site.code] + i18n._altlang(self.site.code):
+ if alt in localized_msg:
+ code = alt
+ break
+ if code:
+ manual += '/%s' % code
self.msg = i18n.twtranslate(self.site, 'reflinks-msg', locals())
self.stopPage = pywikibot.Page(self.site,
pywikibot.translate(self.site, stopPage))
--
To view, visit https://gerrit.wikimedia.org/r/133678
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e0903f5a93dd4cd5da342a591c68c59267ffef7
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Revert "Set translation fallback to False per default"
......................................................................
Revert "Set translation fallback to False per default"
This reverts commit a1b4cf1ded568ac436f4cb90c938b08ac4b8abd9.
Change-Id: I731cdc1ba011eb5a6020629fad158a1f5716e4a8
---
M pywikibot/i18n.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 3ec974b..879093e 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -264,7 +264,7 @@
return message
-def translate(code, xdict, parameters=None, fallback=False):
+def translate(code, xdict, parameters=None, fallback=True):
"""Return the most appropriate translation from a translation dict.
@param code The language code
--
To view, visit https://gerrit.wikimedia.org/r/133602
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I731cdc1ba011eb5a6020629fad158a1f5716e4a8
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Declare family.versionnumber and site.versionnumber as deprecated
......................................................................
Declare family.versionnumber and site.versionnumber as deprecated
There is a more precise method to compare versions by using
LooseVersion from distutils.version whereas versionnumber() for
"2.1wmf3" looks very strange with 1001. With LV we can also compare
the build number.
remove versionnumber() from old site method list
Change-Id: I442523c5b14ccf1a240e74e782c6b3f6f3139a0d
---
M pywikibot/family.py
M pywikibot/site.py
M pywikibot/textlib.py
M scripts/cosmetic_changes.py
M tests/site_tests.py
5 files changed, 19 insertions(+), 11 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index c422460..ae20781 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -959,14 +959,18 @@
# Which version of MediaWiki is used?
def version(self, code):
- """Return MediaWiki version number as a string."""
- # Don't use this, use versionnumber() instead. This only exists
- # to not break family files.
+ """ Return MediaWiki version number as a string.
+ Use LooseVersion from distutils.version to compare version strings.
+
+ """
# Here we return the latest mw release for downloading
return '1.20wmf2'
+ @pywikibot.deprecated("version()")
def versionnumber(self, code):
- """Return an int identifying MediaWiki version.
+ """ DEPRECATED, use version() instead and use
+ distutils.version.LooseVersion to compare version strings.
+ Return an int identifying MediaWiki version.
Currently this is implemented as returning the minor version
number; i.e., 'X' in version '1.X.Y'
@@ -1066,9 +1070,11 @@
]
def version(self, code):
- """Return Wikimedia projects version number as a string."""
- # Don't use this, use versionnumber() instead. This only exists
- # to not break family files.
+ """Return Wikimedia projects version number as a string.
+ Use LooseVersion from distutils.version to compate versions.
+
+ """
+ # Here we return the latest mw release for downloading
return '1.24wmf3'
def shared_image_repository(self, code):
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 2db9e82..ce4328c 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -612,7 +612,6 @@
# postData: Post encoded form data to an http address at this site.
#
# version: Return MediaWiki version string from Family file.
-# versionnumber: Return int identifying the MediaWiki version.
# live_version: Return version number read from Special:Version.
# checkCharset(charset): Warn if charset doesn't match family file.
#
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index c96ecb6..410af7b 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1020,7 +1020,8 @@
# if self.site().isInterwikiLink(name):
# continue
# # {{DEFAULTSORT:...}}
-# defaultKeys = self.site().versionnumber() > 13 and \
+# from distutils.version import LooseVersion as LV
+# defaultKeys = LV(self.site.version()) > LV("1.13") and \
# self.site().getmagicwords('defaultsort')
# # It seems some wikis does not have this magic key
# if defaultKeys:
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 691460f..2b67cfc 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -74,6 +74,7 @@
#
import re
+from distutils.version import LooseVersion as LV
import pywikibot
import isbn
from pywikibot import pagegenerators
@@ -338,7 +339,7 @@
thisNs = namespaces.pop(0)
if nsNumber == 6 and family.name == 'wikipedia':
if self.site.lang in ('en', 'fr') and \
- self.site.versionnumber() >= 14:
+ LV(self.site.version()) >= LV('1.14'):
# do not change "Image" on en-wiki and fr-wiki
assert u'Image' in namespaces
namespaces.remove(u'Image')
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 51a9c9e..83ff431 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -10,6 +10,7 @@
__version__ = '$Id$'
+from distutils.version import LooseVersion as LV
import pywikibot
from pywikibot.site import must_be
from tests import patch_request, unpatch_request
@@ -648,7 +649,7 @@
prefix = title[:title.index(":")]
self.assertTrue(mysite.ns_index(prefix) in [6, 7])
self.assertTrue(change["ns"] in [6, 7])
- if mysite.versionnumber() <= 14:
+ if LV(mysite.version()) <= LV("1.14"):
for change in mysite.recentchanges(pagelist=[mainpage, imagepage],
total=5):
self.assertType(change, dict)
--
To view, visit https://gerrit.wikimedia.org/r/133261
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I442523c5b14ccf1a240e74e782c6b3f6f3139a0d
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: -quiet option for noreferences, code cleanup
......................................................................
-quiet option for noreferences, code cleanup
- implement the hidden -quiet option to prohibit verbose output
- use NoReferencesBot.site attribute instead of getting Site object
over and over again
- use site.code instead of site.lang
- simplify inputChoise
- use page.text instead of page.get()
- use page.save() instead of page.put()
- return from method silently
Change-Id: I089625044be4a1866aeb6d42027b661ab316de1d
---
M scripts/noreferences.py
1 file changed, 24 insertions(+), 17 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 9c91521..43fb040 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -22,6 +22,8 @@
-always Don't prompt you for each replacement.
+ -quiet Use this option to get less output
+
All other parameters will be regarded as part of the title of a single page,
and the bot will only work on that single page.
@@ -448,11 +450,12 @@
yield pywikibot.Page(pywikibot.Site(), entry.title)
-class NoReferencesBot:
+class NoReferencesBot(object):
- def __init__(self, generator, always=False):
+ def __init__(self, generator, always=False, verbose=True):
self.generator = generator
self.always = always
+ self.verbose = verbose
self.site = pywikibot.Site()
self.comment = i18n.twtranslate(self.site, 'noreferences-add-tag')
@@ -462,38 +465,38 @@
re.IGNORECASE | re.DOTALL)
try:
self.referencesTemplates = referencesTemplates[
- pywikibot.Site().family.name][pywikibot.Site().lang]
+ self.site.family.name][self.site.code]
except KeyError:
self.referencesTemplates = []
try:
self.referencesText = referencesSubstitute[
- pywikibot.Site().family.name][pywikibot.Site().lang]
+ self.site.family.name][self.site.code]
except KeyError:
self.referencesText = u'<references />'
- def lacksReferences(self, text, verbose=True):
+ def lacksReferences(self, text):
"""
Checks whether or not the page is lacking a references tag.
"""
oldTextCleaned = pywikibot.removeDisabledParts(text)
if self.referencesR.search(oldTextCleaned) or \
self.referencesTagR.search(oldTextCleaned):
- if verbose:
+ if self.verbose:
pywikibot.output(u'No changes necessary: references tag found.')
return False
elif self.referencesTemplates:
templateR = u'{{(' + u'|'.join(self.referencesTemplates) + ')'
if re.search(templateR, oldTextCleaned, re.IGNORECASE | re.UNICODE):
- if verbose:
+ if self.verbose:
pywikibot.output(
u'No changes necessary: references template found.')
return False
if not self.refR.search(oldTextCleaned):
- if verbose:
+ if self.verbose:
pywikibot.output(u'No changes necessary: no ref tags found.')
return False
else:
- if verbose:
+ if self.verbose:
pywikibot.output(u'Found ref without references.')
return True
@@ -611,15 +614,16 @@
if not self.always:
choice = pywikibot.inputChoice(
u'Do you want to accept these changes?',
- ['Yes', 'No', 'Always yes'], ['y', 'N', 'a'], 'Y')
+ ['Yes', 'No', 'Always yes'], 'yNa', 'Y')
if choice == 'n':
return
elif choice == 'a':
self.always = True
+ page.text = newText
if self.always:
try:
- page.put(newText, self.comment)
+ page.save(self.comment)
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
@@ -631,8 +635,7 @@
pywikibot.output(u'Skipping %s (locked page)' % (page.title(),))
else:
# Save the page in the background. No need to catch exceptions.
- page.put_async(newText, self.comment)
- return
+ page.save(self.comment, async=True)
def run(self):
@@ -642,7 +645,7 @@
pywikibot.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<"
% page.title())
try:
- text = page.get()
+ text = page.text
except pywikibot.NoPage:
pywikibot.output(u"Page %s does not exist?!"
% page.title(asLink=True))
@@ -659,7 +662,7 @@
pywikibot.output(u"Page %s is a disambig; skipping."
% page.title(asLink=True))
continue
- if pywikibot.Site().sitename() == 'wikipedia:en' and \
+ if self.site.sitename() == 'wikipedia:en' and \
page.isIpEdit():
pywikibot.output(
u"Page %s is edited by IP. Possible vandalized"
@@ -671,7 +674,7 @@
def main():
- #page generator
+ # page generator
gen = None
# This temporary array is used to read the page title if one single
# page to work on is specified by the arguments.
@@ -681,6 +684,8 @@
namespaces = []
# Never ask before changing a page
always = False
+ # No verbose output
+ verbose = True
# This factory is responsible for processing command line arguments
# that are also used by other scripts and that determine on which pages
# to work on.
@@ -700,6 +705,8 @@
namespaces.append(arg[11:])
elif arg == '-always':
always = True
+ elif arg == '-quiet':
+ verbose = False
else:
if not genFactory.handleArg(arg):
pageTitle.append(arg)
@@ -727,7 +734,7 @@
if namespaces:
gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces)
preloadingGen = pagegenerators.PreloadingGenerator(gen)
- bot = NoReferencesBot(preloadingGen, always)
+ bot = NoReferencesBot(preloadingGen, always, verbose)
bot.run()
if __name__ == "__main__":
--
To view, visit https://gerrit.wikimedia.org/r/133445
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I089625044be4a1866aeb6d42027b661ab316de1d
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Additional options of RegexFilterPageGenerator from compat
......................................................................
Additional options of RegexFilterPageGenerator from compat
- regex may be a list of compiled or uncompiled regexes
- DIFFERENCE to compat: re.search is used instead of re.match
which is more general
- DIFFERENCE to compat: use quantifier option ('all', 'any' 'none')
instead of boolean inverse option which means all, any or none
regex must match
- backwards compatibility for inverse option
- ignore_namespace: ignore namespace in title for regex match
- same behaviour for RegexBodyFilterPageGenerator which also
gets quantifier parameter
- remove long time commented out lines for GoogleSearchPageGenerator
- pep8 changes
Change-Id: I3634b62779ef3811e85b0e6b8d6080b22957b8fc
---
M pywikibot/pagegenerators.py
1 file changed, 92 insertions(+), 35 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index d0a64b8..87472d0 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -235,8 +235,8 @@
dupfiltergen = DuplicateFilterPageGenerator(gensList)
if self.articlefilter:
- return RegexBodyFilterPageGenerator(PreloadingGenerator(dupfiltergen),
- self.articlefilter)
+ return RegexBodyFilterPageGenerator(
+ PreloadingGenerator(dupfiltergen), self.articlefilter)
else:
return dupfiltergen
@@ -487,7 +487,8 @@
gen = RegexFilterPageGenerator(self.site.allpages(), regex)
elif arg.startswith('-grep'):
if len(arg) == 5:
- self.articlefilter = pywikibot.input(u'Which pattern do you want to grep?')
+ self.articlefilter = pywikibot.input(
+ u'Which pattern do you want to grep?')
else:
self.articlefilter = arg[6:]
return True
@@ -835,20 +836,83 @@
yield page
-def RegexFilterPageGenerator(generator, regex):
- """Yield pages from another generator whose titles match regex."""
- reg = re.compile(regex, re.I)
- for page in generator:
- if reg.match(page.title(withNamespace=False)):
- yield page
+class RegexFilter(object):
+ @classmethod
+ def __filter_match(cls, regex, string, quantifier):
+ """ return True if string matches precompiled regex list with depending
+ on the quantifier parameter (see below).
-def RegexBodyFilterPageGenerator(generator, regex):
- """Yield pages from another generator whose body matches regex with options re.IGNORECASE|re.DOTALL."""
- reg = re.compile(regex, re.IGNORECASE | re.DOTALL)
- for page in generator:
- if reg.search(page.text):
- yield page
+ """
+ if quantifier == 'all':
+ match = all(r.search(string) for r in regex)
+ else:
+ match = any(r.search(string) for r in regex)
+ return (quantifier == 'none') ^ match
+
+ @classmethod
+ def __precompile(cls, regex, flag):
+ """ precompile the regex list if needed """
+ # Enable multiple regexes
+ if not isinstance(regex, list):
+ regex = [regex]
+ # Test if regex is already compiled.
+ # We assume that all list componets have the same type
+ if isinstance(regex[0], basestring):
+ regex = [re.compile(r, flag) for r in regex]
+ return regex
+
+ @classmethod
+ @deprecate_arg("inverse", "quantifier")
+ def titlefilter(cls, generator, regex, quantifier='any',
+ ignore_namespace=True):
+ """ Yield pages from another generator whose title matches regex with
+ options re.IGNORECASE dependig on the quantifier parameter.
+ If ignore_namespace is False, the whole page title is compared.
+ NOTE: if you want to check for a match at the beginning of the title,
+ you have to start the regex with "^"
+
+ @param generator: another generator
+ @type generator: any generator or iterator
+ @param regex: a regex which should match the page title
+ @type regex: a single regex string or a list of regex strings or a
+ compiled regex or a list of compiled regexes
+ @param quantifier: must be one of the following values:
+ 'all' - yields page if title is matched by all regexes
+ 'any' - yields page if title is matched by any regexes
+ 'none' - yields page if title is NOT matched by any regexes
+ @type quantifier: string of ('all', 'any', 'none')
+ @param ignore_namespace: ignore the namespace when matching the title
+ @type ignore_namespace: bool
+ @return: return a page depending on the matching parameters
+
+ """
+ # for backwards compatibility with compat for inverse parameter
+ if quantifier is False:
+ quantifier = 'any'
+ elif quantifier is True:
+ quantifier = 'none'
+ reg = cls.__precompile(regex, re.I)
+ for page in generator:
+ title = page.title(withNamespace=not ignore_namespace)
+ if cls.__filter_match(reg, title, quantifier):
+ yield page
+
+ @classmethod
+ def contentfilter(cls, generator, regex, quantifier='any'):
+ """Yield pages from another generator whose body matches regex with
+ options re.IGNORECASE|re.DOTALL dependig on the quantifier parameter.
+
+ For parameters see titlefilter above
+
+ """
+ reg = cls.__precompile(regex, re.IGNORECASE | re.DOTALL)
+ return (page for page in generator
+ if cls.__filter_match(reg, page.text, quantifier))
+
+# name the generator methods
+RegexFilterPageGenerator = RegexFilter.titlefilter
+RegexBodyFilterPageGenerator = RegexFilter.contentfilter
def CombinedPageGenerator(generators):
@@ -1110,13 +1174,15 @@
yield page
-def SearchPageGenerator(query, step=None, total=None, namespaces=None, site=None):
+def SearchPageGenerator(query, step=None, total=None, namespaces=None,
+ site=None):
"""
Provides a list of results using the internal MediaWiki search engine
"""
if site is None:
site = pywikibot.Site()
- for page in site.search(query, step=step, total=total, namespaces=namespaces):
+ for page in site.search(query, step=step, total=total,
+ namespaces=namespaces):
yield page
@@ -1136,8 +1202,8 @@
results = re.findall(REGEXP, http.request(site=None, uri=link))
if not results:
raise pywikibot.Error(
- 'Nothing found at %s! Try to use the tool by yourself to be sure that it '
- 'works!' % link)
+ u'Nothing found at %s! Try to use the tool by yourself to be sure '
+ u'that it works!' % link)
else:
for result in results:
yield pywikibot.Page(pywikibot.Site(), result)
@@ -1193,22 +1259,12 @@
site = pywikibot.Site()
self.site = site
- #########
- # partially commented out because it is probably not in compliance with
- # Google's "Terms of service"
- # (see 5.3, http://www.google.com/accounts/TOS?loc=US)
def queryGoogle(self, query):
- #if config.google_key:
- if True:
- #try:
- for url in self.queryViaSoapApi(query):
- yield url
- return
- #except ImportError:
- #pass
- # No google license key, or pygoogle not installed. Do it the ugly way.
- #for url in self.queryViaWeb(query):
- # yield url
+ #########
+ # Google's "Terms of service"
+ # (see 5.3, http://www.google.com/accounts/TOS?loc=US)
+ for url in self.queryViaSoapApi(query):
+ yield url
def queryViaSoapApi(self, query):
import google
@@ -1399,4 +1455,5 @@
if __name__ == "__main__":
- pywikibot.output('Pagegenerators cannot be run as script - are you looking for listpages.py?')
+ pywikibot.output(u'Pagegenerators cannot be run as script - are you '
+ u'looking for listpages.py?')
--
To view, visit https://gerrit.wikimedia.org/r/132199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3634b62779ef3811e85b0e6b8d6080b22957b8fc
Gerrit-PatchSet: 12
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: interwiki.py: add and reorganize error handling around ignored links
......................................................................
interwiki.py: add and reorganize error handling around ignored links
Handling of InvalidTitle is added to deal with comments like
<!-- [[Category:{{ja}} {{noun}}]] -->. Two consecutive try-except
blocks are unified for readability.
Change-Id: I890f4071b829aebcb75d32825ae886b5261f2852
---
M scripts/interwiki.py
1 file changed, 4 insertions(+), 3 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 019b478..36d853c 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -1832,9 +1832,6 @@
for iw in re.finditer('<!-- *\[\[(.*?:.*?)\]\] *-->', pagetext):
try:
ignorepage = pywikibot.Page(page.site, iw.groups()[0])
- except (pywikibot.NoSuchSite, ):
- continue
- try:
if (new[ignorepage.site] == ignorepage) and \
(ignorepage.site != page.site):
if (ignorepage not in interwikis):
@@ -1850,6 +1847,10 @@
'from': page})
except KeyError:
pass
+ except pywikibot.NoSuchSite:
+ pass
+ except pywikibot.InvalidTitle:
+ pass
# sanity check - the page we are fixing must be the only one for that
# site.
--
To view, visit https://gerrit.wikimedia.org/r/131062
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I890f4071b829aebcb75d32825ae886b5261f2852
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Whym <whym(a)whym.org>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: Whym <whym(a)whym.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Set translation fallback to False per default
......................................................................
Set translation fallback to False per default
i18n.translate() is used for L10N whereas i18n translations
are done by i18n.tntranslate. Because L10N is site-dependend and
not language-dependent, fallback must be False per default.
Otherwise the given results (templates, categories etc.) may be
wrong.
Change-Id: I15956db5490dec4ca9f7d55d53eb2ebc1a633790
---
M pywikibot/i18n.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 879093e..3ec974b 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -264,7 +264,7 @@
return message
-def translate(code, xdict, parameters=None, fallback=True):
+def translate(code, xdict, parameters=None, fallback=False):
"""Return the most appropriate translation from a translation dict.
@param code The language code
--
To view, visit https://gerrit.wikimedia.org/r/133455
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I15956db5490dec4ca9f7d55d53eb2ebc1a633790
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>