jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/344780 )
Change subject: [bugfix] Add 'mul' to exceptions list
......................................................................
[bugfix] Add 'mul' to exceptions list
- 'mul' pseudo language is used by wikisource and redirects to wikisource.org
itself. That code is added to the language_by_size list in family's
constructor. Therefore we must not add it by the mainenance script.
- also keep lines beneath 80 chars (PEP8)
Bug: T161398
Change-Id: I5016ec0ec563a8c5ac744abffe73032da5e71b7c
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/wikimedia_sites.py b/scripts/maintenance/wikimedia_sites.py
index 7a6ea23..dc72510 100755
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -33,7 +33,7 @@
'wiktionary',
]
-exceptions = ['-']
+exceptions = ['-', 'mul']
def update_family(families):
@@ -74,7 +74,7 @@
text = ' self.languages_by_size = [\n'
line = ' ' * 11
for code in new:
- if len(line) + len(code) <= 76:
+ if len(line) + len(code) < 76:
line += u" '%s'," % code
else:
text += '%s\n' % line
--
To view, visit https://gerrit.wikimedia.org/r/344780
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5016ec0ec563a8c5ac744abffe73032da5e71b7c
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/243630 )
Change subject: [FIX] Change tw(n)translate from Site.code to Site.lang dependency
......................................................................
[FIX] Change tw(n)translate from Site.code to Site.lang dependency
Bug: T140624
Change-Id: I0b7c25924e0d445db1c35da331890068316d3bbc
---
M pywikibot/i18n.py
1 file changed, 32 insertions(+), 29 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index f529aba..bbdf0d7 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -17,7 +17,7 @@
messages. See L{twntranslate} for more information on the messages.
"""
#
-# (C) Pywikibot team, 2004-2016
+# (C) Pywikibot team, 2004-2017
#
# Distributed under the terms of the MIT license.
#
@@ -40,7 +40,8 @@
from pywikibot import config
from pywikibot.exceptions import Error
from pywikibot.plural import plural_rules
-from pywikibot.tools import deprecated, issue_deprecation_warning, StringTypes
+from pywikibot.tools import (
+ deprecated, deprecated_args, issue_deprecation_warning, StringTypes)
PLURAL_PATTERN = r'{{PLURAL:(?:%\()?([^\)]*?)(?:\)d)?\|(.*?)}}'
@@ -524,7 +525,8 @@
return trans
-def twtranslate(code, twtitle, parameters=None, fallback=True,
+@deprecated_args(code='source')
+def twtranslate(source, twtitle, parameters=None, fallback=True,
only_plural=False):
"""
Translate a message using JSON files in messages_package_name.
@@ -569,9 +571,9 @@
... % {'descr': 'seulement'})
'Robot: Changer seulement quelques pages.'
- @param code: When it's a site it's using the code attribute and otherwise it
- is using the value directly.
- @type code: BaseSite or str
+ @param source: When it's a site it's using the lang attribute and otherwise
+ it is using the value directly.
+ @type source: BaseSite or str
@param twtitle: The TranslateWiki string title, in <package>-<key> format
@param parameters: For passing parameters. It should be a mapping but for
backwards compatibility can also be a list, tuple or a single value.
@@ -594,20 +596,20 @@
'Read %s/i18n'
% (_messages_package_name, twtitle, __url__))
- code_needed = False
- # If a site is given instead of a code, use its language
- if hasattr(code, 'code'):
- lang = code.code
+ source_needed = False
+ # If a site is given instead of a lang, use its language
+ if hasattr(source, 'lang'):
+ lang = source.lang
# check whether we need the language code back
- elif isinstance(code, list):
+ elif isinstance(source, list):
# For backwards compatibility still support lists, when twntranslate
# was not deprecated and needed a way to get the used language code back
- warn('The code argument should not be a list but either a BaseSite or '
- 'a str/unicode.', DeprecationWarning, 2)
- lang = code.pop()
- code_needed = True
+ warn('The source argument should not be a list but either a BaseSite '
+ 'or a str/unicode.', DeprecationWarning, 2)
+ lang = source.pop()
+ source_needed = True
else:
- lang = code
+ lang = source
# There are two possible failure modes: the translation dict might not have
# the language altogether, or a specific key could be untranslated. Both
@@ -626,9 +628,9 @@
'Read https://mediawiki.org/wiki/PWB/i18n'
% ('English' if 'en' in langs else "'%s'" % lang,
twtitle))
- # send the language code back via the given list
- if code_needed:
- code.append(alt)
+ # send the language code back via the given mutable list parameter
+ if source_needed:
+ source.append(alt)
if '{{PLURAL:' in trans:
# _extract_plural supports in theory non-mappings, but they are
@@ -659,14 +661,16 @@
@deprecated('twtranslate')
-def twntranslate(code, twtitle, parameters=None):
+@deprecated_args(code='source')
+def twntranslate(source, twtitle, parameters=None):
"""DEPRECATED: Get translated string for the key."""
if parameters is not None:
parameters = _PluralMappingAlias(parameters)
- return twtranslate(code, twtitle, parameters)
+ return twtranslate(source, twtitle, parameters)
-def twhas_key(code, twtitle):
+@deprecated_args(code='source')
+def twhas_key(source, twtitle):
"""
Check if a message has a translation in the specified language code.
@@ -675,16 +679,15 @@
No code fallback is made.
- @param code: The language code
+ @param source: When it's a site it's using the lang attribute and otherwise
+ it is using the value directly.
+ @type source: BaseSite or str
@param twtitle: The TranslateWiki string title, in <package>-<key> format
"""
# If a site is given instead of a code, use its language
- if hasattr(code, 'code'):
- code = code.code
- transdict = _get_translation(code, twtitle)
- if transdict is None:
- return False
- return True
+ lang = getattr(source, 'lang', source)
+ transdict = _get_translation(lang, twtitle)
+ return transdict is not None
def twget_keys(twtitle):
--
To view, visit https://gerrit.wikimedia.org/r/243630
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0b7c25924e0d445db1c35da331890068316d3bbc
Gerrit-PatchSet: 13
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/344668 )
Change subject: paraminfo_tests.py: Add 'text/x-collabkit' as a new content format
......................................................................
paraminfo_tests.py: Add 'text/x-collabkit' as a new content format
test_content_format should expect 'text/x-collabkit' as a new content format
when it finds CollaborationKit extension on a wiki.
Bug: T161223
Change-Id: I40fe1555bda228821920cb619ed45d0bdc1890e7
---
M tests/paraminfo_tests.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/paraminfo_tests.py b/tests/paraminfo_tests.py
index 8a8d776..2899314 100644
--- a/tests/paraminfo_tests.py
+++ b/tests/paraminfo_tests.py
@@ -127,6 +127,9 @@
if isinstance(self.site, DataSite):
# It is not clear when this format has been added, see T129281.
base.append('application/vnd.php.serialized')
+ extensions = set(e['name'] for e in self.site.siteinfo['extensions'])
+ if 'CollaborationKit' in extensions:
+ base.append('text/x-collabkit')
self._check_param_values(self.site, 'edit', 'contentformat', base)
self._check_param_values(self.site, 'parse', 'contentformat', base)
--
To view, visit https://gerrit.wikimedia.org/r/344668
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I40fe1555bda228821920cb619ed45d0bdc1890e7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/286789 )
Change subject: [IMPR] Simplify User class
......................................................................
[IMPR] Simplify User class
- deprecate User.name() method, use User.username property instead.
Replace deprecated method in welcome.py.
- Simplify editCount() and groups() method
- use username property in getUserTalkPage instead of title() method
- remove some tests inside deprecated sendMail which are already done
by send_email method.
- replace contrib.get('comment', None) by dict.get('comment')
because None is the default result when the key doesn't exist.
- Some doc added.
Change-Id: I6b727280046b0d63b15484139426ec794e00eb49
---
M pywikibot/page.py
M scripts/welcome.py
2 files changed, 29 insertions(+), 37 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 604ddb3..131820f 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -12,7 +12,7 @@
"""
#
-# (C) Pywikibot team, 2008-2016
+# (C) Pywikibot team, 2008-2017
#
# Distributed under the terms of the MIT license.
#
@@ -52,7 +52,6 @@
from pywikibot.comms import http
from pywikibot.exceptions import (
AutoblockUser,
- _EmailUserError,
NotEmailableError,
SiteDefinitionError,
UserRightsError,
@@ -2847,9 +2846,12 @@
pywikibot.output(
"This is an autoblock ID, you can only use to unblock it.")
+ @deprecated('User.username')
def name(self):
"""
The username.
+
+ DEPRECATED: use username instead.
@rtype: unicode
"""
@@ -2958,10 +2960,7 @@
@rtype: int or long
"""
- if 'editcount' in self.getprops(force):
- return self.getprops()['editcount']
- else:
- return 0
+ return self.getprops(force).get('editcount', 0)
def isBlocked(self, force=False):
"""
@@ -2993,13 +2992,10 @@
@param force: if True, forces reloading the data from API
@type force: bool
-
+ @return: groups property
@rtype: list
"""
- if 'groups' in self.getprops(force):
- return self.getprops()['groups']
- else:
- return []
+ return self.getprops(force).get('groups', [])
def getUserPage(self, subpage=u''):
"""
@@ -3008,6 +3004,8 @@
@param subpage: subpage part to be appended to the main
page title (optional)
@type subpage: unicode
+ @return: Page object of user page or user subpage
+ @rtype: Page
"""
if self._isAutoblock:
# This user is probably being queried for purpose of lifting
@@ -3025,6 +3023,8 @@
@param subpage: subpage part to be appended to the main
talk page title (optional)
@type subpage: unicode
+ @return: Page object of user talk page or user talk subpage
+ @rtype: Page
"""
if self._isAutoblock:
# This user is probably being queried for purpose of lifting
@@ -3033,7 +3033,7 @@
"This is an autoblock ID, you can only use to unblock it.")
if subpage:
subpage = u'/' + subpage
- return Page(Link(self.title(withNamespace=False) + subpage,
+ return Page(Link(self.username + subpage,
self.site, defaultNamespace=3))
def send_email(self, subject, text, ccme=False):
@@ -3087,22 +3087,15 @@
@type text: unicode
@param ccme: if True, sends a copy of this email to the bot
@type ccme: bool
- @raises _EmailUserError: logged in user does not have 'sendemail' right
- or the target has disabled receiving emails
+ @raises NotEmailableError: the user of this User is not emailable
+ @raises UserRightsError: logged in user does not have 'sendemail' right
@return: operation successful indicator
@rtype: bool
"""
- if not self.isEmailable():
- raise _EmailUserError('This user is not mailable')
-
- if not self.site.has_right('sendemail'):
- raise _EmailUserError('You don\'t have permission to send mail')
-
if self.send_email(subject, text, ccme=ccme):
pywikibot.output('Email sent.')
return True
- else:
- return False
+ return False
def block(self, expiry, reason, anononly=True, nocreate=True,
autoblock=True, noemail=False, reblock=False):
@@ -3172,8 +3165,7 @@
yield (Page(self.site, contrib['title'], contrib['ns']),
contrib['revid'],
ts,
- contrib.get('comment', None)
- )
+ contrib.get('comment'))
@deprecate_arg("number", "total")
def uploadedImages(self, total=10):
diff --git a/scripts/welcome.py b/scripts/welcome.py
index 60c981d..db7b5d2 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -165,8 +165,8 @@
# (C) Filnik, 2007-2011
# (C) Daniel Herding, 2007
# (C) Alex Shih-Han Lin, 2009-2010
-# (C) xqt, 2009-2016
-# (C) Pywikibot team, 2008-2016
+# (C) xqt, 2009-2017
+# (C) Pywikibot team, 2008-2017
#
# Distributed under the terms of the MIT license.
#
@@ -660,7 +660,7 @@
for result in queue:
# Adding the log... (don't take care of the variable's name...).
- luser = pywikibot.url2link(result.name(), self.site, self.site)
+ luser = pywikibot.url2link(result.username, self.site, self.site)
text += u'\n{{WLE|user=%s|contribs=%d}}' % (
luser, result.editCount())
# update log page.
@@ -729,30 +729,30 @@
for users in us:
if users.isBlocked():
showStatus(3)
- pywikibot.output(u'%s has been blocked!' % users.name())
+ pywikibot.output('%s has been blocked!' % users.username)
continue
if 'bot' in users.groups():
showStatus(3)
- pywikibot.output(u'%s is a bot!' % users.name())
+ pywikibot.output('%s is a bot!' % users.username)
continue
- if 'bot' in users.name().lower():
+ if 'bot' in users.username.lower():
showStatus(3)
pywikibot.output(u'%s might be a global bot!'
- % users.name())
+ % users.username)
continue
if users.editCount() >= globalvar.attachEditCount:
showStatus(2)
pywikibot.output(u'%s has enough edits to be welcomed.'
- % users.name())
+ % users.username)
ustp = users.getUserTalkPage()
if ustp.exists():
showStatus(3)
pywikibot.output(u'%s has been already welcomed.'
- % users.name())
+ % users.username)
continue
else:
- if self.badNameFilter(users.name()):
- self.reportBadAccount(users.name())
+ if self.badNameFilter(users.username):
+ self.reportBadAccount(users.username)
continue
welcome_text = i18n.translate(self.site, netext)
if globalvar.randomSign:
@@ -807,11 +807,11 @@
if not globalvar.quiet:
showStatus(1)
pywikibot.output(u'%s has no contributions.'
- % users.name())
+ % users.username)
else:
showStatus(1)
pywikibot.output(u'%s has only %d contributions.'
- % (users.name(), users.editCount()))
+ % (users.username, users.editCount()))
# That user mustn't be welcomed.
continue
if globalvar.makeWelcomeLog and i18n.translate(
--
To view, visit https://gerrit.wikimedia.org/r/286789
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6b727280046b0d63b15484139426ec794e00eb49
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/344584 )
Change subject: Request._add_defaults: Make sure the order of parameters does not change
......................................................................
Request._add_defaults: Make sure the order of parameters does not change
Using `set` on parameters was causing occasional cache misses because the
order of elements in a set is not guaranteed to be preserved.
Bug: T161291
Change-Id: I6ff4ddacf31af2d7ac1535b98dbeb4a5e46cd47a
---
M pywikibot/data/api.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 9030e4b..4f362af 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Interface to Mediawiki's api.php."""
#
-# (C) Pywikibot team, 2007-2016
+# (C) Pywikibot team, 2007-2017
#
# Distributed under the terms of the MIT license.
#
@@ -1683,14 +1683,14 @@
meta = self._params.get("meta", [])
if "userinfo" not in meta:
meta = set(meta + ['userinfo'])
- self._params['meta'] = list(meta)
+ self._params['meta'] = sorted(meta)
uiprop = self._params.get("uiprop", [])
uiprop = set(uiprop + ["blockinfo", "hasmsg"])
- self._params["uiprop"] = list(sorted(uiprop))
+ self._params['uiprop'] = sorted(uiprop)
if 'prop' in self._params:
if self.site.has_extension('ProofreadPage'):
prop = set(self._params['prop'] + ['proofread'])
- self._params['prop'] = list(prop)
+ self._params['prop'] = sorted(prop)
# When neither 'continue' nor 'rawcontinue' is present and the
# version number is at least 1.25wmf5 we add a dummy rawcontinue
# parameter. Querying siteinfo is save as it adds 'continue'.
@@ -2322,7 +2322,7 @@
% (self.__class__.__name__, filename, uniquedescr),
_logger)
return True
- except IOError as e:
+ except IOError:
# file not found
return False
except Exception as e:
--
To view, visit https://gerrit.wikimedia.org/r/344584
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6ff4ddacf31af2d7ac1535b98dbeb4a5e46cd47a
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>