jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1358413?usp=email )
Change subject: doc: Update documentation, including ROADMAP.rst and
CHANGELOG.rst
......................................................................
doc: Update documentation, including ROADMAP.rst and CHANGELOG.rst
Change-Id: I8050ee8eb2c48a70a1f84dbeb1a4cf8eaf0053e2
---
M HISTORY.rst
M ROADMAP.rst
M pywikibot/textlib.py
M pywikibot/time.py
M scripts/CHANGELOG.rst
5 files changed, 60 insertions(+), 30 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index 0b66973..09098ae 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -10,7 +10,7 @@
* Various performance, stability, and code quality improvements.
* Fix ZIP discovery and duplicate import paths in
:func:`config.register_families_folder`.
* Unify negative :ref:`page generator options<GENERATOR OPTIONS>`.
(:phab:`T219282`)
-* Keep the sign of negative POSIX
:class:`timestamps<<pywikibot.time.Timestamp>`.
+* Keep the sign of negative POSIX
:class:`timestamps<pywikibot.time.Timestamp>`.
* Use the :attr:`page.BasePage.site` in :meth:`page.BasePage.change_category`
when calling
:func:`textlib.replaceCategoryLinks` to respect category namespaces and
footer rules.
* Validate :attr:`pywikibot.Link.title` length in UTF-8 bytes within
:meth:`pywikibot.Link.parse`.
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 48a8e5f..da520d0 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -3,6 +3,11 @@
* Avoid mutating class attribute
:attr:`BaseBot.available_options<bot.BaseBot.available_options>`
with :attr:`BaseBot.update_options<bot.BaseBot.update_options>`.
(:phab:`T439883`)
+* Update translations (i18n).
+* Reject nested wikilinks in file captions with
:attr:`textlib.FILE_LINK_REGEX`. (:phab:`T396721`)
+* Various performance, stability, and code quality improvements.
+* Speed up parsing of API ISO timestamps in :meth:`Timestamp._from_iso8601()
+ <pywikibot.time.Timestamp._from_iso8601>`.
Deprecations
============
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 58bcc75..c5d6296 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -40,20 +40,23 @@
# cache for replaceExcept to avoid recompile or regexes each call
_regex_cache: dict[str, re.Pattern[str]] = {}
-# The regex below collects nested templates, providing simpler
-# identification of templates used at the top-level of wikitext.
-# It doesn't match {{{1|...}}}, however it also does not match templates
-# with a numerical name. e.g. {{1|..}}. It will correctly match {{{x}} as
-# being {{x}} with leading '{' left in the wikitext.
-# Prefix msg: is not included in the 'name' group, but all others are
-# included for backwards compatibility with TEMP_REGEX.
-# Only parser functions using # are excluded.
-# When more than two levels of templates are found, this regex will
-# capture from the beginning of the first {{ to the end of the last }},
-# with wikitext between templates as part of the parameters of the first
-# template in the wikitext.
-# This ensures it fallsback to a safe mode for replaceExcept, as it
-# ensures that any replacement will not occur within template text.
+#: The regex below collects nested templates, providing simpler
+#: identification of templates used at the top-level of wikitext. It
+#: doesn't match ``{{{1|...}}}``, however it also does not match
+#: templates with a numerical name. e.g. ``{{1|..}}``. It will correctly
+#: match ``{{{x}}`` as being ``{{x}}`` with leading ``'{'`` left in the
+#: wikitext. The outdated prefix ``msg:`` is not included in the *name*
+#: group. Only parser functions using ``#`` are excluded. When more than
+#: two levels of templates are found, this regex will capture from the
+#: beginning of the first ``{{`` to the end of the last ``}}``, with
+#: wikitext between templates as part of the parameters of the first
+#: template in the wikitext. This ensures it fallsback to a safe mode
+#: for replaceExcept, as it ensures that any replacement will not occur
+#: within template text.
+#:
+#: .. important::
+#: Don't use this regex directly; use
+#: :func:`extract_templates_and_params_regex_simple` instead.
NESTED_TEMPLATE_REGEX = re.compile(r"""
{{\s*(?:msg:\s*)?
(?P<name>[^{\|#0-9][^{\|#]*?)\s*
@@ -70,18 +73,22 @@
(?P<unhandled_depth>{{\s*[^{\|#0-9][^{\|#]*?\s* [^{]* {{ .* }})
""", re.VERBOSE | re.DOTALL)
-# Regex matching file links with optional parameters.
-#
-# Captures the filename and parameters, including links within the
-# parameters. Inner wikilinks cannot contain nested wikilinks.
-# The Namespace names must be substituted into the pattern, e.g.:
-# FILE_LINK_REGEX % 'File'
-# or: FILE_LINK_REGEX % '|'.join(site.namespaces[6])
-#
-# Don't use this regex directly; use textlib.get_regexes('file', site)`
-# instead.
-#
-# 10.7: Exclude empty filename
+#: Regex matching file links with optional parameters.
+#:
+#: Captures the filename and parameters, including links within the
+#: parameters. Inner wikilinks cannot contain nested wikilinks.
+#: The Namespace names must be substituted into the pattern, e.g.:
+#: `FILE_LINK_REGEX % 'File'` or
+#: `FILE_LINK_REGEX % '|'.join(site.namespaces[6])`
+#:
+#: .. important::
+#: Don't use this regex directly; use :func:`get_regexes('file', site)
+#: <get_regexes>` instead.
+#:
+#: .. version-changed:: 10.7
+#: Exclude empty filename
+#: .. version-changed:: 11.10
+#: Reject nested wikilinks in file captions.
FILE_LINK_REGEX = r"""
\[\[\s*
(?:%s) # namespace aliases
@@ -108,9 +115,9 @@
\]\]
"""
-# Used in TimeStripper. When a timestamp-like line has longer gaps
-# than this between year, month, etc in it, then the line will not be
-# considered to contain a timestamp.
+#: Used in :class:`TimeStripper`. When a timestamp-like line has longer
+#: gaps than this between year, month, etc in it, then the line will not
+#: be considered to contain a timestamp.
TIMESTAMP_GAP_LIMIT = 10
diff --git a/pywikibot/time.py b/pywikibot/time.py
index 97ff6d6..49f1fa0 100644
--- a/pywikibot/time.py
+++ b/pywikibot/time.py
@@ -121,6 +121,8 @@
"""Convert a datetime.datetime timestamp to a Timestamp object.
.. version-added:: 7.5
+
+ :meta public:
"""
return Timestamp(dt.year, dt.month, dt.day, dt.hour,
dt.minute, dt.second, dt.microsecond,
@@ -133,6 +135,8 @@
Mediwiki timestamp format: YYYYMMDDHHMMSS
.. version-added:: 7.5
+
+ :meta public:
"""
RE_MW = r'\d{14}' # noqa: N806
m = re.fullmatch(RE_MW, timestr)
@@ -152,6 +156,8 @@
``YYYY-MM-DD[T ]HH:MM:SS[[.,]ffffff][Z|±HH[MM[SS[.ffffff]]]]``
.. version-added:: 7.5
+
+ :meta public:
"""
if 'T' in separators and _API_TIMESTAMP.fullmatch(timestr):
# API timestamps are already UTC; keep the result naive.
@@ -195,6 +201,8 @@
POSIX format: ``SECONDS[.ffffff]]``
.. version-added:: 7.5
+
+ :meta public:
"""
RE_POSIX = r'(?P<S>-?\d{1,13})(?:\.(?P<u>\d{1,6}))?' # noqa: N806
m = re.fullmatch(RE_POSIX, timestr)
@@ -218,6 +226,8 @@
"""Convert a string to a Timestamp object.
.. version-added:: 7.5
+
+ :meta public:
"""
handlers = [
cls._from_mw,
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 0abcd60..a5d1bb6 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -1,6 +1,14 @@
Scripts Changelog
=================
+11.10.0
+-------
+
+next_version
+^^^^^^^^^^^^
+
+* This maintenance script was added to update Sphinx version directives.
(:phab:`T440810`)
+
11.9.0
------
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1358413?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: I8050ee8eb2c48a70a1f84dbeb1a4cf8eaf0053e2
Gerrit-Change-Number: 1358413
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]