jenkins-bot has submitted this change and it was merged.
Change subject: Support editing as a sysop ......................................................................
Support editing as a sysop
This patch makes all functions which are decorated with must_be('user') can perform with sysop account if the function is called with parameter as_group='sysop'
Bug: 58789 Change-Id: Ib8df98667b9457504f54de856aa4c4db0a997635 --- M pywikibot/site.py 1 file changed, 10 insertions(+), 9 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index 20ee4bb..e01efc5 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -701,22 +701,23 @@ will be ignored for now.
@param group: the group the logged in user should belong to + this parameter can be overridden by + keyword argument 'as_group' legal values: 'user' and 'sysop' - @param right: the rights the logged in user hsould have + @param right: the rights the logged in user should have not supported yet and thus ignored. @returns: a decorator to make sure the requirement is statisfied when the decorated function is called. """ - if group == 'user': - run = lambda self: self.login(False) - elif group == 'sysop': - run = lambda self: self.login(True) - else: - raise Exception("Not implemented") - def decorator(fn): def callee(self, *args, **kwargs): - run(self) + grp = kwargs.pop('as_group', group) + if grp == 'user': + self.login(False) + elif grp == 'sysop': + self.login(True) + else: + raise Exception("Not implemented") return fn(self, *args, **kwargs) callee.__name__ = fn.__name__ callee.__doc__ = fn.__doc__
pywikibot-commits@lists.wikimedia.org