jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154358?usp=email )
Change subject: IMPR: replace codecs.open with open or Path.read_text method in upload.py
......................................................................
IMPR: replace codecs.open with open or Path.read_text method in upload.py
Also validate whether -descfile exists
Bug: T395187
Change-Id: I0835072deae9e6661cc16d7fbf883a4a267153ff
---
M scripts/upload.py
1 file changed, 12 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/upload.py b/scripts/upload.py
index c766801..20b854e 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -45,7 +45,8 @@
-summary: [str] Pick a custom edit summary for the bot.
--descfile: [str] Specify a filename where the description is stored
+-descfile: [str] Specify a filename where the description is stored.
+ An error message is printed if the file does not exist.
It is possible to combine ``-abortonwarn`` and ``-ignorewarn`` so that
@@ -66,16 +67,16 @@
parameter, and for a description.
"""
#
-# (C) Pywikibot team, 2003-2024
+# (C) Pywikibot team, 2003-2025
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
-import codecs
import math
import os
import re
+from pathlib import Path
import pywikibot
from pywikibot.bot import suggest_help
@@ -183,9 +184,14 @@
pywikibot.error('Both a description and a -descfile were '
'provided. Please specify only one of those.')
return
- with codecs.open(description_file,
- encoding=pywikibot.config.textfile_encoding) as f:
- description = f.read().replace('\r\n', '\n')
+
+ filepath = Path(description_file)
+ if not filepath.is_file() or filepath.is_symlink():
+ pywikibot.Error('Invalid filename given with -descfile')
+ return
+
+ description = filepath.read_text(
+ encoding=pywikibot.config.textfile_encoding).replace('\r\n', '\n')
while not ('://' in url or os.path.exists(url)):
if not url:
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154358?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: I0835072deae9e6661cc16d7fbf883a4a267153ff
Gerrit-Change-Number: 1154358
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154357?usp=email )
Change subject: IMPR: replace codecs.open with open or pathlib methods in solve_disambiguation
......................................................................
IMPR: replace codecs.open with open or pathlib methods in solve_disambiguation
Bug: T395187
Change-Id: Id494aedc46cc1522ac81728ee9782b879cb89a0a
---
M scripts/solve_disambiguation.py
1 file changed, 20 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 71b4f98..762ede1 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -74,17 +74,16 @@
"""
#
-# (C) Pywikibot team, 2003-2024
+# (C) Pywikibot team, 2003-2025
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
-import codecs
-import os
import re
from contextlib import suppress
from itertools import chain
+from pathlib import Path
from typing import Generator
import pywikibot
@@ -456,28 +455,29 @@
self.disamb_page = disamb_page
self.enabled = enabled
self.ignorelist = set()
+ self._read_ignorelist(config.datafilepath('disambiguations'))
- folder = config.datafilepath('disambiguations')
- if os.path.exists(folder):
- self._read_ignorelist(folder)
-
- def _read_ignorelist(self, folder) -> None:
+ def _read_ignorelist(self, folder: str) -> None:
"""Read pages to be ignored from file.
- :type folder: str
+ The file is stored in the disambiguation/ subdir.
"""
- filename = os.path.join(
- folder, self.disamb_page.title(as_filename=True) + '.txt')
+ folderpath = Path(folder)
+ if not folderpath.is_dir() or folderpath.is_symlink():
+ return
+
+ filepath = folderpath / (
+ self.disamb_page.title(as_filename=True) + '.txt')
+ if not filepath.is_file() or filepath.is_symlink():
+ return
# The file is stored in the disambiguation/ subdir.
# Create if necessary.
- with suppress(IOError), codecs.open(filename, 'r', 'utf-8') as f:
- for line in f:
- # remove trailing newlines and carriage returns
- line = line.rstrip('\r\n')
- # skip empty lines
- if line:
- self.ignorelist.add(line)
+ with suppress(IOError):
+ text = filepath.read_text(encoding='utf-8')
+
+ # skip empty lines
+ self.ignorelist = {line for line in text.splitlines() if line}
def isIgnored(self, ref_page) -> bool: # noqa: N802
"""Return if ref_page is to be ignored.
@@ -495,6 +495,7 @@
# backward compatibility
if isinstance(page_titles, pywikibot.Page):
page_titles = [page_titles.title(as_url=True)]
+
if self.enabled:
# Skip this occurrence next time.
filename = config.datafilepath(
@@ -502,7 +503,7 @@
self.disamb_page.title(as_url=True) + '.txt')
# Open file for appending. If none exists, create a new one.
- with suppress(IOError), codecs.open(filename, 'a', 'utf-8') as f:
+ with suppress(IOError), open(filename, 'a', encoding='utf-8') as f:
f.write('\n'.join(page_titles) + '\n')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154357?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: Id494aedc46cc1522ac81728ee9782b879cb89a0a
Gerrit-Change-Number: 1154357
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156784?usp=email )
Change subject: doc: Fix docstring in GeneratorsMixin.pagetemplates
......................................................................
doc: Fix docstring in GeneratorsMixin.pagetemplates
Change-Id: I72762e604836cf103be74e3ba9556a8bb07ad5ca
---
M pywikibot/site/_generators.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 94ea8fc..7d8534c 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -533,7 +533,7 @@
) -> Iterable[pywikibot.Page]:
"""Iterate pages transcluded (not just linked) on the page.
- .. note: You should not use this method directly; use
+ .. note:: You should not use this method directly; use
:meth:`pywikibot.Page.itertemplates` instead.
.. seealso::
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156784?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: I72762e604836cf103be74e3ba9556a8bb07ad5ca
Gerrit-Change-Number: 1156784
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156773?usp=email )
Change subject: doc: remove documentation for removed parametes in WikiBlameMixin
......................................................................
doc: remove documentation for removed parametes in WikiBlameMixin
Bug: T392694
Change-Id: Ic28251ac41b89ba5a45234848ad8c062d03e9917
---
M pywikibot/page/_toolforge.py
1 file changed, 0 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/page/_toolforge.py b/pywikibot/page/_toolforge.py
index e491b88..eb691f2 100644
--- a/pywikibot/page/_toolforge.py
+++ b/pywikibot/page/_toolforge.py
@@ -156,13 +156,6 @@
percentage edits.
:param max_pct_sum: Only return authors until the prcentage sum
reached *max_pct_sum*.
- :param revid: The revision id for the authors should be found.
- If ``None`` or ``0``, the latest revision is be used. Cannot
- be used together with *date*.
- :param date: The revision date for the authors should be found.
- If ``None``, it will be ignored. Cannot be used together
- with *revid*. If the parameter is a string it must be given
- in the form ``YYYY-MM-DD``
:return: Character count and percentage of edits for each
username.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156773?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: Ic28251ac41b89ba5a45234848ad8c062d03e9917
Gerrit-Change-Number: 1156773
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156412?usp=email )
Change subject: doc: Fix docsig SIG302 issues
......................................................................
doc: Fix docsig SIG302 issues
Change-Id: I5208733aaa60d7307c5a7f98c5b737d32d7df32a
---
M pyproject.toml
M pywikibot/comms/http.py
M pywikibot/date.py
M pywikibot/site/_extensions.py
4 files changed, 21 insertions(+), 24 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pyproject.toml b/pyproject.toml
index 5e0cf61..d963a79 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -156,7 +156,6 @@
"SIG202",
"SIG203",
"SIG301",
- "SIG302",
"SIG401",
"SIG402",
"SIG404",
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 2044b18..8fab9f0 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -263,10 +263,10 @@
:param site: The Site to connect to
:param uri: the URI to retrieve
- :keyword Optional[CodecInfo, str] charset: Either a valid charset
- (usable for str.decode()) or None to automatically chose the
- charset from the returned header (defaults to latin-1)
- :keyword Optional[str] protocol: a url scheme
+ :keyword CodecInfo or str or None charset: Either a valid charset
+ (usable for `str.decode()`) or None to automatically chose the
+ charset from the returned header (defaults to latin-1).
+ :keyword str | None protocol: a url scheme
:return: The received data Response
"""
kwargs.setdefault('verify', site.verify_SSL_certificate())
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 6fa55e7..237afac 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -1,6 +1,6 @@
"""Date data and manipulation module."""
#
-# (C) Pywikibot team, 2003-2024
+# (C) Pywikibot team, 2003-2025
#
# Distributed under the terms of the MIT license.
#
@@ -475,26 +475,24 @@
lambda v: dh(v, 'pattern string', encf, decf)
- :param encf:
- Converts from an integer parameter to another integer or a tuple of
- integers. Depending on the pattern, each integer will be converted to a
- proper string representation, and will be passed as a format argument
- to the pattern::
-
- pattern % encf(value)
-
- This function is a complement of decf.
-
.. versionchanged:: 9.0
*filter* parameter was renamed to *filter_func*
- :param decf:
- Converts a tuple/list of non-negative integers found in the original
- value string
- into a normalized value. The normalized value can be passed right back
- into dh() to produce the original string. This function is a complement
- of encf. dh() interprets %d as a decimal and %s as a roman
- numeral number.
+ :param encf: Converts from an integer parameter to another integer
+ or a tuple of integers. Depending on the pattern, each integer
+ will be converted to a proper string representation, and will be
+ passed as a format argument to the pattern::
+
+ pattern % encf(value)
+
+ This function is a complement of *decf*.
+
+ :param decf: Converts a tuple or list of non-negative integers found
+ in the original value string into a normalized value. The
+ normalized value can be passed right back into :func:`dh` to
+ produce the original string. This function is a complement of
+ *encf*. :func:`dh` interprets ``%d`` as a decimal and ``%s`` as
+ a roman numeral number.
"""
_compPattern, strPattern, decoders = escapePattern2(pattern)
# Encode an integer value into a textual form.
diff --git a/pywikibot/site/_extensions.py b/pywikibot/site/_extensions.py
index 707d2a3..66ea1ff 100644
--- a/pywikibot/site/_extensions.py
+++ b/pywikibot/site/_extensions.py
@@ -28,7 +28,7 @@
def notifications(self, **kwargs):
"""Yield Notification objects from the Echo extension.
- :keyword Optional[str] format: If specified, notifications will
+ :keyword str | None format: If specified, notifications will
be returned formatted this way. Its value is either ``model``,
``special`` or ``None``. Default is ``special``.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156412?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: I5208733aaa60d7307c5a7f98c5b737d32d7df32a
Gerrit-Change-Number: 1156412
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156391?usp=email )
Change subject: doc: update documentation with docformatter
......................................................................
doc: update documentation with docformatter
Change-Id: I924104a2ab267c369c6d53898ec1e3f7f32858dd
---
M make_dist.py
M pwb.py
M pywikibot/__init__.py
M pywikibot/_wbtypes.py
M pywikibot/bot.py
M pywikibot/bot_choice.py
M pywikibot/comms/eventstreams.py
M pywikibot/comms/http.py
M pywikibot/config.py
M pywikibot/cosmetic_changes.py
M pywikibot/daemonize.py
M pywikibot/data/api/_generators.py
M pywikibot/data/api/_optionset.py
M pywikibot/data/api/_paraminfo.py
M pywikibot/data/api/_requests.py
M pywikibot/data/memento.py
M pywikibot/data/sparql.py
M pywikibot/data/superset.py
M pywikibot/data/wikistats.py
M pywikibot/date.py
M pywikibot/diff.py
M pywikibot/editor.py
M pywikibot/exceptions.py
M pywikibot/family.py
M pywikibot/i18n.py
M pywikibot/interwiki_graph.py
M pywikibot/logentries.py
M pywikibot/logging.py
M pywikibot/login.py
M pywikibot/page/_basepage.py
M pywikibot/page/_collections.py
M pywikibot/page/_filepage.py
M pywikibot/page/_links.py
M pywikibot/page/_revision.py
M pywikibot/page/_user.py
M pywikibot/page/_wikibase.py
M pywikibot/pagegenerators/__init__.py
M pywikibot/pagegenerators/_factory.py
M pywikibot/pagegenerators/_filters.py
M pywikibot/pagegenerators/_generators.py
M pywikibot/proofreadpage.py
M pywikibot/scripts/generate_user_files.py
M pywikibot/scripts/wrapper.py
M pywikibot/site/_apisite.py
M pywikibot/site/_basesite.py
M pywikibot/site/_datasite.py
M pywikibot/site/_decorators.py
M pywikibot/site/_extensions.py
M pywikibot/site/_generators.py
M pywikibot/site/_namespace.py
M pywikibot/site/_siteinfo.py
M pywikibot/specialbots/_upload.py
M pywikibot/textlib.py
M pywikibot/throttle.py
M pywikibot/time.py
M pywikibot/tools/__init__.py
M pywikibot/tools/_deprecate.py
M pywikibot/tools/djvu.py
M pywikibot/tools/threading.py
M pywikibot/userinterfaces/gui.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/userinterfaces/transliteration.py
M pywikibot/version.py
M scripts/archivebot.py
M scripts/basic.py
M scripts/blockpageschecker.py
M scripts/category.py
M scripts/checkimages.py
M scripts/claimit.py
M scripts/clean_sandbox.py
M scripts/commonscat.py
M scripts/coordinate_import.py
M scripts/create_isbn_edition.py
M scripts/data_ingestion.py
M scripts/delete.py
M scripts/djvutext.py
M scripts/harvest_template.py
M scripts/image.py
M scripts/imagetransfer.py
M scripts/interwiki.py
M scripts/interwikidata.py
M scripts/listpages.py
M scripts/newitem.py
M scripts/noreferences.py
M scripts/pagefromfile.py
M scripts/patrol.py
M scripts/protect.py
M scripts/redirect.py
M scripts/reflinks.py
M scripts/replace.py
M scripts/revertbot.py
M scripts/solve_disambiguation.py
M scripts/speedy_delete.py
M scripts/template.py
M scripts/templatecount.py
M scripts/weblinkchecker.py
M setup.py
M tests/api_tests.py
M tests/aspects.py
M tests/basepage.py
M tests/bot_tests.py
M tests/cosmetic_changes_tests.py
M tests/file_tests.py
M tests/http_tests.py
M tests/i18n_tests.py
M tests/link_tests.py
M tests/login_tests.py
M tests/memento_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/pwb_tests.py
M tests/reflinks_tests.py
M tests/script_tests.py
M tests/site_detect_tests.py
M tests/site_generators_tests.py
M tests/textlib_tests.py
M tests/thanks_tests.py
M tests/token_tests.py
M tests/utils.py
M tests/wbtypes_tests.py
M tests/wikibase_tests.py
121 files changed, 1,314 insertions(+), 1,241 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1156391?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: I924104a2ab267c369c6d53898ec1e3f7f32858dd
Gerrit-Change-Number: 1156391
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot