jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735666 )
Change subject: [bugfix] Make site parameter of textlib.replace_links() mandatory
......................................................................
[bugfix] Make site parameter of textlib.replace_links() mandatory
replace_links always fails if no site parameter is given
Bug: T294649
Change-Id: I84b4a43003c1a1fcb0dfd166b7b158420370d02e
---
M pywikibot/textlib.py
1 file changed, 15 insertions(+), 14 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 0b9668e..aac155c 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -24,7 +24,6 @@
from pywikibot.backports import Tuple
from pywikibot.exceptions import InvalidTitleError, SiteDefinitionError
from pywikibot.family import Family
-from pywikibot.tools import issue_deprecation_warning
try:
@@ -585,9 +584,8 @@
return marker
-def replace_links(text: str, replace, site=None) -> str:
- """
- Replace wikilinks selectively.
+def replace_links(text: str, replace, site: 'pywikibot.site.BaseSite') -> str:
+ """Replace wikilinks selectively.
The text is searched for a link and on each link it replaces the text
depending on the result for that link. If the result is just None it skips
@@ -605,6 +603,9 @@
function which returns a Link instance and copies the value which should
remaining.
+ .. versionchanged:: 7.0
+ `site` parameter is mandatory
+
:param text: the text in which to replace links
:param replace: either a callable which reacts like described above.
The callable must accept four parameters link, text, groups, rng and
@@ -620,9 +621,12 @@
in that case it will apply the second value from the sequence.
:type replace: sequence of pywikibot.Page/pywikibot.Link/str or
callable
- :param site: a Site object to use. It should match the origin
- or target site of the text
- :type site: pywikibot.site.APISite
+ :param site: a Site object to use. It should match the origin or
+ target site of the text
+ :raises TypeError: missing positional argument 'site'
+ :raises ValueError: Wrong site type
+ :raises ValueError: Wrong replacement number
+ :raises ValueError: Wrong replacement types
"""
def to_link(source):
"""Return the link from source when it's a Page otherwise itself."""
@@ -650,6 +654,10 @@
title += '#' + link.section
return title
+ if not isinstance(site, pywikibot.site.BaseSite):
+ raise ValueError('The "site" argument must be a BaseSite not {}.'
+ .format(type(site).__name__))
+
if isinstance(replace, Sequence):
if len(replace) != 2:
raise ValueError('When used as a sequence, the "replace" '
@@ -664,13 +672,6 @@
replace_list[1] = pywikibot.Page(site, replace_list[1])
check_classes(replace_list[0])
replace = replace_callable
- if site is None:
- issue_deprecation_warning(
- 'site=None',
- 'a valid site for list or tuple parameter "replace"',
- 2, since='20190223')
- elif site is None:
- raise ValueError('The "site" argument must be provided.')
linktrail = site.linktrail()
link_pattern = re.compile(
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735666
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: I84b4a43003c1a1fcb0dfd166b7b158420370d02e
Gerrit-Change-Number: 735666
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735714 )
Change subject: [doc] Update ROADMAP.rst and CHANGELOG.md
......................................................................
[doc] Update ROADMAP.rst and CHANGELOG.md
Change-Id: I6d0d0f24480c7c988b17cf6e2cfb4df2c324e094
---
M ROADMAP.rst
M scripts/CHANGELOG.md
2 files changed, 15 insertions(+), 0 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 3aaab24..0b525c1 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -4,6 +4,8 @@
Improvements and Bugfixes
-------------------------
+* Raise a generic ServerError if the http status code is unofficial (T293208)
+* Add support for Wikimedia OCR engine with proofreadpage
* Rewrite tools.intersect_generators which makes it running up to 10'000 times faster. (T85623, T293276)
* The cached output functionality from compat release was re-implemented (T151727, T73646, T74942, T132135, T144698, T196039, T280466)
* L10N updates
@@ -20,6 +22,16 @@
Code cleanups
-------------
+* version.ParseError was removed in favour of exceptions.VersionParseError
+* specialbots.EditReplacement and specialbots.EditReplacementError were removed in favour of exceptions.EditReplacementError
+* site.PageInUse exception was removed in favour of exceptions.PageInUseError
+* page.UnicodeToAsciiHtml and page.unicode2html were removed in favour of tools.chars.string_to_ascii_html and tools.chars.string2html
+* interwiki_graph.GraphImpossible and login.OAuthImpossible exception were removed in favour of ImportError
+* i18n.TranslationError was removed in favour of exceptions.TranslationError
+* WikiaFamily was removed in favour of FandomFamily
+* data.api exceptions were removed in favour of exceptions module
+* cosmetic_changes CANCEL_ALL/PAGE/METHOD/MATCH constants were removed in favour of CANCEL enum
+* pywikibot.__release__ was removed in favour of pywikibot.__version__
* TextfilePageGenerator was replaced by TextIOPageGenerator
* PreloadingItemGenerator was replaced by PreloadingEntityGenerator
* DuplicateFilterPageGenerator was replaced by tools.filter_unique
diff --git a/scripts/CHANGELOG.md b/scripts/CHANGELOG.md
index 6677768..886f0f5 100644
--- a/scripts/CHANGELOG.md
+++ b/scripts/CHANGELOG.md
@@ -3,6 +3,9 @@
## 7.0.0
*In development*
+### general
+* Provide ConfigParserBot for several scripts (T223778)
+
### add_text
* Provide -create and -createonly options (T291354)
* Deprecated function get_text() was removed in favour of Page.text and BaseBot.skip_page()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735714
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: I6d0d0f24480c7c988b17cf6e2cfb4df2c324e094
Gerrit-Change-Number: 735714
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-CC: jenkins-bot
Gerrit-MessageType: merged