jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/419978 )
Change subject: docs/conf.py: Configure autodoc to document special methods by default
......................................................................
docs/conf.py: Configure autodoc to document special methods by default
Fix an indentation error in proofreadpage.IndexPage.__init__.
Bug: T130625
Change-Id: Iee2ac65e23f6f60f10374d2aac79a683b9a3bd9b
---
M docs/conf.py
M pywikibot/proofreadpage.py
2 files changed, 9 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 7e4d876..d416a40 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -290,3 +290,7 @@
pywikibot_env()
+
+autodoc_default_flags = [
+ 'special-members',
+]
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 184b3cc..5b36e5b 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -666,11 +666,11 @@
In this class:
page number is the number in the page title in the Page namespace, if
- the wikisource site adopts this convention (e.g. page_number is 12
- for Page:Popular Science Monthly Volume 1.djvu/12) or the sequential
- number of the pages linked from the index section in the Index page
- if the index is built via transclusion of a list of pages (e.g. like
- on de wikisource).
+ the wikisource site adopts this convention (e.g. page_number is 12
+ for Page:Popular Science Monthly Volume 1.djvu/12) or the sequential
+ number of the pages linked from the index section in the Index page
+ if the index is built via transclusion of a list of pages (e.g. like
+ on de wikisource).
page label is the label associated with a page in the Index page.
This class provides methods to get pages contained in Index page,
--
To view, visit https://gerrit.wikimedia.org/r/419978
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iee2ac65e23f6f60f10374d2aac79a683b9a3bd9b
Gerrit-Change-Number: 419978
Gerrit-PatchSet: 2
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/274977 )
Change subject: [bugfix] Enable total parameter for site.watched_pages
......................................................................
[bugfix] Enable total parameter for site.watched_pages
- enable total parameter to limit the total number of items of that generator
- Also deprecate special_page_limit: special_page_limit was introduced in
compat for retrieving pages from mw special list via screen scraping.
The use of this parameter in compat is a mess but in core it is not used
except in watched_pages. api may read all items except a total parameter
for a generator or treat counter restricts it.
Bug: T187881
Change-Id: Idd0afa55cec93b92abbd5f0a9d2d0b9317a9a42a
---
M pywikibot/config2.py
M pywikibot/site.py
2 files changed, 11 insertions(+), 9 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 257b3ee..2ae9a8c 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -95,7 +95,8 @@
_private_values = ['authenticate', 'proxy', 'db_password']
_deprecated_variables = ['use_SSL_onlogin', 'use_SSL_always',
- 'available_ssl_project', 'fake_user_agent']
+ 'available_ssl_project', 'fake_user_agent',
+ 'special_page_limit']
# ############# ACCOUNT SETTINGS ##############
@@ -646,11 +647,6 @@
# at least 1 second.
maxlag = 5
-# Maximum of pages which can be retrieved by special pages. Increase this if
-# you heavily use redirect.py with action "double", and especially if you're
-# running solve_disambiguation.py with the -primary argument.
-special_page_limit = 500
-
# Maximum of pages which can be retrieved at one time from wiki server.
# -1 indicates limit by api restriction
step = -1
@@ -893,6 +889,10 @@
'reviewer': u'', # If so, under what reviewer name?
}
+special_page_limit = 500
+
+# #############################################
+
def makepath(path):
"""Return a normalized absolute version of the path argument.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ad28b7a..9d71e1d 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7306,15 +7306,17 @@
@type sysop: bool
@param force_reload: Reload watchlist
@type force_reload: bool
+ @param total: if not None, limit the generator to yielding this many
+ items in total
+ @type total: int
@return: list of pages in watchlist
@rtype: list of pywikibot.Page objects
"""
self.login(sysop=sysop)
- if not total:
- total = pywikibot.config.special_page_limit
expiry = None if force else pywikibot.config.API_config_expiry
gen = api.PageGenerator(site=self, generator='watchlistraw',
- expiry=expiry, gwrlimit=total)
+ expiry=expiry)
+ gen.set_maximum_items(total)
return gen
# aliases for backwards compatibility
--
To view, visit https://gerrit.wikimedia.org/r/274977
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd0afa55cec93b92abbd5f0a9d2d0b9317a9a42a
Gerrit-Change-Number: 274977
Gerrit-PatchSet: 15
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/405583 )
Change subject: [IMPR] Simplify invalid title parsing
......................................................................
[IMPR] Simplify invalid title parsing
This is an alternate implementation of
https://gerrit.wikimedia.org/r/#/c/403957/
Change-Id: Ia2456e721472f9bb0386ab15ab1859aa54e63915
---
M pywikibot/page.py
1 file changed, 3 insertions(+), 5 deletions(-)
Approvals:
Dvorapa: Looks good to me, but someone else must approve
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 12ccea5..6cff93b 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -5569,13 +5569,11 @@
# * with 'relative' URLs. Forbid them explicitly.
if u'.' in t and (
- t == u'.' or t == u'..' or
- t.startswith(u'./') or
- t.startswith(u'../') or
+ t in ('.', '..') or
+ t.startswith(('./', '../')) or
u'/./' in t or
u'/../' in t or
- t.endswith(u'/.') or
- t.endswith(u'/..')
+ t.endswith(('/.', '/..'))
):
raise pywikibot.InvalidTitle(
u"(contains . / combinations): '%s'"
--
To view, visit https://gerrit.wikimedia.org/r/405583
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2456e721472f9bb0386ab15ab1859aa54e63915
Gerrit-Change-Number: 405583
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/418713 )
Change subject: tests/utils.py: Do not modify system language settings
......................................................................
tests/utils.py: Do not modify system language settings
Do not change system wide settings via `control.exe intl.cpl` call.
(T189288)
This reverts changes of 07f3f168263b6ed2591e6db7a3898ddec2de3f21 in
utils.py and config2.py. Only keeping the change of 'azb' to 'nn' in
i18n_tests.py.
To change config.userinterface_lang in subprocesses use
PYWIKIBOT_USERINTERFACE_LANG environment variable.
Bug: T189288
Bug: T189280
Bug: T128991
Change-Id: I8cf2d524963dc570ae03ed0d59af924f8fd86a3e
---
M pywikibot/config2.py
M tests/i18n_tests.py
M tests/utils.py
3 files changed, 9 insertions(+), 183 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 1b42234..257b3ee 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1081,8 +1081,6 @@
_modified = [_key for _key in _gl
if _uc[_key] != globals()[_key] or
_key in ('usernames', 'sysopnames', 'disambiguation_comment')]
-# Retain the list of modified key names
-__modified__ = _modified
if ('user_agent_format' in _modified):
_right_user_agent_format = re.sub(r'{httplib2(:|})', r'{http_backend\1',
@@ -1125,7 +1123,8 @@
'path delimiter.')
if userinterface_lang is None:
- userinterface_lang = getdefaultlocale()[0]
+ userinterface_lang = os.getenv('PYWIKIBOT_USERINTERFACE_LANG') \
+ or getdefaultlocale()[0]
if userinterface_lang in [None, 'C']:
userinterface_lang = 'en'
else:
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 8b05058..6454bb8 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -368,10 +368,6 @@
@classmethod
def setUpClass(cls):
"""Verify that a translation does not yet exist."""
- if 'userinterface_lang' in pywikibot.config.__modified__:
- raise unittest.SkipTest(
- 'user-config has a modified userinterface_lang')
-
super(InputTestCase, cls).setUpClass()
if cls.code in i18n.twget_keys(cls.message):
@@ -380,13 +376,10 @@
% (cls.code, cls.message))
def test_pagegen_i18n_input(self):
- """Test i18n.input fallback via pwb and LC_ALL."""
+ """Test i18n.input fallback via pwb."""
expect = i18n.twtranslate(self.alt_code, self.message, fallback=False)
-
result = self._execute(args=['listpages', '-cat'],
- data_in='non-existant-category\r\n',
- timeout=20)
-
+ data_in='non-existant-category\r\n')
self.assertIn(expect, result['stderr'])
diff --git a/tests/utils.py b/tests/utils.py
index 8ebce88..129f0eb 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -9,12 +9,10 @@
import inspect
import json
-import locale
import os
import re
import subprocess
import sys
-import tempfile
import time
import traceback
import warnings
@@ -44,25 +42,11 @@
from tests import _pwb_py
from tests import unittest
-from tests import unittest_print
OSWIN32 = (sys.platform == 'win32')
PYTHON_26_CRYPTO_WARN = ('Python 2.6 is no longer supported by the Python core '
'team, please upgrade your Python.')
-
-WIN32_LOCALE_UPDATE = """
-<gs:GlobalizationServices xmlns:gs="urn:longhornGlobalizationUnattend">
- <gs:UserList>
- <gs:User UserID="Current" CopySettingsToDefaultUserAcct="true"
- CopySettingsToSystemAcct="true"/>
- </gs:UserList>
-
- <gs:UserLocale>
- <gs:Locale Name="%s" SetAsCurrent="true" ResetAllSettings="false"/>
- </gs:UserLocale>
-</gs:GlobalizationServices>
-"""
class DrySiteNote(RuntimeWarning):
@@ -650,132 +634,6 @@
self._module.http = self._old_http
-def is_simple_locale_with_region(locale):
- """Check if a locale is only an ISO and region code."""
- # Some locale are unicode names, which are not valid
- try:
- lang, sep, qualifier = locale.partition('_')
- except UnicodeDecodeError:
- return False
- if '-' in lang:
- return False
- # Only allow qualifiers that look like a country code, without any suffix
- if qualifier and len(qualifier) == 2:
- return True
- else:
- return False
-
-
-def get_simple_locales():
- """Get list of simple locales."""
- return [locale_code for locale_code in sorted(locale.locale_alias.keys())
- if is_simple_locale_with_region(locale_code)]
-
-
-def generate_locale(lang, region=True, encoding='utf8'):
- """
- Generate a locale string.
-
- @param lang: language code
- @type lang: str
- @param region: region code; if True, a random one will be used
- @type region: str or True
- @param encoding: encoding name
- @type encoding: str
- @rtype: str
- """
- locale_prefix = lang + '_'
-
- if region is True:
- locales = get_simple_locales()
-
- lang_locales = [code for code in locales
- if code.startswith(locale_prefix)]
- assert(lang_locales)
-
- # Get a region from the first locale
- lang, sep, region = lang_locales[0].partition('_')
- assert lang and sep and region
-
- if region:
- locale_code = locale_prefix + region.upper()
- else:
- locale_code = lang
-
- if encoding:
- locale_code += '.' + encoding
-
- return locale_code
-
-
-def execute_with_temp_text_file(text, command, **kwargs):
- """
- Perform command on a temporary file.
-
- @param text: contents of temporary file
- @type text: str
- @param command: command to execute with {0} replaced with the filename
- @type command: str
- @param kwargs: parameters for tempfile.mkstemp/tempfile.NamedTemporaryFile,
- such as prefix, suffix and dir
- """
- options = {
- 'shell': True,
- 'stdout': subprocess.PIPE,
- 'stderr': subprocess.STDOUT,
- }
-
- # NamedTemporaryFile does not work correctly with win32_set_global_locale
- # subprocess.Popen is a context handler in Python 3.2+
- if OSWIN32 or PY2:
- (fd, filename) = tempfile.mkstemp(text=True, **kwargs)
- try:
- os.close(fd)
- with open(filename, 'wt') as f:
- f.write(text)
-
- command = command.format(filename)
-
- p = subprocess.Popen(command, **options)
- out = p.communicate()[0]
-
- # Python 2 raises an exception when attempting to close the process
- # Python 3 does not allow the file to be removed until the process
- # has been closed
- if not PY2:
- p.terminate()
- finally:
- try:
- os.remove(filename)
- except OSError:
- # As it is a temporary file, the OS should clean it up
- unittest_print('Could not delete {0}'.format(filename))
- else:
- with tempfile.NamedTemporaryFile(mode='w+t', **kwargs) as f:
- f.write(text)
- f.flush()
- command = command.format(f.name)
- with subprocess.Popen(command, **options) as p:
- out = p.communicate()[0]
-
- if out:
- unittest_print('command "{0}" output: {1}'.format(command, out))
-
-
-def win32_set_global_locale(locale_code):
- """Set global locale on win32."""
- locale_code = locale_code.split('.')[0]
- win_locale_code = locale_code.replace('_', '-')
- locale_update_xml = WIN32_LOCALE_UPDATE % win_locale_code
- command = 'control.exe intl.cpl,,/f:"{0}"'
- execute_with_temp_text_file(locale_update_xml, command, suffix='.xml')
-
- actual_code = locale.getdefaultlocale()[0]
- assert locale_code == actual_code, \
- ('locale code {0} not set; actual code is {1}'
- .format(locale_code, actual_code))
-
-
def execute(command, data_in=None, timeout=0, error=None):
"""
Execute a command and capture outputs.
@@ -812,31 +670,11 @@
env[str('PYTHONPATH')] = pythonpath
env[str('PYTHONIOENCODING')] = str(config.console_encoding)
- # LC_ALL is used by i18n.input as an alternative for userinterface_lang
- # A complete locale string needs to be created, so the country code
- # is guessed, however it is discarded when loading config.
- if config.userinterface_lang:
- current_locale = locale.getdefaultlocale()[0]
- if current_locale in [None, 'C']:
- current_locale = 'en'
- else:
- current_locale = current_locale.split('.')[0]
- locale_prefix = str(config.userinterface_lang + '_')
-
- if not current_locale.startswith(locale_prefix):
- locale_code = generate_locale(
- config.userinterface_lang,
- encoding=config.console_encoding)
-
- env[str('LC_ALL')] = str(locale_code)
-
- if OSWIN32:
- # This is not multiprocessing safe, as it affects all processes
- win32_set_global_locale(locale_code)
- else:
- current_locale = None
- else:
- current_locale = None
+ # PYWIKIBOT_USERINTERFACE_LANG will be assigned to
+ # config.userinterface_lang
+ if pywikibot.config.userinterface_lang:
+ env[str('PYWIKIBOT_USERINTERFACE_LANG')] = \
+ str(pywikibot.config.userinterface_lang)
# Set EDITOR to an executable that ignores all arguments and does nothing.
env[str('EDITOR')] = str('call' if OSWIN32 else 'true')
@@ -894,10 +732,6 @@
stderr_lines += p.stderr.read()
data_out = p.communicate()
-
- if OSWIN32 and current_locale:
- win32_set_global_locale(current_locale)
-
return {'exit_code': p.returncode,
'stdout': data_out[0].decode(config.console_encoding),
'stderr': (stderr_lines + data_out[1]).decode(config.console_encoding)}
--
To view, visit https://gerrit.wikimedia.org/r/418713
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I8cf2d524963dc570ae03ed0d59af924f8fd86a3e
Gerrit-Change-Number: 418713
Gerrit-PatchSet: 2
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>