lists.wikimedia.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
List overview
Download
Pywikibot-commits
March 2022
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
pywikibot-commits@lists.wikimedia.org
1 participants
162 discussions
Start a n
N
ew thread
[Gerrit] ...core[master]: [IMPR] Make _get_parsed_page a public method
by jenkins-bot (Code Review)
18 Mar '22
18 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770133
) Change subject: [IMPR] Make _get_parsed_page a public method ...................................................................... [IMPR] Make _get_parsed_page a public method - make _get_parsed_page a public method - no deprecation warning is thrown due to the private method status - add force parameter to clear the cache - raise KeyError instead of AssertionError in APISite.get_parsed_page - use get_parsed_page with force parameter in ProofreadPage Change-Id: Icf3b5f22d3f98fe811b5e782a84301bc77894649 --- M pywikibot/page/_basepage.py M pywikibot/proofreadpage.py M pywikibot/site/_apisite.py 3 files changed, 27 insertions(+), 17 deletions(-) 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/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py index 05bc27b..d4a47e4 100644 --- a/pywikibot/page/_basepage.py +++ b/pywikibot/page/_basepage.py @@ -618,10 +618,20 @@ self.site.loadpageinfo(self, preload=True) return self._preloadedtext - def _get_parsed_page(self): - """Retrieve parsed text (via action=parse) and cache it.""" - # Get (cached) parsed text. - if not hasattr(self, '_parsed_text'): + def get_parsed_page(self, force: bool = False) -> str: + """Retrieve parsed text (via action=parse) and cache it. + + .. versionchanged:: 7.1 + `force` parameter was added; + `_get_parsed_page` becomes a public method + + :param force: force updating from the live site + + .. seealso:: + :meth:`APISite.get_parsed_page() + <pywikibot.site._apisite.APISite.get_parsed_page>` + """ + if not hasattr(self, '_parsed_text') or force: self._parsed_text = self.site.get_parsed_page(self) return self._parsed_text diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py index 895566a..4c03176 100644 --- a/pywikibot/proofreadpage.py +++ b/pywikibot/proofreadpage.py @@ -906,11 +906,7 @@ self._pages_from_label = {} # type: PagesFromLabelType self._labels_from_page_number = {} # type: Dict[int, str] self._labels_from_page = {} # type: Dict[pywikibot.page.Page, str] - if hasattr(self, '_parsed_text'): - del self._parsed_text - - self._parsed_text = self._get_parsed_page() - self._soup = _bs4_soup(self._parsed_text) # type: ignore + self._soup = _bs4_soup(self.get_parsed_page(True)) # type: ignore # Do not search for "new" here, to avoid to skip purging if links # to non-existing pages are present. attrs = {'class': re.compile('prp-pagequality')} @@ -932,9 +928,7 @@ attrs = {'class': re.compile('prp-pagequality|new')} if not found: self.purge() - del self._parsed_text - self._parsed_text = self._get_parsed_page() - self._soup = _bs4_soup(self._parsed_text) # type: ignore + self._soup = _bs4_soup(self.get_parsed_page(True)) # type: ignore if not self._soup.find_all('a', attrs=attrs): raise ValueError( 'Missing class="qualityN prp-pagequality-N" or ' diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index 118fed7..2db07ad 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -1441,16 +1441,22 @@ return user_tokens # TODO: expand support to other parameters of action=parse? - def get_parsed_page(self, page): + def get_parsed_page(self, page: 'pywikibot.Page') -> str: """Retrieve parsed text of the page using action=parse. - :see:
https://www.mediawiki.org/wiki/API:Parse
+ .. versionchanged:: 7.1 + raises KeyError instead of AssertionError + + .. seealso:: + -
https://www.mediawiki.org/wiki/API:Parse
+ - :meth:`pywikibot.page.BasePage.get_parsed_page`. """ req = self.simple_request(action='parse', page=page) data = req.submit() - assert 'parse' in data, "API parse response lacks 'parse' key" - assert 'text' in data['parse'], "API parse response lacks 'text' key" - parsed_text = data['parse']['text']['*'] + try: + parsed_text = data['parse']['text']['*'] + except KeyError as e: + raise KeyError('API parse response lacks {} key'.format(e)) return parsed_text def getcategoryinfo(self, category) -> None: -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770133
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: Icf3b5f22d3f98fe811b5e782a84301bc77894649 Gerrit-Change-Number: 770133 Gerrit-PatchSet: 3 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com> Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [page] Split page/__init__.py (part 2)
by Xqt (Code Review)
18 Mar '22
18 Mar '22
Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771825
) Change subject: [page] Split page/__init__.py (part 2) ...................................................................... [page] Split page/__init__.py (part 2) Change-Id: I6da67c0fbbe2ee00645646695e35beb450bd382a --- M pywikibot/CONTENT.rst A pywikibot/page/__init__.py M pywikibot/page/_basepage.py M tests/collections_tests.py M tox.ini 5 files changed, 110 insertions(+), 49 deletions(-) Approvals: Xqt: Verified; Looks good to me, approved diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst index a9eed53..4712112 100644 --- a/pywikibot/CONTENT.rst +++ b/pywikibot/CONTENT.rst @@ -102,7 +102,9 @@ +----------------------------+------------------------------------------------------+ | page | Module with classes for MediaWiki page content | +============================+======================================================+ - | __init__.py | Objects representing MediaWiki pages | + | __init__.py | Interface representing MediaWiki pages | + +----------------------------+------------------------------------------------------+ + | _basepage.py | Objects representing MediaWiki pages | +----------------------------+------------------------------------------------------+ | _collections.py | Structures holding data for Wikibase entities | +----------------------------+------------------------------------------------------+ diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py new file mode 100644 index 0000000..c5c44f6 --- /dev/null +++ b/pywikibot/page/__init__.py @@ -0,0 +1,88 @@ +"""Interface of various types of MediaWiki pages.""" +# +# (C) Pywikibot team, 2022 +# +# Distributed under the terms of the MIT license. +# +from typing import Union + +from pywikibot.page._basepage import ( + BaseLink, + BasePage, + Category, + Claim, + FileInfo, + FilePage, + ItemPage, + Link, + MediaInfo, + Page, + Property, + PropertyPage, + SiteLink, + User, + WikibaseEntity, + WikibasePage, + html2unicode, +) +from pywikibot.page._revision import Revision +from pywikibot.site import BaseSite as _BaseSite +from pywikibot.tools import deprecated, issue_deprecation_warning +from pywikibot.tools.chars import url2string as _url2string + + +__all__ = ( + 'BaseLink', + 'Link', + 'SiteLink', + 'BasePage', + 'Page', + 'FilePage', + 'Category', + 'User', + 'WikibasePage', + 'ItemPage', + 'PropertyPage', + 'Property', + 'Claim', + 'FileInfo', + 'WikibaseEntity', + 'MediaInfo', + 'Revision', + 'html2unicode', + 'url2unicode', +) + +PageSourceType = Union[ + BaseLink, + _BaseSite, + Page, +] + + +@deprecated('pywikibot.tools.chars.url2string', since='6.2.0') +def url2unicode(title: str, encodings='utf-8') -> str: + """Convert URL-encoded text to unicode using several encoding. + + Uses the first encoding that doesn't cause an error. + + .. deprecated:: 6.2 + Use :func:`pywikibot.tools.chars.url2string` instead. + + :param title: URL-encoded character data to convert + :param encodings: Encodings to attempt to use during conversion. + :type encodings: str, list or Site + + :raise UnicodeError: Could not convert using any encoding. + """ + if isinstance(encodings, _BaseSite): + # use all possible encodings from Site object + encodings = encodings.encodings() + issue_deprecation_warning( + 'Passing BaseSite object to encodings parameter', + 'BaseSite.encodings()', + depth=1, + since='6.2.0' + ) + + return _url2string(title, encodings) diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py index 904358f..05bc27b 100644 --- a/pywikibot/page/_basepage.py +++ b/pywikibot/page/_basepage.py @@ -80,32 +80,25 @@ PROTOCOL_REGEX = r'\Ahttps?://' __all__ = ( + 'BaseLink', 'BasePage', - 'Page', - 'FilePage', 'Category', - 'User', - 'WikibasePage', + 'Claim', + 'FileInfo', + 'FilePage', 'ItemPage', + 'Link', + 'MediaInfo', + 'Page', 'Property', 'PropertyPage', - 'Claim', - 'Revision', - 'FileInfo', - 'BaseLink', - 'Link', 'SiteLink', - 'SiteLinkCollection', + 'User', + 'WikibaseEntity', + 'WikibasePage', 'html2unicode', - 'url2unicode', ) -PageSourceType = Union[ - 'pywikibot.site.BaseLink', - 'pywikibot.page.BaseSite', - 'pywikibot.page.Page', -] - logger = logging.getLogger('pywiki.wiki.page') @@ -3555,6 +3548,12 @@ return self._file def get(self, force: bool = False) -> dict: + """Fetch all MediaInfo entity data and cache it. + + :param force: override caching + :raise NoWikibaseEntityError: if this entity doesn't exist + :return: actual data which entity holds + """ if self.id == '-1': if force: if not self.file.exists(): @@ -5906,31 +5905,3 @@ return match.group(0) return _ENTITY_SUB(handle_entity, text) - - -@deprecated('pywikibot.tools.chars.url2string', since='6.2.0') -def url2unicode(title: str, encodings='utf-8') -> str: - """Convert URL-encoded text to unicode using several encoding. - - Uses the first encoding that doesn't cause an error. - - .. deprecated:: 6.2 - Use :func:`pywikibot.tools.chars.url2string` instead. - - :param title: URL-encoded character data to convert - :param encodings: Encodings to attempt to use during conversion. - :type encodings: str, list or Site - - :raise UnicodeError: Could not convert using any encoding. - """ - if isinstance(encodings, pywikibot.site.BaseSite): - # use all possible encodings from Site object - encodings = encodings.encodings() - issue_deprecation_warning( - 'Passing BaseSite object to encodings parameter', - 'BaseSite.encodings()', - depth=1, - since='6.2.0' - ) - - return pywikibot.tools.chars.url2string(title, encodings) diff --git a/tests/collections_tests.py b/tests/collections_tests.py index f2b80ec..2d9096d 100755 --- a/tests/collections_tests.py +++ b/tests/collections_tests.py @@ -1,14 +1,14 @@ #!/usr/bin/python3 """Tests for the Wikidata parts of the page module.""" # -# (C) Pywikibot team, 2019-2021 +# (C) Pywikibot team, 2019-2022 # # Distributed under the terms of the MIT license. # import unittest from contextlib import suppress -from pywikibot.page import ( +from pywikibot.page._collections import ( AliasesDict, ClaimCollection, LanguageDict, diff --git a/tox.ini b/tox.ini index 2e5202d..12254a4 100644 --- a/tox.ini +++ b/tox.ini @@ -148,7 +148,7 @@ pywikibot/fixes.py: E241 pywikibot/interwiki_graph.py: N802, N803, N806 pywikibot/login.py: N802, N816 - pywikibot/page/__init__.py: N802 + pywikibot/page/_basepage.py: N802 pywikibot/page/_collections.py: N802 pywikibot/pagegenerators.py: N802, N803, N806, N816 pywikibot/scripts/generate_family_file.py: T001 -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771825
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: I6da67c0fbbe2ee00645646695e35beb450bd382a Gerrit-Change-Number: 771825 Gerrit-PatchSet: 9 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [page] Split page/__init__.py (part 1)
by Xqt (Code Review)
18 Mar '22
18 Mar '22
Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771824
) Change subject: [page] Split page/__init__.py (part 1) ...................................................................... [page] Split page/__init__.py (part 1) Change-Id: I43a63115d081f08af311bb0e1a3470bc2b60de65 --- R pywikibot/page/_basepage.py 1 file changed, 0 insertions(+), 0 deletions(-) Approvals: Xqt: Verified; Looks good to me, approved diff --git a/pywikibot/page/__init__.py b/pywikibot/page/_basepage.py similarity index 100% rename from pywikibot/page/__init__.py rename to pywikibot/page/_basepage.py -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771824
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: I43a63115d081f08af311bb0e1a3470bc2b60de65 Gerrit-Change-Number: 771824 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [IMPR] Simplify creation of page._protection dict
by jenkins-bot (Code Review)
18 Mar '22
18 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771845
) Change subject: [IMPR] Simplify creation of page._protection dict ...................................................................... [IMPR] Simplify creation of page._protection dict Change-Id: I90b11d5ff1121c37036109e9505e0083be5c7c08 --- M pywikibot/site/_obsoletesites.py 1 file changed, 7 insertions(+), 7 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/site/_obsoletesites.py b/pywikibot/site/_obsoletesites.py index c5f0a50..ee44cbd 100644 --- a/pywikibot/site/_obsoletesites.py +++ b/pywikibot/site/_obsoletesites.py @@ -5,6 +5,7 @@ # Distributed under the terms of the MIT license. # import pywikibot +from pywikibot.backports import Dict, Tuple from pywikibot.exceptions import NoPageError from pywikibot.site._apisite import APISite from pywikibot.site._basesite import BaseSite @@ -27,23 +28,22 @@ pywikibot.error('Site {} has been closed. {}'.format(self.sitename, notice)) - def page_restrictions(self, page): + def page_restrictions( + self, page: 'pywikibot.Page') -> Dict[str, Tuple[str, str]]: """Return a dictionary reflecting page protections.""" if not page.exists(): raise NoPageError(page) if not hasattr(page, '_protection'): - page._protection = {'edit': ('steward', 'infinity'), - 'move': ('steward', 'infinity'), - 'delete': ('steward', 'infinity'), - 'upload': ('steward', 'infinity'), - 'create': ('steward', 'infinity')} + page._protection = dict.fromkeys( + ('create', 'delete', 'edit', 'move', 'upload'), + ('steward', 'infinity')) return page._protection def recentchanges(self, **kwargs) -> None: """An error instead of pointless API call.""" self._closed_error('No recent changes can be returned.') - def is_uploaddisabled(self): + def is_uploaddisabled(self) -> bool: """Return True if upload is disabled on site.""" if not hasattr(self, '_uploaddisabled'): self._uploaddisabled = True -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/771845
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: I90b11d5ff1121c37036109e9505e0083be5c7c08 Gerrit-Change-Number: 771845 Gerrit-PatchSet: 4 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...i18n[master]: Localisation updates from https://translatewiki.net.
by jenkins-bot (Code Review)
17 Mar '22
17 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/771579
) Change subject: Localisation updates from
https://translatewiki.net
. ...................................................................... Localisation updates from
https://translatewiki.net
. Change-Id: Ia8a04873275e8c121e88bd9c810e1ace8193d1c3 --- M blockpageschecker/sv.json M category/nb.json M category/sv.json M category_redirect/sv.json 4 files changed, 8 insertions(+), 1 deletion(-) Approvals: L10n-bot: Looks good to me, approved jenkins-bot: Verified diff --git a/blockpageschecker/sv.json b/blockpageschecker/sv.json index 1edf46d..d6c5ab2 100644 --- a/blockpageschecker/sv.json +++ b/blockpageschecker/sv.json @@ -1,8 +1,11 @@ { "@metadata": { "authors": [ + "Sabelöga", "WikiPhoenix" ] }, + "blockpageschecker-adding": "Bot: Lägger till sidlåsningsmall", + "blockpageschecker-modifying": "Bot: Modifierar föråldrad mall", "blockpageschecker-deleting": "Bot: Raderar föråldrad mall" } diff --git a/category/nb.json b/category/nb.json index f2609b2..1b6b025 100644 --- a/category/nb.json +++ b/category/nb.json @@ -9,6 +9,7 @@ }, "category-adding": "Robot: Legger til kategorien [[:Category:%(newcat)s|%(newcat)s]]", "category-also-in": "(også i %(alsocat)s)", + "category-clean": "Bot: Fjerner kategorien %(category)s, som allerede ligger i %(child)s", "category-listifying": "Robot: Omdanner liste fra %(fromcat)s ({{PLURAL:%(num)d|ett element|%(num)d elementer}})", "category-removing": "Robot: Fjerner ifra %(oldcat)s", "category-renamed": "Robot: Flyttet fra %(oldcat)s. Forfattere: %(authors)s", diff --git a/category/sv.json b/category/sv.json index 31fb46d..c1f7b0f 100644 --- a/category/sv.json +++ b/category/sv.json @@ -5,12 +5,14 @@ "Cybjit", "Jopparn", "Lokal Profil", + "Sabelöga", "Skalman", "WikiPhoenix" ] }, "category-adding": "Bot: Lägger till kategori [[:Category:%(newcat)s|%(newcat)s]]", "category-also-in": "(också i %(alsocat)s)", + "category-clean": "Bot: Tar bort kategori %(category)s som redan finns i %(child)s", "category-listifying": "Bot: Skapar en lista från %(fromcat)s (%(num)d st)", "category-removing": "Bot: Tar bort från %(oldcat)s", "category-renamed": "Bot: Flyttad från %(oldcat)s. Författare: %(authors)s", diff --git a/category_redirect/sv.json b/category_redirect/sv.json index e8b5374..788d5f1 100644 --- a/category_redirect/sv.json +++ b/category_redirect/sv.json @@ -2,10 +2,11 @@ "@metadata": { "authors": [ "Lokal Profil", + "Sabelöga", "WikiPhoenix" ] }, - "category_redirect-add-template": "Bot: lägger till kategoriomdirigeringsmall för underhåll", + "category_redirect-add-template": "Bot: Lägger till kategoriomdirigeringsmall för underhåll", "category_redirect-change-category": "Bot: Ändrar omdirigerad kategori [[:%(oldCatLink)s|%(oldCatTitle)s]] till [[:%(newCatLink)s|%(newCatTitle)s]]", "category_redirect-comment": "Underhållsbot för kategoriomdirigeringar", "category_redirect-edit-request": "Det har upptäckts att följande skyddade sidor kräver uppdateringar till kategorilänkar: %(itemlist)s", -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/771579
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n Gerrit-Branch: master Gerrit-Change-Id: Ia8a04873275e8c121e88bd9c810e1ace8193d1c3 Gerrit-Change-Number: 771579 Gerrit-PatchSet: 1 Gerrit-Owner: L10n-bot <l10n-bot(a)translatewiki.net> Gerrit-Reviewer: L10n-bot <l10n-bot(a)translatewiki.net> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [IMPR] Provide canonical name with BuiltinNamespace IntEnum
by jenkins-bot (Code Review)
17 Mar '22
17 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/769401
) Change subject: [IMPR] Provide canonical name with BuiltinNamespace IntEnum ...................................................................... [IMPR] Provide canonical name with BuiltinNamespace IntEnum - provide canonical property with BuiltinNamespace - replace Namespace.canonical_namespaces class attribute by canonical_namespaces class property Change-Id: I70e8cee96dafbbec25dbb3ba82828e890b16ae3e --- M pywikibot/site/_namespace.py 1 file changed, 22 insertions(+), 28 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/site/_namespace.py b/pywikibot/site/_namespace.py index 1618449..4dd6457 100644 --- a/pywikibot/site/_namespace.py +++ b/pywikibot/site/_namespace.py @@ -1,6 +1,6 @@ """Objects representing Namespaces of MediaWiki site.""" # -# (C) Pywikibot team, 2008-2021 +# (C) Pywikibot team, 2008-2022 # # Distributed under the terms of the MIT license. # @@ -9,8 +9,8 @@ from typing import Optional, Union from pywikibot.backports import Iterable as IterableType -from pywikibot.backports import List -from pywikibot.tools import ComparableMixin, SelfCallMixin +from pywikibot.backports import Dict, List +from pywikibot.tools import classproperty, ComparableMixin, SelfCallMixin NamespaceIDType = Union[int, str, 'Namespace'] @@ -40,6 +40,15 @@ CATEGORY = 14 CATEGORY_TALK = 15 + @property + def canonical(self) -> str: + """Canonical form of MediaWiki built-in namespace. + + .. versionadded:: 7.1 + """ + name = '' if self == 0 else self.name.capitalize().replace('_', ' ') + return name.replace('Mediawiki', 'MediaWiki') + class Namespace(Iterable, ComparableMixin): @@ -61,30 +70,6 @@ properties will have the same value. """ - # These are the MediaWiki built-in names for MW 1.14+. - # Namespace prefixes are always case-insensitive, but the - # canonical forms are capitalized. - canonical_namespaces = { - -2: 'Media', - -1: 'Special', - 0: '', - 1: 'Talk', - 2: 'User', - 3: 'User talk', - 4: 'Project', - 5: 'Project talk', - 6: 'File', - 7: 'File talk', - 8: 'MediaWiki', - 9: 'MediaWiki talk', - 10: 'Template', - 11: 'Template talk', - 12: 'Help', - 13: 'Help talk', - 14: 'Category', - 15: 'Category talk', - } - def __init__(self, id, canonical_name: Optional[str] = None, custom_name: Optional[str] = None, @@ -97,7 +82,7 @@ :param aliases: Aliases """ self.id = id - canonical_name = canonical_name or self.canonical_namespaces.get(id) + canonical_name = canonical_name or BuiltinNamespace(self.id).canonical assert custom_name is not None or canonical_name is not None, \ 'Namespace needs to have at least one name' @@ -120,6 +105,15 @@ for key, value in kwargs.items(): setattr(self, key, value) + @classproperty + def canonical_namespaces(cls) -> Dict[int, str]: + """Return the canonical forms of MediaWiki built-in namespaces. + + .. versionchanged:: 7.1 + implemented as classproperty using BuiltinNamespace IntEnum. + """ + return {item.value: item.canonical for item in BuiltinNamespace} + def _distinct(self): if self.custom_name == self.canonical_name: return [self.canonical_name] + self.aliases -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/769401
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: I70e8cee96dafbbec25dbb3ba82828e890b16ae3e Gerrit-Change-Number: 769401 Gerrit-PatchSet: 4 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [bugfix] Enable nested templates with MultiTemplateMatchBuilder
by jenkins-bot (Code Review)
15 Mar '22
15 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770956
) Change subject: [bugfix] Enable nested templates with MultiTemplateMatchBuilder ...................................................................... [bugfix] Enable nested templates with MultiTemplateMatchBuilder Bug: T110529 Change-Id: I411cb16b144c187df16402073b394ca6d2560976 --- M pywikibot/textlib.py 1 file changed, 8 insertions(+), 5 deletions(-) Approvals: Meno25: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index dc313df..9d32247 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -195,7 +195,7 @@ """Return a compiled regex to match template.""" # TODO: add ability to also match contents within the template # TODO: add option for template to be None to match any template - # TODO: use NESTED_TEMPLATE_REGEX with <parameters> instead of <params> + # TODO: merge regex with NESTED_TEMPLATE_REGEX namespace = self.site.namespaces[10] if isinstance(template, pywikibot.Page): if template.namespace() == 10: @@ -214,10 +214,13 @@ namespaces = [_ignore_case(ns) for ns in namespace] namespaces.append(_ignore_case('msg')) pattern = re.sub(r'_|\\ ', r'[_ ]', pattern) - templateRegex = re.compile( - r'\{\{ *(%(namespace)s:)?%(pattern)s(?P<parameters>\s*\|.+?|) *}}' - % {'namespace': ':|'.join(namespaces), 'pattern': pattern}, - flags) + templateRegexP = ( + r'{{\s*(%(namespace)s:)?%(pattern)s' + r'(?P<parameters>\s*\|[^{]+?' + r'((({{{[^{}]+?}}}|{{[^{}]+?}}|{[^{}]*?})[^{]*?)*?)?' + r'|)\s*}}' + ) % {'namespace': ':|'.join(namespaces), 'pattern': pattern} + templateRegex = re.compile(templateRegexP, flags) return templateRegex def search_any_predicate(self, templates): -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770956
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: I411cb16b144c187df16402073b394ca6d2560976 Gerrit-Change-Number: 770956 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Jon Harald Søby <jhsoby(a)gmail.com> Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [doc] Update documentation
by jenkins-bot (Code Review)
15 Mar '22
15 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770934
) Change subject: [doc] Update documentation ...................................................................... [doc] Update documentation Change-Id: Id5e1e26a3ddcd3ff61606bd6748b11c1c76d992e --- M pywikibot/families/wikinews_family.py 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Meno25: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/families/wikinews_family.py b/pywikibot/families/wikinews_family.py index 278b1d2..e7e6be3 100644 --- a/pywikibot/families/wikinews_family.py +++ b/pywikibot/families/wikinews_family.py @@ -1,6 +1,6 @@ """Family module for Wikinews.""" # -# (C) Pywikibot team, 2005-2021 +# (C) Pywikibot team, 2005-2022 # # Distributed under the terms of the MIT license. # -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770934
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: Id5e1e26a3ddcd3ff61606bd6748b11c1c76d992e Gerrit-Change-Number: 770934 Gerrit-PatchSet: 2 Gerrit-Owner: Meno25 <meno25mail(a)gmail.com> Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [flake] remove E501 flake8 exception at wikisource
by Xqt (Code Review)
15 Mar '22
15 Mar '22
Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770959
) Change subject: [flake] remove E501 flake8 exception at wikisource ...................................................................... [flake] remove E501 flake8 exception at wikisource Change-Id: I32bcb85f25a778fb1456473c8eaa98de92996d9c --- M pywikibot/families/wikisource_family.py 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Xqt: Verified; Looks good to me, approved diff --git a/pywikibot/families/wikisource_family.py b/pywikibot/families/wikisource_family.py index 7fc3000..3ca00b8 100644 --- a/pywikibot/families/wikisource_family.py +++ b/pywikibot/families/wikisource_family.py @@ -16,11 +16,11 @@ name = 'wikisource' closed_wikis = [ - #
https://noc.wikimedia.org/conf/highlight.php?file=dblists/closed.dblist
# noqa: E501 + #
https://noc.wikimedia.org/conf/highlight.php?file=dblists/closed.dblist
'ang', 'ht', ] removed_wikis = [ - #
https://noc.wikimedia.org/conf/highlight.php?file=dblists/deleted.dblist
# noqa: E501 + #
https://noc.wikimedia.org/conf/highlight.php?file=dblists/deleted.dblist
'tokipona', ] -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770959
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: I32bcb85f25a778fb1456473c8eaa98de92996d9c Gerrit-Change-Number: 770959 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-MessageType: merged
1
0
0
0
[Gerrit] ...core[master]: [IMPR] Make APISite._simple_request a public method
by jenkins-bot (Code Review)
15 Mar '22
15 Mar '22
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770135
) Change subject: [IMPR] Make APISite._simple_request a public method ...................................................................... [IMPR] Make APISite._simple_request a public method APISite._simple_request is already used outside the APISite class; therefore it should become a public method Change-Id: I1f99c49f0d700629b1260cb3bc016f9751e79cc2 --- M pywikibot/page/__init__.py M pywikibot/pagegenerators.py M pywikibot/site/_apisite.py M pywikibot/site/_datasite.py M pywikibot/site/_extensions.py M pywikibot/site/_upload.py M scripts/change_pagelang.py 7 files changed, 88 insertions(+), 82 deletions(-) Approvals: D3r1ck01: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 9f4671e..904358f 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -3093,7 +3093,7 @@ } if ccme: params['ccme'] = 1 - mailrequest = self.site._simple_request(**params) + mailrequest = self.site.simple_request(**params) maildata = mailrequest.submit() if 'emailuser' in maildata: diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py index a4f998d..f8f1b26 100644 --- a/pywikibot/pagegenerators.py +++ b/pywikibot/pagegenerators.py @@ -2901,7 +2901,7 @@ 'action': 'wbgetentities', 'props': 'sitelinks'} - wbrequest = repo._simple_request(**req) + wbrequest = repo.simple_request(**req) wbdata = wbrequest.submit() entities = (item for item in wbdata['entities'].values() if 'sitelinks' in item and site.dbName() in item['sitelinks']) diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index 491bbc4..118fed7 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -268,8 +268,17 @@ return self._request_class(kwargs)(site=self, **kwargs) + @deprecated('simple_request', since='7.1.0') def _simple_request(self, **kwargs): - """Create a request by defining all kwargs as parameters.""" + """DEPRECATED. Create a request using all kwargs as parameters.""" + return self.simple_request(**kwargs) + + def simple_request(self, **kwargs): + """Create a request by defining all kwargs as parameters. + + .. versionchanged:: 7.1 + `_simple_request` becomes a public method + """ return self._request_class({'parameters': kwargs}).create_simple( self, **kwargs) @@ -419,7 +428,7 @@ # csrf token introduced in MW 1.24 with suppress(Error): req_params['token'] = self.tokens['csrf'] - uirequest = self._simple_request(**req_params) + uirequest = self.simple_request(**req_params) uirequest.submit() self._loginstatus = _LoginStatus.NOT_LOGGED_IN @@ -464,7 +473,7 @@ """ if not hasattr(self, '_userinfo'): - uirequest = self._simple_request( + uirequest = self.simple_request( action='query', meta='userinfo', uiprop='blockinfo|hasmsg|groups|rights|ratelimits' @@ -527,7 +536,7 @@ meta='globaluserinfo', guiprop='groups|rights|editcount', ) - uirequest = self._simple_request(**param) + uirequest = self.simple_request(**param) uidata = uirequest.submit() assert 'query' in uidata, \ "API userinfo response lacks 'query' key" @@ -603,7 +612,7 @@ # TODO: Integrate into _userinfo if (force or not hasattr(self, '_useroptions') or self.user() != self._useroptions['_name']): - uirequest = self._simple_request( + uirequest = self.simple_request( action='query', meta='userinfo', uiprop='options' @@ -843,7 +852,7 @@ raise ValueError('text must be a string') if not text: return '' - req = self._simple_request(action='expandtemplates', text=text) + req = self.simple_request(action='expandtemplates', text=text) if title is not None: req['title'] = title if includecomments is True: @@ -1281,11 +1290,12 @@ return page._redirtarget title = page.title(with_section=False) - query = self._simple_request( + query = self.simple_request( action='query', prop='info', titles=title, - redirects=True) + redirects=True + ) result = query.submit() if 'query' not in result or 'redirects' not in result['query']: raise RuntimeError( @@ -1406,16 +1416,16 @@ types_wiki = self._paraminfo.parameter('tokens', 'type')['type'] types.extend(types_wiki) - req = self._simple_request(action='tokens', - type=self.validate_tokens(types)) + req = self.simple_request(action='tokens', + type=self.validate_tokens(types)) else: if all is not False: types_wiki = self._paraminfo.parameter('query+tokens', 'type')['type'] types.extend(types_wiki) - req = self._simple_request(action='query', meta='tokens', - type=self.validate_tokens(types)) + req = self.simple_request(action='query', meta='tokens', + type=self.validate_tokens(types)) req._warning_handler = warn_handler data = req.submit() @@ -1436,7 +1446,7 @@ :see:
https://www.mediawiki.org/wiki/API:Parse
""" - req = self._simple_request(action='parse', page=page) + req = self.simple_request(action='parse', page=page) data = req.submit() assert 'parse' in data, "API parse response lacks 'parse' key" assert 'text' in data['parse'], "API parse response lacks 'text' key" @@ -1516,7 +1526,7 @@ 'target': target, 'reason': reason} - req = self._simple_request(**params) + req = self.simple_request(**params) if target: self.lock_page(page) @@ -1686,7 +1696,7 @@ elif watch: pywikibot.warning("editpage: Invalid watch value '{}' ignored." .format(watch)) - req = self._simple_request(**params) + req = self.simple_request(**params) self.lock_page(page) try: @@ -1867,8 +1877,7 @@ # Send the merge API request token = self.tokens['csrf'] - req = self._simple_request(action='mergehistory', - token=token) + req = self.simple_request(action='mergehistory', token=token) req['from'] = source req['to'] = dest if reason: @@ -1966,12 +1975,12 @@ 'does not exist on {site}.') token = self.tokens['move'] self.lock_page(page) - req = self._simple_request(action='move', - noredirect=noredirect, - reason=summary, - movetalk=movetalk, - token=token, - to=newtitle) + req = self.simple_request(action='move', + noredirect=noredirect, + reason=summary, + movetalk=movetalk, + token=token, + to=newtitle) req['from'] = oldtitle # "from" is a python keyword try: result = req.submit() @@ -2076,7 +2085,7 @@ token=self.tokens['rollback'], user=user) self.lock_page(page) - req = self._simple_request(**parameters) + req = self.simple_request(**parameters) try: req.submit() except APIError as err: @@ -2174,7 +2183,7 @@ else: params['deletetalk'] = deletetalk - req = self._simple_request(**params) + req = self.simple_request(**params) self.lock_page(page) try: req.submit() @@ -2229,7 +2238,7 @@ 'fileids': fileids, } - req = self._simple_request(**params) + req = self.simple_request(**params) self.lock_page(page) try: req.submit() @@ -2312,7 +2321,7 @@ protections=protections, reason=reason, expiry=expiry) - req = self._simple_request(**parameters) + req = self.simple_request(**parameters) try: result = req.submit() except APIError as err: @@ -2391,12 +2400,11 @@ token = self.tokens['block'] if expiry is False: expiry = 'never' - req = self._simple_request(action='block', user=user.username, - expiry=expiry, reason=reason, token=token, - anononly=anononly, nocreate=nocreate, - autoblock=autoblock, noemail=noemail, - reblock=reblock, - allowusertalk=allowusertalk) + req = self.simple_request(action='block', user=user.username, + expiry=expiry, reason=reason, token=token, + anononly=anononly, nocreate=nocreate, + autoblock=autoblock, noemail=noemail, + reblock=reblock, allowusertalk=allowusertalk) data = req.submit() return data @@ -2412,10 +2420,10 @@ :type user: :py:obj:`pywikibot.User` :param reason: Reason for the unblock. """ - req = self._simple_request(action='unblock', - user=user.username, - token=self.tokens['block'], - reason=reason) + req = self.simple_request(action='unblock', + user=user.username, + token=self.tokens['block'], + reason=reason) data = req.submit() return data @@ -2440,7 +2448,7 @@ 'token': self.tokens['watch'], 'unwatch': unwatch, } - req = self._simple_request(**parameters) + req = self.simple_request(**parameters) results = req.submit() unwatch = 'unwatched' if unwatch else 'watched' return all(unwatch in r for r in results['watch']) @@ -2464,7 +2472,7 @@ links tables for any page that uses this page as a template. :return: True if API returned expected response; False otherwise """ - req = self._simple_request(action='purge', titles=list(set(pages))) + req = self.simple_request(action='purge', titles=list(set(pages))) if converttitles: req['converttitles'] = True if redirects: @@ -2531,9 +2539,8 @@ :see:
https://www.mediawiki.org/wiki/API:Stashimageinfo
""" props = props or False - req = self._simple_request( - action='query', prop='stashimageinfo', siifilekey=file_key, - siiprop=props) + req = self.simple_request(action='query', prop='stashimageinfo', + siifilekey=file_key, siiprop=props) return req.submit()['query']['stashimageinfo'][0] @need_right('upload') @@ -2610,7 +2617,7 @@ 'from{}'.format(old[0]): old[1], 'to{}'.format(diff[0]): diff[1]} - req = self._simple_request(**params) + req = self.simple_request(**params) data = req.submit() comparison = data['compare']['*'] return comparison diff --git a/pywikibot/site/_datasite.py b/pywikibot/site/_datasite.py index ebce64f..7662092 100644 --- a/pywikibot/site/_datasite.py +++ b/pywikibot/site/_datasite.py @@ -170,7 +170,7 @@ # an empty string ('&props=') but it should # result in a missing entry. props=props if props else False) - req = self._simple_request(**params) + req = self.simple_request(**params) data = req.submit() if 'success' not in data: raise APIError(data['errors'], '') @@ -206,7 +206,7 @@ req['sites'].append(p.site.dbName()) req['titles'].append(p._link._text) - req = self._simple_request(action='wbgetentities', **req) + req = self.simple_request(action='wbgetentities', **req) data = req.submit() for entity in data['entities']: if 'missing' in data['entities'][entity]: @@ -291,7 +291,7 @@ UserWarning, 2) params['data'] = json.dumps(data) - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -315,7 +315,7 @@ 'token': self.tokens['edit'], 'bot': bot, } - req = self._simple_request(**params) + req = self.simple_request(**params) data = req.submit() # Update the item if claim.getID() in entity.claims: @@ -351,7 +351,7 @@ params['value'] = json.dumps(claim._formatValue()) params['baserevid'] = claim.on_item.latest_revision_id - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -378,7 +378,7 @@ 'bot': bot, } - req = self._simple_request(**params) + req = self.simple_request(**params) data = req.submit() claim.on_item.latest_revision_id = data['pageinfo']['lastrevid'] return data @@ -433,7 +433,7 @@ params['reference'] = sourceclaim.hash params['snaks'] = json.dumps(snak) - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -472,7 +472,7 @@ params['snaktype'] = qualifier.getSnakType() params['property'] = qualifier.getID() - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -505,7 +505,7 @@ 'token': self.tokens['edit'], } - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -534,7 +534,7 @@ 'token': self.tokens['edit'], } - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -564,7 +564,7 @@ 'token': self.tokens['edit'] } - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('edit') @@ -590,7 +590,7 @@ } if bot: params['bot'] = 1 - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('item-merge') @@ -623,7 +623,7 @@ } if bot: params['bot'] = 1 - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() @need_right('item-redirect') @@ -644,7 +644,7 @@ 'token': self.tokens['edit'], 'bot': bot, } - req = self._simple_request(**params) + req = self.simple_request(**params) return req.submit() def search_entities(self, search: str, language: str, @@ -787,7 +787,7 @@ warn('Unknown parameter {} for action {}, ignored' .format(arg, action), UserWarning, 2) - req = self._simple_request(**params) + req = self.simple_request(**params) data = req.submit() return data diff --git a/pywikibot/site/_extensions.py b/pywikibot/site/_extensions.py index 38f53fa..4aca5d5 100644 --- a/pywikibot/site/_extensions.py +++ b/pywikibot/site/_extensions.py @@ -1,6 +1,6 @@ """Objects representing API interface to MediaWiki site extenstions.""" # -# (C) Pywikibot team, 2008-2021 +# (C) Pywikibot team, 2008-2022 # # Distributed under the terms of the MIT license. # @@ -40,7 +40,7 @@ for key, value in kwargs.items(): params['not' + key] = value - data = self._simple_request(**params).submit() + data = self.simple_request(**params).submit() notifications = data['query']['notifications']['list'] # Support API before 1.27.0-wmf.22 @@ -61,7 +61,7 @@ # is supported by the site kwargs = merge_unique_dicts(kwargs, action='echomarkread', token=self.tokens['edit']) - req = self._simple_request(**kwargs) + req = self.simple_request(**kwargs) data = req.submit() try: return data['query']['echomarkread']['result'] == 'success' @@ -315,8 +315,8 @@ :return: The API response. """ token = self.tokens['csrf'] - req = self._simple_request(action='thank', rev=revid, token=token, - source=source) + req = self.simple_request(action='thank', rev=revid, token=token, + source=source) data = req.submit() if data['result']['success'] != 1: raise APIError('Thanking unsuccessful', '') @@ -339,8 +339,8 @@ """ post_id = post.uuid token = self.tokens['csrf'] - req = self._simple_request(action='flowthank', - postid=post_id, token=token) + req = self.simple_request(action='flowthank', postid=post_id, + token=token) data = req.submit() if data['result']['success'] != 1: raise APIError('Thanking unsuccessful', '') @@ -361,9 +361,8 @@ :return: A dict representing the board's metadata. :rtype: dict """ - req = self._simple_request(action='flow', page=page, - submodule='view-topiclist', - vtllimit=1) + req = self.simple_request(action='flow', page=page, + submodule='view-topiclist', vtllimit=1) data = req.submit() return data['flow']['view-topiclist']['result']['topiclist'] @@ -428,9 +427,9 @@ :return: A dict representing the topic's data. :rtype: dict """ - req = self._simple_request(action='flow', page=page, - submodule='view-topic', - vtformat=content_format) + req = self.simple_request(action='flow', page=page, + submodule='view-topic', + vtformat=content_format) data = req.submit() return data['flow']['view-topic']['result']['topic'] @@ -448,9 +447,9 @@ :return: A dict representing the post data for the given UUID. :rtype: dict """ - req = self._simple_request(action='flow', page=page, - submodule='view-post', vppostId=post_id, - vpformat=content_format) + req = self.simple_request(action='flow', page=page, + submodule='view-post', vppostId=post_id, + vpformat=content_format) data = req.submit() return data['flow']['view-post']['result']['topic'] @@ -711,6 +710,6 @@ :return: The reduced link, without protocol prefix. :rtype: str """ - req = self._simple_request(action='shortenurl', url=url) + req = self.simple_request(action='shortenurl', url=url) data = req.submit() return data['shortenurl']['shorturl'] diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py index a8608ae..c85a397 100644 --- a/pywikibot/site/_upload.py +++ b/pywikibot/site/_upload.py @@ -288,7 +288,7 @@ if poll: # run a poll; not possible in first iteration assert file_key - req = self.site._simple_request( + req = self.site.simple_request( action='upload', token=token, filekey=file_key, @@ -440,7 +440,7 @@ raise Error( "User '{}' is not authorized to upload by URL on site {}." .format(self.site.user(), self)) - final_request = self.site._simple_request( + final_request = self.site.simple_request( action='upload', filename=file_page_title, url=self.url, comment=self.comment, text=self.text, token=token) @@ -509,7 +509,7 @@ assert file_key pywikibot.log('Waiting for upload to be published.') result = None - final_request = self.site._simple_request( + final_request = self.site.simple_request( action='upload', token=token, filekey=file_key, diff --git a/scripts/change_pagelang.py b/scripts/change_pagelang.py index ea205cb..75a3c04 100755 --- a/scripts/change_pagelang.py +++ b/scripts/change_pagelang.py @@ -66,7 +66,7 @@ 'title': page.title(), 'lang': self.opt.setlang, 'token': token} - r = self.site._simple_request(**parameters) + r = self.site.simple_request(**parameters) r.submit() pywikibot.output(color_format( '{lightpurple}{0}{default}: Setting ' @@ -84,7 +84,7 @@ 'prop': 'info', 'titles': page.title(), 'meta': 'siteinfo'} - r = self.site._simple_request(**parameters) + r = self.site.simple_request(**parameters) langcheck = r.submit()['query'] currentlang = '' -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/770135
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: I1f99c49f0d700629b1260cb3bc016f9751e79cc2 Gerrit-Change-Number: 770135 Gerrit-PatchSet: 4 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
17
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Results per page:
10
25
50
100
200