jenkins-bot has submitted this change and it was merged.
Change subject: Fix API write assert
......................................................................
Fix API write assert
Cyclic recusion was introduced in
I80971cde07651a042ef6472dc1a81cb4a1704742
Use _extensions instead of _siteinfo to determine whether to
check the list of extensions.
Also wrap clauses in brackets to dictate precedence of the
and/or operators.
Change-Id: I19858792673d2a22417f8cd41e2a2881a725b189
---
M pywikibot/data/api.py
1 file changed, 12 insertions(+), 8 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 30b8415..2bdb78a 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -144,18 +144,22 @@
)
# MediaWiki 1.23 allows assertion for any action,
# whereas earlier WMF wikis and others used an extension which
- # could only allow assert for action=edit. Do not look up
- # the extension info if the siteinfo has not been loaded,
- # otherwise cyclic recursion will occur.
-
- # Check siteinfo has not been loaded to avoid infinite loop
- if hasattr(self.site, "_siteinfo"):
+ # could only allow assert for action=edit.
+ #
+ # When we can't easily check whether the extension is loaded,
+ # to avoid cyclic recursion in the Pywikibot codebase, assume
+ # that it is present, which will cause a API warning emitted
+ # to the logging (console) if it is not present, but will not
+ # otherwise be a problem.
+ # This situation is only tripped when one of the first actions
+ # on the site is a write action and the extension isn't installed.
+ if hasattr(self.site, "_extensions"):
use_assert_edit_extension = self.site.hasExtension('AssertEdit', False)
else:
use_assert_edit_extension = True
- if (self.write and LV(self.site.version()) >= LV("1.23") or
- self.params["action"] == "edit" and use_assert_edit_extension):
+ if ((self.write and LV(self.site.version()) >= LV("1.23")) or
+ (self.params["action"] == "edit" and use_assert_edit_extension)):
pywikibot.debug(u"Adding user assertion", _logger)
self.params["assert"] = "user" # make sure user is logged in
--
To view, visit https://gerrit.wikimedia.org/r/153007
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I19858792673d2a22417f8cd41e2a2881a725b189
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove custom lunatic-python patches
......................................................................
Remove custom lunatic-python patches
Replace custom instructions in externals/README and remove custom
patch file externals/patch-lua as several github repos include that
change are a few are advanced well past that patch.
If a custom lua is required, it should be placed in externals as
'lua' so the pywikibot code finds it automatically without looking
for '_lua'.
Change-Id: I096e55da10323b1a77fcc9f822f77ba23610c563
---
M externals/README
D externals/patch-lua
M scripts/script_wui.py
3 files changed, 15 insertions(+), 162 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/externals/README b/externals/README
index 2e9b788..52cb293 100644
--- a/externals/README
+++ b/externals/README
@@ -1,33 +1,11 @@
-External dependencies for the rewrite branch. This package is only necessary to
-run pywikibot from a fully self-sufficient (no other dependencies other than
-python 2.6+) directory. This is especially useful on Windows.
+This package is only necessary to run pywikibot from a fully self-sufficient
+(no other dependencies other than python 2.6+) directory.
+This is especially useful on Windows.
Usually - under normal circumstances - these packages should be installed
separately elsewhere in the OS by the standard package managing system.
-If you want to run the rewrite as a stand-alone package, please also download
-the contents of the externals/ subdirectory. Furthermore this includes git
-repos and zip archives like:
+If you want to run the rewrite as a stand-alone package, you may download
+dependencies into the externals/ subdirectory, and they will automatically
+be used by the pwb.py script.
-* parse-crontab: Parse and use crontab schedules in Python - Version .14
- (from https://github.com/josiahcarlson/parse-crontab)
- 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 https://labix.org/lunatic-python)
- Download the zip archive and unpack the 'lunatic-python-1.0' dir into the
- path 'externals/_lua' afterwards.
- $ wget https://labix.org/download/lunatic-python/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
- and you are done.
- For the sake of completeness, the command invoked to create the patch was:
- $ diff -Naur lunatic-python-1.0 _lua > patch-lua
diff --git a/externals/patch-lua b/externals/patch-lua
deleted file mode 100644
index 22f1f6b..0000000
--- a/externals/patch-lua
+++ /dev/null
@@ -1,128 +0,0 @@
-diff -Naur lunatic-python-1.0/__init__.py _lua/__init__.py
---- lunatic-python-1.0/__init__.py 1970-01-01 01:00:00.000000000 +0100
-+++ _lua/__init__.py 2013-10-12 17:32:58.954669463 +0200
-@@ -0,0 +1,39 @@
-+# patches applied for compatibility with lua5.1:
-+# https://github.com/bastibe/lunatic-python/issues/1
-+# http://lua-users.org/wiki/LunaticPython
-+
-+import sys, os
-+
-+#scriptdir = os.path.dirname(sys.argv[0])
-+#if not os.path.isabs(scriptdir):
-+# scriptdir = os.path.abspath(os.path.join(os.curdir, scriptdir))
-+scriptdir = os.path.abspath(os.path.join(os.path.split(__file__)[0], '..', '..', 'scripts'))
-+
-+libdir = os.path.join(scriptdir, '../externals/_lua/build/lib.linux-x86_64-%s.%s' % sys.version_info[:2])
-+if not os.path.exists(libdir):
-+ os.makedirs(libdir)
-+# path has to exist BEFORE appending, otherwise the re-import fails
-+sys.path.append(libdir)
-+
-+try:
-+ # try to import
-+ from lua import *
-+except ImportError, e:
-+ print "(re-)compilation triggered because of: '%s'" % e
-+
-+ cur = os.path.abspath(os.curdir)
-+ os.chdir( os.path.join(scriptdir, '../externals/_lua') )
-+
-+ # remove/reset if existing already
-+ if os.path.exists(os.path.join(libdir, 'lua.so')):
-+ os.remove( os.path.join(libdir, 'lua.so') )
-+
-+ # compile python module (may be use 'distutil' instead of 'make' here)
-+ if os.system("python setup.py build"):
-+ #if os.system("make"):
-+ raise ImportError("'lua.so' could not be compiled!")
-+
-+ os.chdir( cur )
-+
-+ # re-try to import
-+ from lua import *
-diff -Naur lunatic-python-1.0/python.lua _lua/python.lua
---- lunatic-python-1.0/python.lua 2003-12-13 05:37:57.000000000 +0100
-+++ _lua/python.lua 2013-10-12 17:31:55.467702300 +0200
-@@ -1,6 +1,6 @@
- local path = os.getenv("LUA_SOPATH")
- if path then
-- func = loadlib(path.."/lua-python.so", "luaopen_python")
-+ func = package.loadlib(path.."/lua-python.so", "luaopen_python")
- if func then
- func()
- return
-@@ -10,7 +10,7 @@
- local loaded = false
- for i = 10, 2, -1 do
- for j = 10, 2, -1 do
-- func = loadlib(string.format(modmask, i, j), "luaopen_python")
-+ func = package.loadlib(string.format(modmask, i, j), "luaopen_python")
- if func then
- loaded = true
- func()
-diff -Naur lunatic-python-1.0/setup.py _lua/setup.py
---- lunatic-python-1.0/setup.py 2005-10-19 01:10:07.000000000 +0200
-+++ _lua/setup.py 2013-10-12 17:31:55.481702073 +0200
-@@ -1,7 +1,7 @@
- #!/usr/bin/python
- from distutils.core import setup, Extension
- from distutils.sysconfig import get_python_lib, get_python_version
--import os
-+import os, platform
-
- if os.path.isfile("MANIFEST"):
- os.unlink("MANIFEST")
-@@ -9,7 +9,13 @@
- # You may have to change these
- PYLIBS = ["python"+get_python_version(), "pthread", "util"]
- PYLIBDIR = [get_python_lib(standard_lib=True)+"/config"]
--LUALIBS = ["lua", "lualib"]
-+pltfrm = platform.platform().lower()
-+if 'ubuntu' in pltfrm:
-+ LUALIBS = ["lua5.1"]
-+elif 'fedora' in pltfrm:
-+ LUALIBS = ["lua"]
-+else:
-+ LUALIBS = ["lua5.1"]
- LUALIBDIR = []
-
- setup(name="lunatic-python",
-@@ -31,13 +37,13 @@
- ["src/pythoninlua.c", "src/luainpython.c"],
- library_dirs=PYLIBDIR,
- libraries=PYLIBS,
-- extra_compile_args=["-rdynamic"],
-+ extra_compile_args=["-rdynamic", "-I/usr/include/lua5.1"],
- extra_link_args=["-rdynamic"]),
- Extension("lua",
- ["src/pythoninlua.c", "src/luainpython.c"],
- library_dirs=LUALIBDIR,
- libraries=LUALIBS,
-- extra_compile_args=["-rdynamic"],
-+ extra_compile_args=["-rdynamic", "-I/usr/include/lua5.1"],
- extra_link_args=["-rdynamic"]),
- ],
- )
-diff -Naur lunatic-python-1.0/src/luainpython.c _lua/src/luainpython.c
---- lunatic-python-1.0/src/luainpython.c 2005-10-19 01:07:02.000000000 +0200
-+++ _lua/src/luainpython.c 2013-10-12 17:31:55.482702057 +0200
-@@ -488,12 +488,12 @@
-
- if (!L) {
- L = lua_open();
-- luaopen_base(L);
-- luaopen_table(L);
-- luaopen_io(L);
-- luaopen_string(L);
-- luaopen_debug(L);
-- luaopen_loadlib(L);
-+
-+ /* loading each lib separately has some deep conflict
-+ * with python's readline module so we obey the holy
-+ * docs by lua people and use the magic loader.
-+ */
-+ luaL_openlibs(L);
- luaopen_python(L);
- lua_settop(L, 0);
- }
diff --git a/scripts/script_wui.py b/scripts/script_wui.py
index 3bbe3fd..ab2a595 100755
--- a/scripts/script_wui.py
+++ b/scripts/script_wui.py
@@ -71,15 +71,18 @@
import resource
import re
-# https://labix.org/lunatic-python
-try:
- import lua # installed packages (on f15: 'lua', 'lunatic-python')
-except ImportError:
- import _lua as lua # compiled in externals with patch (ubuntu on TS/labs)
-# https://github.com/josiahcarlson/parse-crontab
+# https://labix.org/lunatic-python is bit-rotting, and there are maintained
+# versions on github:
+# https://github.com/bastibe/lunatic-python.git
+# https://github.com/AlereDevices/lunatic-python.git
+import lua
+# The crontab package is https://github.com/josiahcarlson/parse-crontab
+# version 0.20 installs a package called 'tests' which conflicts with our
+# test suite. Use https://github.com/jayvdb/parse-crontab until it is fixed.
import crontab
import pywikibot
+# pywikibot.botirc depends on https://pypi.python.org/pypi/irc
import pywikibot.botirc
--
To view, visit https://gerrit.wikimedia.org/r/150176
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I096e55da10323b1a77fcc9f822f77ba23610c563
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Execute user config in sandbox
......................................................................
Execute user config in sandbox
Give the user-config script a global environment which does not
have private methods or necessary imports, and copy only known
configuration items into the globals of the config module.
Change-Id: I4e31d05c1ff6f55f96e1ceffcddf06e54216c25b
---
M pywikibot/config2.py
1 file changed, 29 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 667a65c..4b31fc1 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -24,6 +24,8 @@
import os
import sys
+# Please keep _imported_modules in sync with the imports above
+_imported_modules = ('os', 'sys')
# IMPORTANT:
# Do not change any of the variables in this file. Instead, make
@@ -705,13 +707,25 @@
return path
# System-level and User-level changes.
# Store current variables and their types.
-_glv = {}
-_glv.update(globals())
+_glv = dict((_key, _val) for _key, _val in globals().items()
+ if _key[0] != '_' and _key not in _imported_modules)
_gl = list(_glv.keys())
_tp = {}
for _key in _gl:
if _key[0] != '_':
_tp[_key] = type(globals()[_key])
+
+# Create an environment for user-config.py which is
+# a shallow copy of the core config settings, so that
+# we can detect modified config items easily.
+_uc = {}
+for _key, _val in _glv.items():
+ if isinstance(_val, dict):
+ _uc[_key] = {}
+ if len(_val.keys()) > 0:
+ _uc[_key].update(_val)
+ else:
+ _uc[_key] = _val
# Get the user files
_thislevel = 0
@@ -728,7 +742,7 @@
_fileuid = _filestatus[4]
if sys.platform == 'win32' or _fileuid in [os.getuid(), 0]:
if sys.platform == 'win32' or _filemode & 0o02 == 0:
- exec(compile(open(_filename).read(), _filename, 'exec'))
+ exec(compile(open(_filename).read(), _filename, 'exec'), _uc)
else:
print("WARNING: Skipped '%(fn)s': writeable by others."
% {'fn': _filename})
@@ -737,8 +751,10 @@
% {'fn': _filename})
# Test for obsoleted and/or unknown variables.
-for _key, _val in list(globals().items()):
+for _key, _val in list(_uc.items()):
if _key.startswith('_'):
+ pass
+ elif _key in _imported_modules:
pass
elif _key in _gl:
nt = type(_val)
@@ -760,6 +776,14 @@
print("WARNING: "
"Configuration variable %(_key)r is defined but unknown.\n"
"Misspelled?" % locals())
+
+# Copy the user config settings into globals
+_modified = [_key for _key in _gl
+ if _uc[_key] != globals()[_key] or
+ _key in ('usernames', 'sysopnames', 'disambiguation_comment')]
+
+for _key in _modified:
+ globals()[_key] = _uc[_key]
# Fix up default console_encoding
if console_encoding is None:
@@ -799,7 +823,7 @@
if _name[0] != '_':
if not type(globals()[_name]) in [types.FunctionType,
types.ModuleType]:
- if _all or _glv[_name] != globals()[_name]:
+ if _all or _name in _modified:
_value = globals()[_name]
if _name in _private_values and _value:
if isinstance(_value, dict):
--
To view, visit https://gerrit.wikimedia.org/r/141467
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4e31d05c1ff6f55f96e1ceffcddf06e54216c25b
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Betacommand <betacommand(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: update 3 SourceForge bug ids to Bugzilla ones
......................................................................
update 3 SourceForge bug ids to Bugzilla ones
3 other bugs were closed on SourceForge without being imported
on Bugzilla:
- pywikibot/page.py:1840 bug #1795683
- pywikibot/textlib.py:221 bug #1731008
- scripts/interwiki.py:1900 bug #3081100
(maybe they should be removed from comments)
Change-Id: Iecba7695b828837fdd3c3e91beac8c815ef94825
---
M scripts/blockpageschecker.py
M scripts/cosmetic_changes.py
2 files changed, 3 insertions(+), 3 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index 2ffc1e8..c026b20 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -296,7 +296,7 @@
"""
# This check does not work :
# PreloadingGenerator cannot set correctly page.editRestriction
- # (see bug #1949476 )
+ # (see bug 55322)
if not page.canBeEdited():
pywikibot.output("%s is sysop-protected : this account can't edit "
"it! Skipping..." % pagename)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 831ad6b..a69c35d 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -344,7 +344,7 @@
assert u'Kép' in namespaces
namespaces.remove(u'Kép')
elif self.site.code == 'pt':
- # bug #3346901 should be implemented
+ # bug 55242 should be implemented
continue
# lowerspaced and underscored namespaces
for i in range(len(namespaces)):
@@ -773,7 +773,7 @@
text = pywikibot.replaceExcept(text, u'[ىي]', u'ی', exceptions)
return text
# replace persian/arabic digits
- ## deactivated due to bug #3539407
+ # deactivated due to bug 55185
for i in range(0, 10):
text = pywikibot.replaceExcept(text, old[i], new[i], exceptions)
# do not change digits in class, style and table params
--
To view, visit https://gerrit.wikimedia.org/r/151988
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iecba7695b828837fdd3c3e91beac8c815ef94825
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Support list of encodings for url2unicode.
......................................................................
Support list of encodings for url2unicode.
Decouples url2unicode from Site objects, so it
may be used in code where a Site is not relevant.
Change-Id: I9ca2a933d227afa79de8ce402304592682785d17
---
M pywikibot/page.py
M scripts/cosmetic_changes.py
2 files changed, 31 insertions(+), 18 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 7a0d1bd..623fb29 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3546,12 +3546,14 @@
else:
self._anchor = None
+ # Convert URL-encoded characters to unicode
+ encodings = [self._source.encoding()] + list(self._source.encodings())
+
+ self._text = url2unicode(self._text, encodings=encodings)
+
# Clean up the name, it can come from anywhere.
# Convert HTML entities to unicode
t = html2unicode(self._text)
-
- # Convert URL-encoded characters to unicode
- t = url2unicode(t, site=self._source)
# Normalize unicode string to a NFC (composed) format to allow
# proper string comparisons. According to
@@ -4040,21 +4042,31 @@
return x
-def url2unicode(title, site, site2=None):
- """Convert URL-encoded text to unicode using site's encoding.
-
- If site2 is provided, try its encodings as well. Uses the first encoding
- that doesn't cause an error.
-
+@deprecate_arg('site2', None)
+@deprecate_arg('site', 'encodings')
+def url2unicode(title, encodings='utf-8'):
"""
- # create a list of all possible encodings for both hint sites
- encList = [site.encoding()] + list(site.encodings())
- if site2 and site2 != site:
- encList.append(site2.encoding())
- encList += list(site2.encodings())
+ Convert URL-encoded text to unicode using several encoding.
+
+ Uses the first encoding that doesn't cause an error.
+
+ @param data: URL-encoded character data to convert
+ @type data: str
+ @param encodings: Encodings to attempt to use during conversion.
+ @type encodings: str, list or Site
+ @return: unicode
+
+ @exception UnicodeError: Could not convert using any encoding.
+ """
+ if isinstance(encodings, basestring):
+ encodings = [encodings]
+ elif isinstance(encodings, pywikibot.site.BaseSite):
+ # create a list of all possible encodings for both hint sites
+ site = encodings
+ encodings = [site.encoding()] + list(site.encodings())
+
firstException = None
- # try to handle all encodings (will probably retry utf-8)
- for enc in encList:
+ for enc in encodings:
try:
t = title.encode(enc)
t = unquote_to_bytes(t)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 34a2d4f..dcac72c 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -78,6 +78,7 @@
import pywikibot
import isbn
from pywikibot import config, i18n, pagegenerators, Bot
+from pywikibot.page import url2unicode
warning = """
ATTENTION: You can run this script as a stand-alone for testing purposes.
@@ -427,8 +428,8 @@
titleLength)
# Convert URL-encoded characters to unicode
- titleWithSection = pywikibot.url2unicode(titleWithSection,
- site=self.site)
+ titleWithSection = url2unicode(titleWithSection,
+ encodings=self.site)
if titleWithSection == '':
# just skip empty links.
--
To view, visit https://gerrit.wikimedia.org/r/150869
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ca2a933d227afa79de8ce402304592682785d17
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: use API assert for supported 'write' actions
......................................................................
use API assert for supported 'write' actions
For MediaWiki 1.23+ extend the existing assertion, that the bot is logged in,
to cover all write operations.
Also add check that the AssertEdit extension is present before asserting
for MediaWiki versions 1.14 to 1.22. Prior versions do not provide a
list of running extensions.
If the first operation to the site is a edit operation, before server
capabilities have been determined, do the assertion unconditionally
as the api module doesnt know check. If the server doesnt understand
the assert, it will issue a warning but others behave properly.
Bug: 55068
Change-Id: I80971cde07651a042ef6472dc1a81cb4a1704742
---
M pywikibot/data/api.py
1 file changed, 15 insertions(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 7102074..e25c996 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -26,6 +26,7 @@
import re
import traceback
import time
+from distutils.version import LooseVersion as LV
import pywikibot
from pywikibot import config, login
@@ -141,7 +142,20 @@
"wbremoveclaims", "wbsetclaimvalue", "wbsetreference",
"wbremovereferences"
)
- if self.params["action"] == "edit":
+ # MediaWiki 1.23 allows assertion for any action,
+ # whereas earlier WMF wikis and others used an extension which
+ # could only allow assert for action=edit. Do not look up
+ # the extension info if the siteinfo has not been loaded,
+ # otherwise cyclic recursion will occur.
+
+ # Check siteinfo has not been loaded to avoid infinite loop
+ if hasattr(self.site, "_siteinfo"):
+ use_assert_edit_extension = self.site.hasExtension('AssertEdit', False)
+ else:
+ use_assert_edit_extension = True
+
+ if (self.write and LV(self.site.version()) >= LV("1.23") or
+ self.params["action"] == "edit" and use_assert_edit_extension):
pywikibot.debug(u"Adding user assertion", _logger)
self.params["assert"] = "user" # make sure user is logged in
--
To view, visit https://gerrit.wikimedia.org/r/147837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I80971cde07651a042ef6472dc1a81cb4a1704742
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
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.
Change subject: Bug 68665-misspelling fails if site not configured
......................................................................
Bug 68665-misspelling fails if site not configured
Instead of failing, a message is presented to the user.
It has also fixed a bug in case family=commons, replacing site.lang with
site.code.
Change-Id: Ic1d2233d9983eb0875595f03f04bd5232e997e14
---
M scripts/misspelling.py
1 file changed, 18 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/misspelling.py b/scripts/misspelling.py
index 13f6b08..ec9644b 100644
--- a/scripts/misspelling.py
+++ b/scripts/misspelling.py
@@ -33,6 +33,15 @@
from pywikibot import i18n, pagegenerators
from solve_disambiguation import DisambiguationRobot
+HELP_MSG = """\n
+mispelling.py does not support site {site}.
+
+Help Pywikibot team to provide support for your wiki by submitting
+a bug to:
+ https://bugzilla.wikimedia.org/enter_bug.cgi?product=Pywikibot
+with category containing misspelling pages or a template for
+these misspellings.\n"""
+
class MisspellingRobot(DisambiguationRobot):
@@ -61,16 +70,15 @@
def createPageGenerator(self, firstPageTitle):
mysite = pywikibot.Site()
- mylang = mysite.lang
+ mylang = mysite.code
if mylang in self.misspellingCategory:
misspellingCategoryTitle = self.misspellingCategory[mylang]
misspellingCategory = pywikibot.Category(mysite,
misspellingCategoryTitle)
generator = pagegenerators.CategorizedPageGenerator(
misspellingCategory, recurse=True, start=firstPageTitle)
- else:
- misspellingTemplateName = 'Template:%s' \
- % self.misspellingTemplate[mylang]
+ elif mylang in self.misspellingTemplate:
+ misspellingTemplateName = 'Template:%s' % self.misspellingTemplate[mylang]
misspellingTemplate = pywikibot.Page(mysite,
misspellingTemplateName)
generator = pagegenerators.ReferringPageGenerator(
@@ -79,6 +87,12 @@
pywikibot.output(
u'-start parameter unsupported on this wiki because there '
u'is no category for misspellings.')
+ else:
+ pywikibot.output(HELP_MSG.format(site=mysite))
+
+ empty_gen = (i for i in [])
+ return empty_gen
+
preloadingGen = pagegenerators.PreloadingGenerator(generator)
return preloadingGen
--
To view, visit https://gerrit.wikimedia.org/r/152810
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1d2233d9983eb0875595f03f04bd5232e997e14
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>