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
jenkins-bot has submitted this change and it was merged.
Change subject: pep8-ified config2.py
......................................................................
pep8-ified config2.py
Note: test for variables was adapted slightly to prevent
E721 / do not compare types, use ‘isinstance()’ from triggering.
Instead of comparing the old type with type(None), the old *value*
is compared to None instead. This is also a nicer check conceptually.
Change-Id: Ibdfc17e86814a905e212bd454deba36c7995df4f
---
M pywikibot/config2.py
1 file changed, 21 insertions(+), 14 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index d6ad0bd..8fec8c0 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -7,8 +7,9 @@
#
__version__ = '$Id$'
-import os, re
+import os
import sys as __sys
+import re
import platform
# IMPORTANT:
@@ -72,8 +73,8 @@
#
# Security Connection for Wikimedia Projects
#
-use_SSL_onlogin = False # if available, use SSL when logging in
-use_SSL_always = False # if available, use SSL for all API queries
+use_SSL_onlogin = False # if available, use SSL when logging in
+use_SSL_always = False # if available, use SSL for all API queries
# Available security projects
available_ssl_project = [
@@ -92,6 +93,7 @@
# WARNING: this should NEVER be used in practice, ALWAYS supply a more
# relevant summary for bot edits
default_edit_summary = u'Wikipedia python library v.2'
+
# Get the names of all known families, and initialize
# with empty dictionaries
@@ -127,7 +129,7 @@
elif _win_version == 6:
base_dir = os.path.join(home, "AppData\\Roaming", NAME)
else:
- base_dir = os.path.join(home, "."+NAME)
+ base_dir = os.path.join(home, "." + NAME)
if not os.path.isdir(base_dir):
os.makedirs(base_dir, mode=0700)
if not os.path.isabs(base_dir):
@@ -144,9 +146,9 @@
_base_dir = _get_base_dir()
# families/ is a subdirectory of the directory in which config.py is found
for _filename in os.listdir(
- os.path.join(os.path.dirname(__file__), 'families')):
+ os.path.join(os.path.dirname(__file__), 'families')):
if _filename.endswith("_family.py"):
- familyName = _filename[ : -len("_family.py")]
+ familyName = _filename[:-len("_family.py")]
usernames[familyName] = {}
sysopnames[familyName] = {}
disambiguation_comment[familyName] = {}
@@ -180,8 +182,8 @@
# transliteration_target = console_encoding
# After emitting the warning, this last option will be set.
-transliteration_target = 'not set'
-
+transliteration_target = 'not set'
+
# The encoding in which textfiles are stored, which contain lists of page
# titles. The most used is: 'utf-8'. 'utf-8-sig' recognizes BOM but it is
# available on Python 2.5 or higher. For a complete list please see:
@@ -591,6 +593,7 @@
# End of configuration section
# ============================
+
def makepath(path):
"""Return a normalized absolute version of the path argument.
@@ -610,6 +613,7 @@
os.makedirs(dpath)
return os.path.normpath(os.path.abspath(path))
+
def datafilepath(*filename):
"""Return an absolute path to a data file in a standard location.
@@ -621,11 +625,12 @@
import os.path
return makepath(os.path.join(base_dir, *filename))
+
def shortpath(path):
"""Return a file path relative to config.base_dir."""
import os.path
if path.startswith(base_dir):
- return path[len(base_dir) + len(os.path.sep) : ]
+ return path[len(base_dir) + len(os.path.sep):]
return path
# System-level and User-level changes.
# Store current variables and their types.
@@ -651,10 +656,10 @@
execfile(_filename)
else:
print "WARNING: Skipped '%(fn)s': writeable by others."\
- % {'fn' :_filename}
+ % {'fn': _filename}
else:
print "WARNING: Skipped '%(fn)s': owned by someone else."\
- % {'fn' :_filename}
+ % {'fn': _filename}
# Test for obsoleted and/or unknown variables.
for _key, _val in globals().items():
@@ -663,7 +668,9 @@
elif _key in _gl:
nt = type(_val)
ot = _tp[_key]
- if nt == ot or _val is None or ot == type(None):
+ ov = _glv[_key]
+
+ if nt == ot or _val is None or ov is None: # nopep8
pass
elif nt is int and (ot is float or ot is bool):
pass
@@ -695,8 +702,8 @@
else:
transliteration_target = None
elif transliteration_target in ('None', 'none'):
- transliteration_target = None
-
+ transliteration_target = None
+
# Save base_dir for use by other modules
base_dir = _base_dir
--
To view, visit https://gerrit.wikimedia.org/r/79587
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibdfc17e86814a905e212bd454deba36c7995df4f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot