jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/571008 )
Change subject: [IMPR] replace Site.userinfo['rights'] with Site.has_right ......................................................................
[IMPR] replace Site.userinfo['rights'] with Site.has_right
Change-Id: I083779a8f56e15459e692c125036409765107cf9 --- M pywikibot/page.py M pywikibot/site.py M pywikibot/specialbots.py M scripts/category.py M scripts/redirect.py 5 files changed, 17 insertions(+), 22 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index af90868..c154adf 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -1917,7 +1917,7 @@ reason = pywikibot.input('Please enter a reason for the deletion:')
# If user has 'delete' right, delete the page - if 'delete' in self.site.userinfo['rights']: + if self.site.has_right('delete'): answer = 'y' if prompt and not hasattr(self.site, '_noDeletePrompt'): answer = pywikibot.input_choice( diff --git a/pywikibot/site.py b/pywikibot/site.py index 0ad71fe..f91c2f0 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -1304,7 +1304,7 @@ 'can perform requested action.' .format(self.sitename)) if right is not None: - if right in self.userinfo['rights']: + if self.has_right(right): return fn(self, *args, **kwargs) if grp == 'user': self.login(False) @@ -5034,10 +5034,10 @@
err = ('deletedrevs: User:{} not authorized to ' .format(self.user())) - if 'deletedhistory' not in self.userinfo['rights']: + if not self.has_right('deletedhistory'): raise Error(err + 'access deleted revisions.') if content: - if 'undelete' not in self.userinfo['rights']: + if not self.has_right('undelete'): raise Error(err + 'view deleted content.')
revids = kwargs.pop('revids', None) @@ -5291,7 +5291,7 @@
token = self.tokens['edit'] if bot is None: - bot = ('bot' in self.userinfo['rights']) + bot = self.has_right('bot') params = dict(action='edit', title=page, text=text, token=token, summary=summary, bot=bot, recreate=recreate, createonly=createonly, @@ -6354,7 +6354,7 @@ # An offset != 0 doesn't make sense without a file key assert(_offset == 0 or _file_key is not None) # check for required user right - if 'upload' not in self.userinfo['rights']: + if not self.has_right('upload'): raise Error( "User '%s' does not have upload rights on site %s." % (self.user(), self)) @@ -6592,7 +6592,7 @@ } else: # upload by URL - if 'upload_by_url' not in self.userinfo['rights']: + if not self.has_right('upload_by_url'): raise Error( "User '%s' is not authorized to upload by URL on site %s." % (self.user(), self)) diff --git a/pywikibot/specialbots.py b/pywikibot/specialbots.py index 2bfbed1..cd74fee 100644 --- a/pywikibot/specialbots.py +++ b/pywikibot/specialbots.py @@ -3,7 +3,7 @@ """Library containing special bots.""" # # (C) Rob W.W. Hooft, Andre Engels 2003-2004 -# (C) Pywikibot team, 2003-2019 +# (C) Pywikibot team, 2003-2020 # # Distributed under the terms of the MIT license. # @@ -423,8 +423,7 @@ pywikibot.output('Uploading file to {0}...'.format(site))
ignore_warnings = self.ignoreWarning is True or self._handle_warnings - if ('://' in file_url - and 'upload_by_url' not in site.userinfo['rights']): + if '://' in file_url and not site.has_right('upload_by_url'): file_url = self.read_file_content(file_url)
try: @@ -462,7 +461,7 @@ return
# early check that user has proper rights to upload - if 'upload' not in self.targetSite.userinfo['rights']: + if not self.targetSite.has_right('upload'): pywikibot.error( "User '%s' does not have upload rights on site %s." % (self.targetSite.user(), self.targetSite)) diff --git a/scripts/category.py b/scripts/category.py index 41c69a3..4897134 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -119,8 +119,8 @@ # (C) leogregianin, 2004-2008 # (C) Ben McIlwain (CydeWeys), 2006-2015 # (C) Anreas J Schwab, 2007 -# (C) xqt, 2009-2019 -# (C) Pywikibot team, 2008-2019 +# (C) xqt, 2009-2020 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # @@ -573,12 +573,9 @@ page don't exist. """ self.site = pywikibot.Site() - self.can_move_cats = ( - 'move-categorypages' in self.site.userinfo['rights']) - self.noredirect = ( - delete_oldcat - and 'suppressredirect' in self.site.userinfo['rights'] - ) + self.can_move_cats = self.site.has_right('move-categorypages') + self.noredirect = delete_oldcat \ + and self.site.has_right('suppressredirect') # Create attributes for the categories and their talk pages. self.oldcat = self._makecat(oldcat) self.oldtalk = self.oldcat.toggleTalkPage() diff --git a/scripts/redirect.py b/scripts/redirect.py index 7f576f8..41a159b3 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -427,8 +427,7 @@ @return: A valid speedy deletion template. @rtype: str or None """ - if self.getOption('delete') \ - and 'delete' not in self.site.userinfo['rights']: + if self.getOption('delete') and not self.site.has_right('delete'): sd = self.getOption('sdtemplate') if not sd and i18n.twhas_key(self.site, 'redirect-broken-redirect-template'): @@ -465,7 +464,7 @@ assert page.site == self.site, ( 'target page is on different site {0}'.format(page.site)) reason = i18n.twtranslate(self.site, summary_key) - if 'delete' in page.site.userinfo['rights']: + if page.site.has_right('delete'): page.delete(reason, prompt=False) elif self.sdtemplate: pywikibot.output('User does not have delete right, '
pywikibot-commits@lists.wikimedia.org