jenkins-bot has submitted this change and it was merged.
Change subject: Revert "Finish implementation of must_be decorator"
......................................................................
Revert "Finish implementation of must_be decorator"
Russblau reported that something broke with this and
prevented his bot from editing. Reverting until we can
debug and figure out what went wrong.
This reverts commit 650ea9d2c319d5a58b708c87ad9048ad84491240.
Change-Id: I80dd97a75b909f9d2db2485f3681af444ebcd9b9
---
M pywikibot/site.py
1 file changed, 18 insertions(+), 38 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 943e82b..bca3feb 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -637,43 +637,28 @@
def globalusers_address(self, target='', limit=500, offset='', group=''):
raise NotImplementedError
-
def must_be(group=None,right=None):
+ """ Decorator to require a certain user status. For now, only the values
+ group = 'user' and group = 'sysop' are supported. The right property
+ will be ignored for now.
+
+ @param group: the group the logged in user should belong to
+ legal values: 'user' and 'sysop'
+ @param right: the rights the logged in user hsould have
+ not supported yet and thus ignored.
+ @returns: a decorator to make sure the requirement is statisfied when
+ the decorated function is called.
"""
- Decorator to require a certain user status.
- You can use the group and right independently or together.
- Example:
- @must_be(group='user', right='edit)
- def edit_page(...):
-
- @param group: any arbitrary group the user should belong to
- @param right: the rights the logged in user should have.
- @return: a decorator to make sure the requirement is statisfied when
- the decorated function is called.
- """
-
- if group:
- if group == 'user':
- grp = lambda self: self.login(False)
- elif group == 'sysop':
- grp = lambda self: self.login(True)
- else:
- grp = lambda self: self.has_group(group)
+ if group == 'user':
+ run = lambda self: self.login(False)
+ elif group == 'sysop':
+ run = lambda self: self.login(True)
else:
- grp = lambda self: True # No group provided
-
- if right:
- rht = lambda self: self.has_right(group)
- else:
- rht = lambda self: True # No right provided
-
- run = lambda self: grp(self) and rht(self)
+ raise Exception("Not implemented")
def decorator(fn):
def callee(self, *args, **kwargs):
- ok = run(self)
- if not ok:
- raise NoUsername('') # FIXME: Pick a better error
+ run(self)
return fn(self, *args, **kwargs)
callee.__name__ = fn.__name__
callee.__doc__ = fn.__doc__
@@ -848,11 +833,6 @@
self._loginstatus = LoginStatus.NOT_LOGGED_IN # failure
if not hasattr(self, "_siteinfo"):
self._getsiteinfo()
-
- if sysop:
- return self._loginstatus == LoginStatus.AS_SYSOP
- else:
- return self._loginstatus == LoginStatus.AS_USER
forceLogin = login # alias for backward-compatibility
@@ -2563,7 +2543,7 @@
"editconflict": "Page %(title)s not saved due to edit conflict.",
}
- @must_be(group='user', right='edit')
+ @must_be(group='user')
def editpage(self, page, summary, minor=True, notminor=False,
bot=True, recreate=True, createonly=False, watch=None):
"""Submit an edited Page object to be saved to the wiki.
@@ -2921,7 +2901,7 @@
#TODO: implement patrol
- @must_be(right='block')
+ @must_be(group='sysop')
def blockuser(self, user, expiry, reason, anononly=True, nocreate=True, autoblock=True,
noemail=False, reblock=False):
--
To view, visit https://gerrit.wikimedia.org/r/80173
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I80dd97a75b909f9d2db2485f3681af444ebcd9b9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Merlijn van Deen has submitted this change and it was merged.
Change subject: Making SSL connection true as default per disabling http for logged in users in 21 August
......................................................................
Making SSL connection true as default per disabling http for logged in users in 21 August
Change-Id: I856ac9eac7261912eb6778ed7e04c1c7771f9981
---
M family.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
diff --git a/family.py b/family.py
index 871519d..255cc3d 100644
--- a/family.py
+++ b/family.py
@@ -4726,3 +4726,6 @@
def shared_image_repository(self, code):
return ('commons', 'commons')
+
+ def protocol(self, code):
+ return 'https'
--
To view, visit https://gerrit.wikimedia.org/r/80003
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I856ac9eac7261912eb6778ed7e04c1c7771f9981
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Merlijn van Deen has submitted this change and it was merged.
Change subject: Making SSL connection true as default per disabling http for logged in users in 21 August
......................................................................
Making SSL connection true as default per disabling http for logged in users in 21 August
Change-Id: I7a95c627970ba7a691cde899b650291db3c21947
---
M pywikibot/family.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index dcd04dc..46a40c1 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -941,3 +941,6 @@
def shared_image_repository(self, code):
return ('commons', 'commons')
+
+ def protocol(self, code):
+ return 'https'
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/80006
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7a95c627970ba7a691cde899b650291db3c21947
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
DrTrigon has submitted this change and it was merged.
Change subject: minor docu fix and enhanced some parts
......................................................................
minor docu fix and enhanced some parts
Change-Id: Ia2fed28377a4867120c03cdd5795581258ddf77d
---
M externals/README
1 file changed, 8 insertions(+), 3 deletions(-)
Approvals:
DrTrigon: Verified; Looks good to me, approved
diff --git a/externals/README b/externals/README
index aa1a445..4ca2ba0 100644
--- a/externals/README
+++ b/externals/README
@@ -11,15 +11,20 @@
* parse-crontab: Parse and use crontab schedules in Python - Version .14
(from https://github.com/josiahcarlson/parse-crontab)
- Checkout the gip repository and copy the 'crontab' dir into the path
- 'externals/crontab' afterwards.
+ Checkout the git repository and copy the 'crontab' dir into the path
+ 'externals/crontab' afterwards. Or download the zip archive and unpack the
+ 'parse-crontab-master/crontab' dir into the path 'externals/crontab'.
+ $ wget https://github.com/josiahcarlson/parse-crontab/archive/master.zip
+ $ unzip master.zip
+ $ mv parse-crontab-master/crontab crontab
+ $ rm -rf parse-crontab-master
* lunatic-python: Two-way bridge between Python and Lua - Version 1.0
(from http://labix.org/lunatic-python)
Download the zip archive and unpack the 'lunatic-python-1.0' dir into the
path 'externals/_lua' afterwards.
$ wget http://labix.org/download/lunatic-python/lunatic-python-1.0.tar.bz2
- $ tar -xvf lunatic-python-1.0.tar.bz2
+ $ tar -xvf lunatic-python-1.0.tar.bz2
$ mv lunatic-python-1.0 _lua
Patch package dir in order to work with newer lua (>= 5.1) versions
$ patch -p1 -d [path-to-install-dir]/_lua < [path-to-externals]/patch-lua
--
To view, visit https://gerrit.wikimedia.org/r/79819
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2fed28377a4867120c03cdd5795581258ddf77d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
jenkins-bot has submitted this change and it was merged.
Change subject: Finish implementation of must_be decorator
......................................................................
Finish implementation of must_be decorator
Converted a few uses to use the proper userright, which eventually
all uses should use instead of a specific group
Change-Id: Ic7196732b0841a5c3a956fa0c7a2b558eba16371
---
M pywikibot/site.py
1 file changed, 38 insertions(+), 18 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index bca3feb..943e82b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -637,28 +637,43 @@
def globalusers_address(self, target='', limit=500, offset='', group=''):
raise NotImplementedError
-def must_be(group=None,right=None):
- """ Decorator to require a certain user status. For now, only the values
- group = 'user' and group = 'sysop' are supported. The right property
- will be ignored for now.
- @param group: the group the logged in user should belong to
- legal values: 'user' and 'sysop'
- @param right: the rights the logged in user hsould have
- not supported yet and thus ignored.
- @returns: a decorator to make sure the requirement is statisfied when
- the decorated function is called.
+def must_be(group=None,right=None):
"""
- if group == 'user':
- run = lambda self: self.login(False)
- elif group == 'sysop':
- run = lambda self: self.login(True)
+ Decorator to require a certain user status.
+ You can use the group and right independently or together.
+ Example:
+ @must_be(group='user', right='edit)
+ def edit_page(...):
+
+ @param group: any arbitrary group the user should belong to
+ @param right: the rights the logged in user should have.
+ @return: a decorator to make sure the requirement is statisfied when
+ the decorated function is called.
+ """
+
+ if group:
+ if group == 'user':
+ grp = lambda self: self.login(False)
+ elif group == 'sysop':
+ grp = lambda self: self.login(True)
+ else:
+ grp = lambda self: self.has_group(group)
else:
- raise Exception("Not implemented")
+ grp = lambda self: True # No group provided
+
+ if right:
+ rht = lambda self: self.has_right(group)
+ else:
+ rht = lambda self: True # No right provided
+
+ run = lambda self: grp(self) and rht(self)
def decorator(fn):
def callee(self, *args, **kwargs):
- run(self)
+ ok = run(self)
+ if not ok:
+ raise NoUsername('') # FIXME: Pick a better error
return fn(self, *args, **kwargs)
callee.__name__ = fn.__name__
callee.__doc__ = fn.__doc__
@@ -833,6 +848,11 @@
self._loginstatus = LoginStatus.NOT_LOGGED_IN # failure
if not hasattr(self, "_siteinfo"):
self._getsiteinfo()
+
+ if sysop:
+ return self._loginstatus == LoginStatus.AS_SYSOP
+ else:
+ return self._loginstatus == LoginStatus.AS_USER
forceLogin = login # alias for backward-compatibility
@@ -2543,7 +2563,7 @@
"editconflict": "Page %(title)s not saved due to edit conflict.",
}
- @must_be(group='user')
+ @must_be(group='user', right='edit')
def editpage(self, page, summary, minor=True, notminor=False,
bot=True, recreate=True, createonly=False, watch=None):
"""Submit an edited Page object to be saved to the wiki.
@@ -2901,7 +2921,7 @@
#TODO: implement patrol
- @must_be(group='sysop')
+ @must_be(right='block')
def blockuser(self, user, expiry, reason, anononly=True, nocreate=True, autoblock=True,
noemail=False, reblock=False):
--
To view, visit https://gerrit.wikimedia.org/r/79557
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7196732b0841a5c3a956fa0c7a2b558eba16371
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot