jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693849 )
Change subject: Append a newline to context before question
......................................................................
Append a newline to context before question
Without it, the context output glued with the options.
See T283488 ("* [[Mark Twain]] (1835−1910Option (<number> [1-19]").
Change-Id: Ibcf9146a1dc6dc3723cc977af8c189e95eb774e2
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index ceace54..c4abe8b 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -401,7 +401,7 @@
for option in options:
if isinstance(option, OutputOption) \
and option.before_question:
- self.stream_output(option.out)
+ self.stream_output(option.out + '\n')
output = Option.formatted(question, options, default)
if force:
self.stream_output(output + '\n')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693849
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibcf9146a1dc6dc3723cc977af8c189e95eb774e2
Gerrit-Change-Number: 693849
Gerrit-PatchSet: 1
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693649 )
Change subject: [doc] Update documentation
......................................................................
[doc] Update documentation
* mediawiki --> MediaWiki
* Update redirected URLs
Change-Id: Ifc0fbd3f147cf1bcb6abd8c0f70126ea464b7f24
---
M pywikibot/data/api.py
M pywikibot/diff.py
M scripts/archivebot.py
M tests/date_tests.py
4 files changed, 4 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 733ef13..4974223 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2283,7 +2283,7 @@
* list=alldeletedrevisions
More info:
- https://lists.wikimedia.org/pipermail/mediawiki-api-announce/2018-August/00…
+ https://lists.wikimedia.org/hyperkitty/list/mediawiki-api-announce@lists.wi…
"""
if self.site.mw_version < '1.32':
return
diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index 13eea46..366b268 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -584,7 +584,7 @@
Site.compare() returns HTML that is useful for displaying on a page.
Here we use BeautifulSoup to get the un-HTML-ify the context of changes.
Finally we present the added and deleted contexts.
- @param compare_string: HTML string from mediawiki API
+ @param compare_string: HTML string from MediaWiki API
@return: deleted and added list of contexts
"""
from bs4 import BeautifulSoup
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 7de2476..f3c2370 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -73,7 +73,7 @@
of the year. So up to three days are still counted as the year before.
See also:
- - http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ - https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm
- https://docs.python.org/3.4/library/datetime.html#datetime.date.isocalendar
Options (may be omitted):
diff --git a/tests/date_tests.py b/tests/date_tests.py
index 3facf6d..d76989f 100644
--- a/tests/date_tests.py
+++ b/tests/date_tests.py
@@ -66,7 +66,7 @@
net = True
def test_month_name_formats(self):
- """Test MonthName format for codes retrieved via mediawiki message."""
+ """Test MonthName format for codes retrieved via MediaWiki message."""
formatname = 'MonthName'
for code in date.formats['Cat_BirthsAD']:
convert = date.formats[formatname][code]
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693649
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ifc0fbd3f147cf1bcb6abd8c0f70126ea464b7f24
Gerrit-Change-Number: 693649
Gerrit-PatchSet: 3
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693512 )
Change subject: [cleanup] Disallow non-numeric i18n count
......................................................................
[cleanup] Disallow non-numeric i18n count
When 'num' was a string representation of a number rather than an int we issued
a deprecation warning. Time to enforce it.
Change-Id: Ie7b491674a44ca9f8b42942441d0c49af2b5ba29
---
M pywikibot/i18n.py
1 file changed, 2 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 5399c85..5eaf720 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -38,7 +38,6 @@
ModuleDeprecationWrapper,
deprecated,
deprecated_args,
- issue_deprecation_warning,
)
@@ -441,12 +440,8 @@
variants = match.group(2)
num = parameters[selector]
if not isinstance(num, int):
- issue_deprecation_warning(
- 'type {} for value {} ({})'
- .format(type(num), selector, num),
- 'an int', 1,
- warning_class=FutureWarning, since='20151009')
- num = int(num)
+ raise ValueError("'{}' must be a number, not a {} ({})"
+ .format(selector, num, type(num).__name__))
plural_entries = []
specific_entries = {}
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693512
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie7b491674a44ca9f8b42942441d0c49af2b5ba29
Gerrit-Change-Number: 693512
Gerrit-PatchSet: 2
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: Isaacandy <isaac(a)iznd.xyz>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693509 )
Change subject: [cleanup] Remove deprecated twntranslate method
......................................................................
[cleanup] Remove deprecated twntranslate method
This method was deprecated about six years ago. Also cleaning up a couple bits
of code that were commented as being for it.
Change-Id: I0b31aaeff0f175ca2ed6f6200b61ba47c3f1879d
---
M pywikibot/i18n.py
M tests/i18n_tests.py
2 files changed, 4 insertions(+), 213 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 5399c85..4554f3a7 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -28,7 +28,6 @@
from contextlib import suppress
from textwrap import fill
from typing import Optional, Union
-from warnings import warn
import pywikibot
from pywikibot import __url__, config
@@ -36,7 +35,6 @@
from pywikibot.plural import plural_rule
from pywikibot.tools import (
ModuleDeprecationWrapper,
- deprecated,
deprecated_args,
issue_deprecation_warning,
)
@@ -710,21 +708,9 @@
'See {}/i18n'
.format(_messages_package_name, twtitle, __url__))
- source_needed = False
- # If a site is given instead of a lang, use its language
- if hasattr(source, 'lang'):
- lang = source.lang
- # check whether we need the language code back
- elif isinstance(source, list):
- # For backwards compatibility still support lists, when twntranslate
- # was not deprecated and needed a way to get the used language code
- # back.
- warn('The source argument should not be a list but either a BaseSite '
- 'or a str/unicode.', DeprecationWarning, 2)
- lang = source.pop()
- source_needed = True
- else:
- lang = source
+ # if source is a site then use its lang attribute, otherwise it's a str
+
+ lang = getattr(source, 'lang', source)
# There are two possible failure modes: the translation dict might not have
# the language altogether, or a specific key could be untranslated. Both
@@ -743,9 +729,6 @@
'outdated submodule. See {}/i18n'
.format('English' if 'en' in langs else "'{}'".format(lang),
twtitle, __url__)))
- # send the language code back via the given mutable list parameter
- if source_needed:
- source.append(alt)
if '{{PLURAL:' in trans:
# _extract_plural supports in theory non-mappings, but they are
@@ -754,16 +737,6 @@
raise TypeError('parameters must be a mapping.')
trans = _extract_plural(alt, trans, parameters)
- # this is only the case when called in twntranslate, and that didn't apply
- # parameters when it wasn't a dict
- if isinstance(parameters, _PluralMappingAlias):
- # This is called due to the old twntranslate function which ignored
- # KeyError. Instead only_plural should be used.
- if isinstance(parameters.source, dict):
- with suppress(KeyError):
- trans %= parameters.source
- parameters = None
-
if parameters is not None and not isinstance(parameters, Mapping):
raise ValueError('parameters should be a mapping, not {}'
.format(type(parameters).__name__))
@@ -773,16 +746,6 @@
return trans
-@deprecated('twtranslate', since='20151009', future_warning=True)
-@deprecated_args(code='source')
-def twntranslate(source, twtitle: str,
- parameters: Optional[Mapping] = None) -> Optional[str]:
- """DEPRECATED: Get translated string for the key."""
- if parameters is not None:
- parameters = _PluralMappingAlias(parameters)
- return twtranslate(source, twtitle, parameters)
-
-
@deprecated_args(code='source')
def twhas_key(source, twtitle: str) -> bool:
"""
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py
index 2c9bc72..b80d6fb 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -7,10 +7,9 @@
from contextlib import suppress
import pywikibot
-from pywikibot import bot, config, i18n, plural
+from pywikibot import bot, config, i18n
from pywikibot.exceptions import TranslationError
from tests.aspects import (
- AutoDeprecationTestCase,
DefaultSiteTestCase,
PwbTestCase,
TestCase,
@@ -296,177 +295,6 @@
i18n.twtranslate('en', 'test-no-english')
-class TestTWNTranslate(TWNTestCaseBase, AutoDeprecationTestCase):
-
- """Test {{PLURAL:}} support."""
-
- net = False
- message_package = 'tests.i18n'
-
- def testNumber(self):
- """Use a number."""
- self.assertEqual(
- i18n.twntranslate('de', 'test-plural', 0) % {'num': 0},
- 'Bot: Ändere 0 Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-plural', 1) % {'num': 1},
- 'Bot: Ändere 1 Seite.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-plural', 2) % {'num': 2},
- 'Bot: Ändere 2 Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-plural', 3) % {'num': 3},
- 'Bot: Ändere 3 Seiten.')
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', 0) % {'num': 'no'},
- 'Bot: Changing no pages.')
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', 1) % {'num': 'one'},
- 'Bot: Changing one page.')
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', 2) % {'num': 'two'},
- 'Bot: Changing two pages.')
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', 3) % {'num': 'three'},
- 'Bot: Changing three pages.')
-
- def testString(self):
- """Use a string."""
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', '1') % {'num': 'one'},
- 'Bot: Changing one page.')
-
- def testDict(self):
- """Use a dictionary."""
- self.assertEqual(
- i18n.twntranslate('en', 'test-plural', {'num': 2}),
- 'Bot: Changing 2 pages.')
-
- def testExtended(self):
- """Use additional format strings."""
- self.assertEqual(
- i18n.twntranslate('fr', 'test-plural',
- {'num': 1, 'descr': 'seulement'}),
- 'Robot: Changer seulement une page.')
-
- def testExtendedOutside(self):
- """Use additional format strings also outside."""
- self.assertEqual(
- i18n.twntranslate('fr', 'test-plural', 1) % {'descr': 'seulement'},
- 'Robot: Changer seulement une page.')
-
- def testMultiple(self):
- """Test using multiple plural entries."""
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', 1)
- % {'action': 'Ändere', 'line': 'eine'},
- 'Bot: Ändere eine Zeile von einer Seite.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', 2)
- % {'action': 'Ändere', 'line': 'zwei'},
- 'Bot: Ändere zwei Zeilen von mehreren Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', 3)
- % {'action': 'Ändere', 'line': 'drei'},
- 'Bot: Ändere drei Zeilen von mehreren Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', (1, 2, 2))
- % {'action': 'Ändere', 'line': 'eine'},
- 'Bot: Ändere eine Zeile von mehreren Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', [3, 1, 1])
- % {'action': 'Ändere', 'line': 'drei'},
- 'Bot: Ändere drei Zeilen von einer Seite.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', ['3', 1, 1])
- % {'action': 'Ändere', 'line': 'drei'},
- 'Bot: Ändere drei Zeilen von einer Seite.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals', '321')
- % {'action': 'Ändere', 'line': 'dreihunderteinundzwanzig'},
- 'Bot: Ändere dreihunderteinundzwanzig Zeilen von mehreren Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals',
- {'action': 'Ändere', 'line': 1, 'page': 1}),
- 'Bot: Ändere 1 Zeile von einer Seite.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals',
- {'action': 'Ändere', 'line': 1, 'page': 2}),
- 'Bot: Ändere 1 Zeile von mehreren Seiten.')
- self.assertEqual(
- i18n.twntranslate('de', 'test-multiple-plurals',
- {'action': 'Ändere', 'line': '11', 'page': 2}),
- 'Bot: Ändere 11 Zeilen von mehreren Seiten.')
-
- def testMultipleWrongParameterLength(self):
- """Test wrong parameter length."""
- err_msg = 'Length of parameter does not match PLURAL occurrences'
- with self.assertRaisesRegex(ValueError, err_msg):
- i18n.twntranslate('de', 'test-multiple-plurals', (1, 2))
-
- with self.assertRaisesRegex(ValueError, err_msg):
- i18n.twntranslate('de', 'test-multiple-plurals', ['321'])
-
- def testMultipleNonNumbers(self):
- """Test error handling for multiple non-numbers."""
- with self.assertRaisesRegex(
- ValueError, r"invalid literal for int\(\) with base 10: 'drei'"
- ):
- i18n.twntranslate('de', 'test-multiple-plurals', ['drei', '1', 1])
- with self.assertRaisesRegex(
- ValueError, r"invalid literal for int\(\) with base 10: 'elf'"
- ):
- i18n.twntranslate('de', 'test-multiple-plurals',
- {'action': 'Ändere', 'line': 'elf', 'page': 2})
-
- def testAllParametersExist(self):
- """Test that all parameters are required when using a dict."""
- # all parameters must be inside twntranslate
- self.assertEqual(i18n.twntranslate('de', 'test-multiple-plurals',
- {'line': 1, 'page': 1}),
- 'Bot: %(action)s %(line)s Zeile von einer Seite.')
-
- def test_fallback_lang(self):
- """
- Test that twntranslate uses the translation's language.
-
- twntranslate calls _twtranslate which might return the translation for
- a different language and then the plural rules from that language need
- to be applied.
- """
- # co has fr as altlang but has no plural rules defined (otherwise this
- # test might not catch problems) so it's using the plural variant for 0
- # although French uses the plural variant for numbers > 1 (so not 0)
- assert 'co' not in plural.plural_rules
- assert plural.plural_rules['fr']['plural'](0) is False
- self.assertEqual(
- i18n.twntranslate('co', 'test-plural',
- {'num': 0, 'descr': 'seulement'}),
- 'Robot: Changer seulement une page.')
- self.assertEqual(
- i18n.twntranslate('co', 'test-plural',
- {'num': 1, 'descr': 'seulement'}),
- 'Robot: Changer seulement une page.')
-
-
-class ScriptMessagesTestCase(TWNTestCaseBase, AutoDeprecationTestCase):
-
- """Real messages test."""
-
- net = False
- message_package = 'scripts.i18n'
-
- def test_basic(self):
- """Verify that real messages are able to be loaded."""
- self.assertEqual(i18n.twntranslate('en', 'pywikibot-enter-new-text'),
- 'Please enter the new text:')
-
- def test_missing(self):
- """Test a missing message from a real message bundle."""
- with self.assertRaises(TranslationError):
- i18n.twntranslate('en', 'pywikibot-missing-key')
-
-
class InputTestCase(TWNTestCaseBase, UserInterfaceLangTestCase, PwbTestCase):
"""Test i18n.input."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693509
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0b31aaeff0f175ca2ed6f6200b61ba47c3f1879d
Gerrit-Change-Number: 693509
Gerrit-PatchSet: 2
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693539 )
Change subject: Revert "[cleanup] Require archivebot durations to have a time unit"
......................................................................
Revert "[cleanup] Require archivebot durations to have a time unit"
This reverts commit 5bc89c24e0c8dfe57831a6c36e8843c752784439.
Reason for revert: This is too early.
May come at earliest with 6.3 as the FutureWarning's announcement was in 6.1
Change-Id: Ibe4feec28388950e03be722fe4ccaab0228a1c82
---
M scripts/archivebot.py
M tests/archivebot_tests.py
2 files changed, 15 insertions(+), 17 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index f81be2e..7de2476 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -116,6 +116,7 @@
findmarker,
to_local_digits,
)
+from pywikibot.tools import issue_deprecation_warning
ShouldArchive = Tuple[str, str]
@@ -241,19 +242,15 @@
@return: key and duration extracted form the string
"""
- if len(string) < 2:
- raise MalformedConfigError('Time period should be a numeric value '
- 'followed by its qualifier')
-
- key, duration = string[-1], string[:-1]
-
- if key not in MW_KEYS:
- raise MalformedConfigError('Time period qualifier is unrecognized: {}'
- .format(string))
- if not duration.isdigit():
- raise MalformedConfigError("Time period's duration should be "
- 'numeric: {}'.format(string))
-
+ if string.isdigit():
+ key = 's'
+ duration = string
+ issue_deprecation_warning('Time period without qualifier',
+ string + key, 1, FutureWarning,
+ since='20161009')
+ else:
+ key = string[-1]
+ duration = string[:-1]
return key, duration
diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index e3a3828..9bf1e36 100644
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -12,6 +12,7 @@
import pywikibot.page
from pywikibot.exceptions import Error
from pywikibot.textlib import TimeStripper
+from pywikibot.tools import suppress_warnings
from scripts import archivebot
from tests.aspects import TestCase
@@ -96,12 +97,12 @@
def test_checkstr(self):
"""Test for extracting key and duration from shorthand notation."""
self.assertEqual(archivebot.checkstr('400s'), ('s', '400'))
+ with suppress_warnings('Time period without qualifier', UserWarning):
+ self.assertEqual(archivebot.checkstr('3000'), ('s', '3000'))
self.assertEqual(archivebot.checkstr('7d'), ('d', '7'))
self.assertEqual(archivebot.checkstr('3y'), ('y', '3'))
-
- for invalid_value in ('', '3000', '4000@'):
- with self.assertRaises(archivebot.MalformedConfigError):
- archivebot.checkstr(invalid_value)
+ # Should pass, because the key is verified in str2time
+ self.assertEqual(archivebot.checkstr('4000@'), ('@', '4000'))
def test_str2size(self):
"""Test for parsing the shorthand notation of sizes."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693539
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibe4feec28388950e03be722fe4ccaab0228a1c82
Gerrit-Change-Number: 693539
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693584 )
Change subject: [cleanup] Require archivebot durations to have a time unit
......................................................................
[cleanup] Require archivebot durations to have a time unit
Our archivebot's checkstr() should verify that our time value is valid.
Dropping the deprecated behavior of treating numeric values as seconds, and
adding basic input validation.
Change-Id: I997c6e82a9890a9526f26c0e8b5474a216b97579
---
M scripts/archivebot.py
M tests/archivebot_tests.py
2 files changed, 17 insertions(+), 15 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 7de2476..f81be2e 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -116,7 +116,6 @@
findmarker,
to_local_digits,
)
-from pywikibot.tools import issue_deprecation_warning
ShouldArchive = Tuple[str, str]
@@ -242,15 +241,19 @@
@return: key and duration extracted form the string
"""
- if string.isdigit():
- key = 's'
- duration = string
- issue_deprecation_warning('Time period without qualifier',
- string + key, 1, FutureWarning,
- since='20161009')
- else:
- key = string[-1]
- duration = string[:-1]
+ if len(string) < 2:
+ raise MalformedConfigError('Time period should be a numeric value '
+ 'followed by its qualifier')
+
+ key, duration = string[-1], string[:-1]
+
+ if key not in MW_KEYS:
+ raise MalformedConfigError('Time period qualifier is unrecognized: {}'
+ .format(string))
+ if not duration.isdigit():
+ raise MalformedConfigError("Time period's duration should be "
+ 'numeric: {}'.format(string))
+
return key, duration
diff --git a/tests/archivebot_tests.py b/tests/archivebot_tests.py
index 9bf1e36..e3a3828 100644
--- a/tests/archivebot_tests.py
+++ b/tests/archivebot_tests.py
@@ -12,7 +12,6 @@
import pywikibot.page
from pywikibot.exceptions import Error
from pywikibot.textlib import TimeStripper
-from pywikibot.tools import suppress_warnings
from scripts import archivebot
from tests.aspects import TestCase
@@ -97,12 +96,12 @@
def test_checkstr(self):
"""Test for extracting key and duration from shorthand notation."""
self.assertEqual(archivebot.checkstr('400s'), ('s', '400'))
- with suppress_warnings('Time period without qualifier', UserWarning):
- self.assertEqual(archivebot.checkstr('3000'), ('s', '3000'))
self.assertEqual(archivebot.checkstr('7d'), ('d', '7'))
self.assertEqual(archivebot.checkstr('3y'), ('y', '3'))
- # Should pass, because the key is verified in str2time
- self.assertEqual(archivebot.checkstr('4000@'), ('@', '4000'))
+
+ for invalid_value in ('', '3000', '4000@'):
+ with self.assertRaises(archivebot.MalformedConfigError):
+ archivebot.checkstr(invalid_value)
def test_str2size(self):
"""Test for parsing the shorthand notation of sizes."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693584
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I997c6e82a9890a9526f26c0e8b5474a216b97579
Gerrit-Change-Number: 693584
Gerrit-PatchSet: 1
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693505 )
Change subject: [cleanup] Disallow non-map translation parameters
......................................................................
[cleanup] Disallow non-map translation parameters
Translation with a string or integer parameter argument were deprecated about
six years ago. Enforcing it.
Change-Id: Ic9869f12d729d8ec99fb2e96dbef12a5efd7f410
---
M pywikibot/i18n.py
1 file changed, 6 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index aba2f29..5399c85 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -529,7 +529,7 @@
def translate(code,
xdict: Union[dict, str],
- parameters: Union[dict, str, int, None] = None,
+ parameters: Optional[Mapping] = None,
fallback=False) -> str:
"""Return the most appropriate localization from a localization dict.
@@ -610,15 +610,11 @@
return trans
if not isinstance(parameters, Mapping):
- issue_deprecation_warning('parameters not being a mapping',
- warning_class=FutureWarning,
- since='20151008')
- plural_parameters = _PluralMappingAlias(parameters)
- else:
- plural_parameters = parameters
+ raise ValueError('parameters should be a mapping, not {}'
+ .format(type(parameters).__name__))
# else we check for PLURAL variants
- trans = _extract_plural(code, trans, plural_parameters)
+ trans = _extract_plural(code, trans, parameters)
if parameters:
# On error: parameter is for PLURAL variants only,
# don't change the string
@@ -769,9 +765,8 @@
parameters = None
if parameters is not None and not isinstance(parameters, Mapping):
- issue_deprecation_warning('parameters not being a Mapping',
- warning_class=FutureWarning,
- since='20151008')
+ raise ValueError('parameters should be a mapping, not {}'
+ .format(type(parameters).__name__))
if not only_plural and parameters:
return trans % parameters
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693505
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic9869f12d729d8ec99fb2e96dbef12a5efd7f410
Gerrit-Change-Number: 693505
Gerrit-PatchSet: 1
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: Isaacandy <isaac(a)iznd.xyz>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693498 )
Change subject: [cleanup] Remove deprecated LogEntry title method
......................................................................
[cleanup] Remove deprecated LogEntry title method
This method was deprecated almost six years ago. Cleaning it up.
Change-Id: Ie5d35b09b9838258494285bc21f2e7feed4f1c2c
---
M pywikibot/logentries.py
M tests/logentries_tests.py
2 files changed, 1 insertion(+), 32 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 106448d..4bade5d 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -11,7 +11,6 @@
import pywikibot
from pywikibot.backports import List
from pywikibot.exceptions import Error, HiddenKeyError
-from pywikibot.tools import deprecated
_logger = 'wiki'
@@ -102,16 +101,6 @@
return self[self._expected_type]
- @deprecated('page()', since='20150617', future_warning=True)
- def title(self):
- """
- DEPRECATED: Alias for page().
-
- This is going to be replaced by just returning the title as a string
- instead of a Page instance.
- """
- return self.page()
-
def page(self):
"""
Page on which action was performed.
diff --git a/tests/logentries_tests.py b/tests/logentries_tests.py
index f4d5653..990acf2 100644
--- a/tests/logentries_tests.py
+++ b/tests/logentries_tests.py
@@ -17,7 +17,7 @@
UserTargetLogEntry,
)
from tests import unittest_print
-from tests.aspects import DeprecationTestCase, MetaTestCaseClass, TestCase
+from tests.aspects import MetaTestCaseClass, TestCase
class TestLogentriesBase(TestCase):
@@ -284,26 +284,6 @@
self.assertEqual(type(le4), type(le5))
-class TestDeprecatedMethods(TestLogentriesBase, DeprecationTestCase):
-
- """Test cases for deprecated logentry methods."""
-
- def test_logentry_title(self, key):
- """Test title and page return the same instance."""
- # Request multiple log entries in the hope that one might have no
- # title entry
- self._do_test_warning_filename = False # T271044
- for logentry in self.site.logevents(total=5):
- if 'title' in logentry.data: # title may be missing
- self.assertIsInstance(logentry.title(), pywikibot.Page)
- self.assertIs(logentry.title(), logentry.page())
- else:
- with self.assertRaises(KeyError):
- logentry.title()
- self.assertDeprecation() # T271044
- self._reset_messages() # T271044
-
-
if __name__ == '__main__': # pragma: no cover
with suppress(SystemExit):
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693498
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie5d35b09b9838258494285bc21f2e7feed4f1c2c
Gerrit-Change-Number: 693498
Gerrit-PatchSet: 2
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693504 )
Change subject: [cleanup] Disallow site to be None when required for regex
......................................................................
[cleanup] Disallow site to be None when required for regex
Our _get_regexes() issued a deprecation warning when a site is required but not
provided. It's time we enforce it.
Change-Id: I56c9c1cff7e8a192d525dd66533c44209e0fc5dc
---
M pywikibot/textlib.py
1 file changed, 2 insertions(+), 6 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ae7060d..2b14c97 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -296,12 +296,8 @@
if isinstance(_regex_cache[exc], tuple):
if not site and exc in ('interwiki', 'property', 'invoke',
'category', 'file'):
- issue_deprecation_warning(
- 'site=None',
- "a valid site for '{}' regex".format(exc),
- warning_class=FutureWarning,
- since='20151006')
- site = pywikibot.Site()
+ raise ValueError("Site cannot be None for the '{}' regex"
+ .format(exc))
if (exc, site) not in _regex_cache:
re_text, re_var = _regex_cache[exc]
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693504
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I56c9c1cff7e8a192d525dd66533c44209e0fc5dc
Gerrit-Change-Number: 693504
Gerrit-PatchSet: 1
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692862 )
Change subject: [IMPR] use itertools.count in reflinks.py
......................................................................
[IMPR] use itertools.count in reflinks.py
Change-Id: I7ff4e138a61ea27813367fad503248b21ae93981
---
M scripts/reflinks.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index dc437c4..2c4a9d1 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -41,11 +41,13 @@
#
import codecs
import http.client as httplib
+import itertools
import os
import re
import socket
import subprocess
import tempfile
+
from contextlib import suppress
from functools import partial
from http import HTTPStatus
@@ -353,7 +355,7 @@
used_numbers.add(int(number))
# generator to give the next free number
- free_number = (str(i) for i in range(1, 1000) # should be enough
+ free_number = (str(i) for i in itertools.count(start=1)
if i not in used_numbers)
for (g, d) in found_refs.items():
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692862
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7ff4e138a61ea27813367fad503248b21ae93981
Gerrit-Change-Number: 692862
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692846 )
Change subject: [docs] Add a glossary to docs
......................................................................
[docs] Add a glossary to docs
Change-Id: Ia31b2ecd5d180e212414126151d0c01ed058370f
---
A docs/glossary.rst
M docs/index.rst
2 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/glossary.rst b/docs/glossary.rst
new file mode 100644
index 0000000..1adafff
--- /dev/null
+++ b/docs/glossary.rst
@@ -0,0 +1,61 @@
+Glossary
+========
+
+.. if you add new entries, keep the alphabetical sorting!
+
+.. glossary::
+
+ ``>>>``
+ The default Python prompt of the interactive Pywikibot shell.
+ Often seen for code examples which can be executed interactively
+ in the interpreter. The :mod:`pywikibot` module is preloaded. The
+ :mod:`scripts.shell` script is part of the :mod:`scripts` module.
+
+ compat
+ The first Pywikibot package formerly known as *Pywikipediabot*
+ also called :term:`trunk` was started in 2003. MediaWiki didn't
+ have an API so a `screen scrapping
+ <https://en.wikipedia.org/Screen_scraper>`_ was used.
+
+ core
+ In 2007 a new branch of Pywikibot formerly known as
+ :term:`trunk` was started using the new MediaWiki API. The
+ current release is |release|.
+
+ master
+ The development branch of Pywikibot. It should not be used for
+ production systems, use :term:`stable` instead. The master branch
+ may have untested features. Use master branch if you want to
+ support development and report undetected problems.
+
+ pwb
+ Can refer to:
+
+ - short for Pywikibot
+ - the :mod:`pwb` wrapper script
+
+ pywikibot
+ **Py**\ thon Media\ **Wiki Bot** Framework, a Python library and
+ collection of scripts that automate work on MediaWiki sites.
+ Originally designed for Wikipedia, it is now used throughout the
+ Wikimedia Foundation's projects and on many other wikis based of
+ MediaWiki software.
+
+ rewrite
+ A former name of :term:`core`.
+
+ stable
+ A stable branch of Pywikibot updated roughly every month
+ after tests passes. This branch is preinstalled at :term:`PAWS`
+ and should be used for production systems.
+
+ trunk
+ A former name of :term:`compat`.
+
+ PAWS
+ PAWS (PAWS: A Web Shell) formerly known as *Pywikibot: A Web Shell*
+ is a Jupyter notebooks deployment hosted by Wikimedia. It has
+ preinstalled the :term:`stable` release of Pywikibot. Refer:
+
+ - https://wikitech.wikimedia.org/wiki/PAWS
+ - https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 8db7805..e6cb09a 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -79,6 +79,7 @@
.. toctree::
:maxdepth: 1
+ glossary
changelog
licenses
credits
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692846
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia31b2ecd5d180e212414126151d0c01ed058370f
Gerrit-Change-Number: 692846
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged