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
2026
April
March
February
January
2025
December
November
October
September
August
July
June
May
April
March
February
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
June 2025
----- 2026 -----
April 2026
March 2026
February 2026
January 2026
----- 2025 -----
December 2025
November 2025
October 2025
September 2025
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 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
97 discussions
Start a n
N
ew thread
[Gerrit] ...core[master]: IMPR: replace codecs.open() with pathlib methods in make_i18n_dict.py
by jenkins-bot (Code Review)
08 Jun '25
08 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152435?usp=email
) Change subject: IMPR: replace codecs.open() with pathlib methods in make_i18n_dict.py ...................................................................... IMPR: replace codecs.open() with pathlib methods in make_i18n_dict.py Bug: T395187 Change-Id: I2c583e915faf87f4f6e2d58adc95012a055916f0 --- M scripts/maintenance/make_i18n_dict.py 1 file changed, 17 insertions(+), 19 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py index d55c3cf..8cc41ad 100755 --- a/scripts/maintenance/make_i18n_dict.py +++ b/scripts/maintenance/make_i18n_dict.py @@ -30,16 +30,15 @@ >>> bot.to_json() """ # -# (C) Pywikibot team, 2013-2024 +# (C) Pywikibot team, 2013-2025 # # Distributed under the terms of the MIT license. # from __future__ import annotations -import codecs import json -import os from importlib import import_module +from pathlib import Path from pywikibot import config @@ -132,24 +131,23 @@ if not self.dict: self.run(quiet) - json_dir = os.path.join( - config.base_dir, 'scripts/i18n', self.scriptname) - if not os.path.exists(json_dir): - os.makedirs(json_dir) + json_dir = Path(config.base_dir, 'scripts/i18n', self.scriptname) + json_dir.mkdir(exist_ok=True) + for lang in self.dict: - file_name = os.path.join(json_dir, f'{lang}.json') - if os.path.isfile(file_name): - with codecs.open(file_name, 'r', 'utf-8') as json_file: - new_dict = json.load(json_file) - else: - new_dict = {} + new_dict = {} + + file_path = json_dir / f'{lang}.json' + if file_path.is_file(): + new_dict = json.load(file_path.read_text(encoding='utf-8')) + new_dict['@metadata'] = new_dict.get('@metadata', {'authors': []}) - with codecs.open(file_name, 'w', 'utf-8') as json_file: - new_dict.update(self.dict[lang]) - s = json.dumps(new_dict, ensure_ascii=False, sort_keys=True, - indent=indent, separators=(',', ': ')) - s = s.replace(' ' * indent, '\t') - json_file.write(s) + new_dict.update(self.dict[lang]) + s = json.dumps(new_dict, ensure_ascii=False, sort_keys=True, + indent=indent, separators=(',', ': ')) + s = s.replace(' ' * indent, '\t') + + file_path.write_text(s, encoding='utf-8') if __name__ == '__main__': -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152435?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I2c583e915faf87f4f6e2d58adc95012a055916f0 Gerrit-Change-Number: 1152435 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: IMPR: replace codecs.open() with pathlib methods in pagefromfile.py
by jenkins-bot (Code Review)
08 Jun '25
08 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152436?usp=email
) Change subject: IMPR: replace codecs.open() with pathlib methods in pagefromfile.py ...................................................................... IMPR: replace codecs.open() with pathlib methods in pagefromfile.py Bug: T395187 Change-Id: I4f5b7deaef2da6eb15f5846e90554db1ef9b2ef3 --- M scripts/pagefromfile.py 1 file changed, 4 insertions(+), 6 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py index 1217bbf..009c3e4 100755 --- a/scripts/pagefromfile.py +++ b/scripts/pagefromfile.py @@ -71,15 +71,15 @@ between them by specifying '\n' as a value. """ # -# (C) Pywikibot team, 2004-2024 +# (C) Pywikibot team, 2004-2025 # # Distributed under the terms of the MIT license. # from __future__ import annotations -import codecs import os import re +from pathlib import Path import pywikibot from pywikibot import config, i18n @@ -231,11 +231,9 @@ changed from iterator method to generator property """ pywikibot.info(f"\n\nReading '{self.filename}'...") + filepath = Path(self.filename) try: - with codecs.open(self.filename, 'r', - encoding=config.textfile_encoding) as f: - text = f.read() - + text = filepath.read_text(encoding=config.textfile_encoding) except OSError as e: pywikibot.error(e) return -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1152436?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I4f5b7deaef2da6eb15f5846e90554db1ef9b2ef3 Gerrit-Change-Number: 1152436 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: [FEAT] exturlusage: search for http and https by default
by jenkins-bot (Code Review)
08 Jun '25
08 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154384?usp=email
) Change subject: [FEAT] exturlusage: search for http and https by default ...................................................................... [FEAT] exturlusage: search for http and https by default Bug: T396280 Change-Id: Iec349bd21f3f0d04a43cf8d2d28d1735e8b5643e --- M pywikibot/site/_generators.py M tests/site_generators_tests.py 2 files changed, 29 insertions(+), 11 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py index 5deb56d..debd456 100644 --- a/pywikibot/site/_generators.py +++ b/pywikibot/site/_generators.py @@ -1317,8 +1317,8 @@ def exturlusage( self, url: str | None = None, - protocol: str | None = None, - namespaces: list[int] | None = None, + protocol: str | list[str] | None = None, + namespaces: NamespaceArgType = None, total: int | None = None, content: bool = False, ) -> Iterable[pywikibot.Page]: @@ -1331,9 +1331,11 @@ of the hostname :param namespaces: list of namespace numbers to fetch contribs from :param total: Maximum number of pages to retrieve in total - :param protocol: Protocol to search for, likely http or https, http by + :param protocol: list of protocols to search for, http and https by default. Full list shown on Special:LinkSearch wikipage """ + if isinstance(protocol, str): + protocol = [protocol] if url is not None: found_protocol, _, url = url.rpartition('://') @@ -1343,13 +1345,18 @@ url = None if found_protocol: - if protocol and protocol != found_protocol: - raise ValueError('Protocol was specified, but a different ' - 'one was found in searched url') - protocol = found_protocol - - if not protocol: - protocol = 'http' + if protocol: + if len(protocol) > 1: + raise ValueError( + 'More than one protocol was specified and a ' + 'protocol was found in searched url' + ) + if protocol[0] != found_protocol: + raise ValueError( + f'Protocol {protocol!r} was specified, but ' + f'{found_protocol!r} was found in searched url' + ) + protocol = [found_protocol] return self._generator(api.PageGenerator, type_arg='exturlusage', geuquery=url, geuprotocol=protocol, diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py index 0d3ab20..7bf8655 100755 --- a/tests/site_generators_tests.py +++ b/tests/site_generators_tests.py @@ -578,9 +578,10 @@ self.assertRaises(AssertionError): mysite.blocks(total=5, starttime=high, endtime=low, reverse=True) - def test_exturl_usage(self) -> None: + def test_exturlusage(self) -> None: """Test the site.exturlusage() method.""" mysite = self.get_site() + url = '
www.google.com
' eu = list(mysite.exturlusage(url, total=10)) self.assertLessEqual(len(eu), 10) @@ -591,6 +592,16 @@ self.assertIsInstance(link, pywikibot.Page) self.assertIn(link.namespace(), (2, 3)) + with self.assertRaises(ValueError): + mysite.exturlusage('
https://www.google.com
', protocol='http') + with self.assertRaises(ValueError): + mysite.exturlusage('
http://www.google.com
', protocol='https') + with self.assertRaises(ValueError): + mysite.exturlusage( + '
https://www.google.com
', + protocol=['http', 'https'], + ) + def test_protectedpages_create(self) -> None: """Test that protectedpages returns protected page titles.""" pages = list(self.get_site().protectedpages(protect_type='create', -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154384?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: Iec349bd21f3f0d04a43cf8d2d28d1735e8b5643e Gerrit-Change-Number: 1154384 Gerrit-PatchSet: 1 Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(a)gmail.com> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: tests: Validate that Timestamp.replace() returns a Timestamp
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154380?usp=email
) Change subject: tests: Validate that Timestamp.replace() returns a Timestamp ...................................................................... tests: Validate that Timestamp.replace() returns a Timestamp Change-Id: I3b6f3069a8c022f8d86ac95a4de871b3828382d6 --- M tests/time_tests.py 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/time_tests.py b/tests/time_tests.py index ec36c84..ab3a40c 100755 --- a/tests/time_tests.py +++ b/tests/time_tests.py @@ -64,6 +64,12 @@ ], } + def test_clone(self) -> None: + """Validate that Timestamp.replace() returns a Timestamp.""" + ts1 = Timestamp.now() + ts2 = ts1.replace() + self.assertIsInstance(ts2, Timestamp) + def test_set_from_timestamp(self) -> None: """Test creating instance from Timestamp object.""" for func in Timestamp.utcnow, Timestamp.nowutc: -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154380?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I3b6f3069a8c022f8d86ac95a4de871b3828382d6 Gerrit-Change-Number: 1154380 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: Style: Don't use "else" after "raise" statement
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154379?usp=email
) Change subject: Style: Don't use "else" after "raise" statement ...................................................................... Style: Don't use "else" after "raise" statement Change-Id: I5974ab240bd4d91df7e86e4dec19c78e69a11e94 --- M tests/gui_tests.py 1 file changed, 2 insertions(+), 3 deletions(-) Approvals: jenkins-bot: Verified Matěj Suchánek: Looks good to me, approved diff --git a/tests/gui_tests.py b/tests/gui_tests.py index 99be655..2413c80 100755 --- a/tests/gui_tests.py +++ b/tests/gui_tests.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Tests for the Tk UI.""" # -# (C) Pywikibot team, 2008-2024 +# (C) Pywikibot team, 2008-2025 # # Distributed under the terms of the MIT license. # @@ -94,8 +94,7 @@ dialog = tkinter.Tk() except RuntimeError as e: raise unittest.SkipTest(f'Skipping due to T380732 - {e}') - else: - dialog.destroy() + dialog.destroy() from pywikibot.userinterfaces.gui import EditBoxWindow, Tkdialog -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154379?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I5974ab240bd4d91df7e86e4dec19c78e69a11e94 Gerrit-Change-Number: 1154379 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: trsts: update pre-commit hooks
by Xqt (Code Review)
07 Jun '25
07 Jun '25
Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154377?usp=email
) Change subject: trsts: update pre-commit hooks ...................................................................... trsts: update pre-commit hooks Change-Id: I892869a7585ab9a7d078abb2b787560438b1da61 --- M .pre-commit-config.yaml 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: Xqt: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c87b9e4..f28e82a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,7 +58,7 @@ - id: rst-inline-touching-normal - id: text-unicode-replacement-char - repo:
https://github.com/astral-sh/ruff-pre-commit
- rev: v0.11.12 + rev: v0.11.13 hooks: - id: ruff args: -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154377?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I892869a7585ab9a7d078abb2b787560438b1da61 Gerrit-Change-Number: 1154377 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: doc: Update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154372?usp=email
) Change subject: doc: Update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst ...................................................................... doc: Update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst Change-Id: I1ade98182b42c98f875ae068db441f0c4f27a302 --- M AUTHORS.rst M ROADMAP.rst M scripts/CHANGELOG.rst 3 files changed, 14 insertions(+), 1 deletion(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/AUTHORS.rst b/AUTHORS.rst index 025a484..3e29b4e 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -194,6 +194,7 @@ Legoktm Leonardo Gregianin Lewis Cawte + Lichinsol Linedwell luzpaz diff --git a/ROADMAP.rst b/ROADMAP.rst index 3bfda15..feaec53 100644 --- a/ROADMAP.rst +++ b/ROADMAP.rst @@ -1,7 +1,11 @@ Current Release Changes ======================= -* (no changes yet) +* Add login methods overview to :mod:`login` module (:phab:`T396204`) +* Enable EmailAuth with :class:`login.ClientLoginManager` (:phab:`T395703`) +* Move :mod:`tools.threading.RLock<tools.threading>` to :mod:`backports` module (:phab:`T395182`) +* Only show the description passed to :class:`specialbots.UploadRobot` if it is to be verified (:phab:`T394895`) +* Add support for Python 3.15 (:phab:`T395177`) Current Deprecations diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst index e141564..c4b2143 100644 --- a/scripts/CHANGELOG.rst +++ b/scripts/CHANGELOG.rst @@ -1,6 +1,14 @@ Scripts Changelog ================= +10.2.0 +------ + +noreferences +^^^^^^^^^^^^ + +* Fix missing commas in L10N dicts + 10.1.0 ------ -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154372?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I1ade98182b42c98f875ae068db441f0c4f27a302 Gerrit-Change-Number: 1154372 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: [IMPR] use i18n.translate instead of dictonaries directly.
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1119711?usp=email
) Change subject: [IMPR] use i18n.translate instead of dictonaries directly. ...................................................................... [IMPR] use i18n.translate instead of dictonaries directly. Bug: T219094 Change-Id: I1574231107308298e2d10d11499ee21c747bfff3 --- M pywikibot/cosmetic_changes.py M scripts/category.py M scripts/commonscat.py M scripts/imagetransfer.py M scripts/interwiki.py M scripts/solve_disambiguation.py 6 files changed, 17 insertions(+), 10 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 4bf1fdc..ffc66cd 100644 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -374,7 +374,7 @@ subpage = False if self.template: try: - tmpl, loc = moved_links[self.site.code] + tmpl, loc = i18n.translate(self.site.code, moved_links) del tmpl except KeyError: loc = None diff --git a/scripts/category.py b/scripts/category.py index 15200be..7cd95e1 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -302,7 +302,7 @@ tmpl: Sequence = [] with suppress(KeyError): - tmpl, _loc = moved_links[page.site.code] + tmpl, _loc = i18n.translate(page.site.code, moved_links) if not isinstance(tmpl, list): tmpl = [tmpl] diff --git a/scripts/commonscat.py b/scripts/commonscat.py index 9074deb..1c7c4e0 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -261,7 +261,8 @@ def skipPage(page) -> bool: """Determine if the page should be skipped.""" try: - templates_to_ignore = ignoreTemplates[page.site.code] + templates_to_ignore = i18n.translate(page.site.code, + ignoreTemplates) except KeyError: return False diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index c6f7f3b..a1820a7 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -230,7 +230,8 @@ pywikibot.info('Adding nowCommons template to ' + sourceImagePage.title()) sourceImagePage.put(sourceImagePage.get() + '\n\n' - + nowCommonsTemplate[sourceSite.code] + + i18n.translate(sourceSite.code, + nowCommonsTemplate) % target_filename, summary=reason) diff --git a/scripts/interwiki.py b/scripts/interwiki.py index b19e0d1..e357276 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -1865,7 +1865,7 @@ if page.namespace() == 10: loc = None with suppress(KeyError): - tmpl, loc = moved_links[page.site.code] + tmpl, loc = i18n.translate(page.site.code, moved_links) del tmpl if loc is not None and loc in page.title(): pywikibot.info( @@ -2085,15 +2085,17 @@ """Test for allowed edits.""" tmpl = [] with suppress(KeyError): - tmpl, _ = moved_links[page.site.code] + tmpl, _ = i18n.translate(page.site.code, moved_links) if not isinstance(tmpl, list): tmpl = [tmpl] with suppress(KeyError): - tmpl += ignoreTemplates[page.site.code] + tmpl += i18n.translate(page.site.code, ignoreTemplates, + fallback=i18n.DEFAULT_FALLBACK) - tmpl += ignoreTemplates['_default'] + tmpl += i18n.translate('_default', ignoreTemplates, + fallback=i18n.DEFAULT_FALLBACK) if tmpl != []: templates = page.templatesWithParams() for template in templates: diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py index fe9a3fe..ef114b1 100755 --- a/scripts/solve_disambiguation.py +++ b/scripts/solve_disambiguation.py @@ -1037,7 +1037,9 @@ if params and template == primary_page: baseTerm = params[1] break - disambTitle = primary_topic_format[self.site.lang] % baseTerm + disambTitle = i18n.translate( + self.site.lang, + primary_topic_format) % baseTerm try: page2 = pywikibot.Page( pywikibot.Link(disambTitle, self.site)) @@ -1078,7 +1080,8 @@ try: page2 = pywikibot.Page( pywikibot.Link( - primary_topic_format[self.site.lang] + i18n.translate(self.site.lang, + primary_topic_format) % page.title(), self.site)) links = page2.linkedPages() -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1119711?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I1574231107308298e2d10d11499ee21c747bfff3 Gerrit-Change-Number: 1119711 Gerrit-PatchSet: 7 Gerrit-Owner: Lichinsol <vaibhavjoshi1411(a)gmail.com> Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-CC: Matěj Suchánek <matejsuchanek97(a)gmail.com>
1
0
0
0
[Gerrit] ...core[master]: Tests: replace codecs.open with pathlib methods in textlib_tests.py
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154361?usp=email
) Change subject: Tests: replace codecs.open with pathlib methods in textlib_tests.py ...................................................................... Tests: replace codecs.open with pathlib methods in textlib_tests.py Also: - remove unused enwiki_help_editing.meta test file - read the enwiki_help_editing.page content in setUpClass method - drop multiple test text files, they are never implemented for 13 years - simplify test methods Bug: T395187 Change-Id: I2a710369e0154668b4738d8d81009161620c0cb8 --- D tests/pages/enwiki_help_editing.meta M tests/textlib_tests.py 2 files changed, 34 insertions(+), 47 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/tests/pages/enwiki_help_editing.meta b/tests/pages/enwiki_help_editing.meta deleted file mode 100644 index 64c439c..0000000 --- a/tests/pages/enwiki_help_editing.meta +++ /dev/null @@ -1,2 +0,0 @@ -Help:Editing. (2012, March 9). In Wikipedia, The Free Encyclopedia. Retrieved 17:43, March 18, 2012, from
https://en.wikipedia.org/w/index.php?title=Help:Editing&oldid=480978372
-Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 9203773..b918223 100755 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -1,19 +1,18 @@ #!/usr/bin/env python3 """Test textlib module.""" # -# (C) Pywikibot team, 2011-2024 +# (C) Pywikibot team, 2011-2025 # # Distributed under the terms of the MIT license. # from __future__ import annotations -import codecs import functools -import os import re import unittest from collections import OrderedDict from contextlib import nullcontext, suppress +from pathlib import Path from unittest import mock import pywikibot @@ -30,87 +29,77 @@ ) -files = {} -dirname = os.path.join(os.path.dirname(__file__), 'pages') - -for f in ['enwiki_help_editing']: - with codecs.open(os.path.join(dirname, f + '.page'), - 'r', 'utf-8') as content: - files[f] = content.read() - - class TestSectionFunctions(TestCase): """Test wikitext section handling function.""" net = False + @classmethod + def setUpClass(cls): + """Read test content.""" + dirname = Path(__file__).parent / 'pages' + file = dirname / 'enwiki_help_editing.page' + cls.content = file.read_text(encoding='utf-8') + def setUp(self): """Setup tests.""" self.catresult1 = '[[Category:Cat1]]\n[[Category:Cat2]]\n' super().setUp() - @staticmethod - def contains(fn, sn): - """Invoke does_text_contain_section().""" - return textlib.does_text_contain_section( - files[fn], sn) + def assertContains(self, sn, msg=None): + """Test that file content contains sn.""" + self.assertTrue(textlib.does_text_contain_section(self.content, sn), + msg) - def assertContains(self, fn, sn, *args, **kwargs): - """Test that files[fn] contains sn.""" - self.assertEqual(self.contains(fn, sn), True, *args, **kwargs) - - def assertNotContains(self, fn, sn, *args, **kwargs): - """Test that files[fn] does not contain sn.""" - self.assertEqual(self.contains(fn, sn), False, *args, **kwargs) + def assertNotContains(self, sn, msg=None): + """Test that file content does not contain sn.""" + self.assertFalse(textlib.does_text_contain_section(self.content, sn), + msg) def testCurrentBehaviour(self) -> None: """Test that 'Editing' is found.""" - self.assertContains('enwiki_help_editing', 'Editing') + self.assertContains('Editing') def testSpacesInSection(self) -> None: """Test with spaces in section.""" - self.assertContains('enwiki_help_editing', 'Minor_edits') - self.assertNotContains('enwiki_help_editing', '#Minor edits', + self.assertContains('Minor_edits') + self.assertNotContains('#Minor edits', "Incorrect, '#Minor edits' does not work") - self.assertNotContains('enwiki_help_editing', 'Minor Edits', + self.assertNotContains('Minor Edits', 'section hashes are case-sensitive') - self.assertNotContains('enwiki_help_editing', 'Minor_Edits', + self.assertNotContains('Minor_Edits', 'section hashes are case-sensitive') @unittest.expectedFailure # TODO: T133276 def test_encoded_chars_in_section(self) -> None: """Test encoded chars in section.""" - self.assertContains( - 'enwiki_help_editing', 'Talk_.28discussion.29_pages', - 'As used in the TOC') + self.assertContains('Talk_.28discussion.29_pages', + 'As used in the TOC') def test_underline_characters_in_section(self) -> None: """Test with underline chars in section.""" - self.assertContains('enwiki_help_editing', 'Talk_(discussion)_pages', + self.assertContains('Talk_(discussion)_pages', 'Understood by mediawiki') def test_spaces_outside_section(self) -> None: """Test with spaces around section.""" - self.assertContains('enwiki_help_editing', 'Naming and_moving') - self.assertContains('enwiki_help_editing', ' Naming and_moving ') - self.assertContains('enwiki_help_editing', ' Naming and_moving_') + self.assertContains('Naming and_moving') + self.assertContains(' Naming and_moving ') + self.assertContains(' Naming and_moving_') def test_link_in_section(self) -> None: """Test with link inside section.""" # section is ==[[Wiki markup]]== - self.assertContains('enwiki_help_editing', '[[Wiki markup]]', - 'Link as section header') - self.assertContains('enwiki_help_editing', '[[:Wiki markup]]', + self.assertContains('[[Wiki markup]]', 'Link as section header') + self.assertContains('[[:Wiki markup]]', 'section header link with preleading colon') - self.assertNotContains('enwiki_help_editing', 'Wiki markup', - 'section header must be a link') + self.assertNotContains('Wiki markup', 'section header must be a link') # section is ===[[:Help]]ful tips=== - self.assertContains('enwiki_help_editing', '[[Help]]ful tips', - 'Containing link') - self.assertContains('enwiki_help_editing', '[[:Help]]ful tips', + self.assertContains('[[Help]]ful tips', 'Containing link') + self.assertContains('[[:Help]]ful tips', 'Containing link with preleading colon') - self.assertNotContains('enwiki_help_editing', 'Helpful tips', + self.assertNotContains('Helpful tips', 'section header must contain a link') -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154361?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I2a710369e0154668b4738d8d81009161620c0cb8 Gerrit-Change-Number: 1154361 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
[Gerrit] ...core[master]: IMPR: replace codecs.open with open in category script
by jenkins-bot (Code Review)
07 Jun '25
07 Jun '25
jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154356?usp=email
) Change subject: IMPR: replace codecs.open with open in category script ...................................................................... IMPR: replace codecs.open with open in category script Bug: T395187 Change-Id: Ie41ec63f880a173aeb98e4d7e4a0cb5ec149f669 --- M scripts/category.py 1 file changed, 1 insertion(+), 2 deletions(-) Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved diff --git a/scripts/category.py b/scripts/category.py index 040886a..b018035 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -159,7 +159,6 @@ # from __future__ import annotations -import codecs import math import os import pickle @@ -1413,7 +1412,7 @@ pywikibot.info() if self.filename: pywikibot.info('Saving results in ' + self.filename) - with codecs.open(self.filename, 'a', encoding='utf-8') as f: + with open(self.filename, 'a', encoding='utf-8') as f: f.write(tree) else: pywikibot.stdout(tree) -- To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154356?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: Ie41ec63f880a173aeb98e4d7e4a0cb5ec149f669 Gerrit-Change-Number: 1154356 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <info(a)gno.de> Gerrit-Reviewer: Xqt <info(a)gno.de> Gerrit-Reviewer: jenkins-bot
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
9
10
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
Results per page:
10
25
50
100
200