jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/904743?usp=email )
Change subject: [IMPR] Improve api._generators and avoid similar code
......................................................................
[IMPR] Improve api._generators and avoid similar code
Change-Id: I5959bfe9686d918774529b98d45a3ac084848366
---
M pywikibot/data/api/_generators.py
1 file changed, 39 insertions(+), 34 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py
index e32ed2e..de6f011 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -19,7 +19,7 @@
import pywikibot
from pywikibot import config
-from pywikibot.backports import Callable
+from pywikibot.backports import Callable, Iterable
from pywikibot.exceptions import Error, InvalidTitleError, UnsupportedPageError
from pywikibot.site import Namespace
from pywikibot.tools import deprecated
@@ -963,25 +963,42 @@
page._coords = coords
-def update_page(page, pagedict: dict, props=None):
- """Update attributes of Page object page, based on query data in pagedict.
+def update_page(page: pywikibot.Page,
+ pagedict: dict[str, Any],
+ props: Iterable[str] | None = None) -> None:
+ """
+ Update attributes of Page object *page*, based on query data in *pagedict*.
:param page: object to be updated
- :type page: pywikibot.page.Page
- :param pagedict: the contents of a "page" element of a query response
- :param props: the property names which resulted in pagedict. If a missing
- value in pagedict can indicate both 'false' and 'not present' the
- property which would make the value present must be in the props
- parameter.
- :type props: iterable of string
- :raises pywikibot.exceptions.InvalidTitleError: Page title is invalid
- :raises pywikibot.exceptions.UnsupportedPageError: Page with namespace < 0
- is not supported yet
+ :param pagedict: the contents of a *page* element of a query
+ response
+ :param props: the property names which resulted in *pagedict*. If a
+ missing value in *pagedict* can indicate both 'false' and
+ 'not present' the property which would make the value present
+ must be in the *props* parameter.
+ :raises InvalidTitleError: Page title is invalid
+ :raises UnsupportedPageError: Page with namespace < 0 is not
+ supported yet
"""
_update_pageid(page, pagedict)
_update_contentmodel(page, pagedict)
props = props or []
+
+ # test for pagedict content only and call updater function
+ for element in ('coordinates', 'revisions'):
+ if element in pagedict:
+ updater = globals()['_update_' + element]
+ updater(page, pagedict[element])
+
+ # test for pagedict and props contents, call updater or set attribute
+ for element in ('categories', 'langlinks', 'templates'):
+ if element in pagedict:
+ updater = globals()['_update_' + element]
+ updater(page, pagedict[element])
+ elif element in props:
+ setattr(page, '_' + element, set())
+
if 'info' in props:
page._isredir = 'redirect' in pagedict
@@ -991,9 +1008,6 @@
if 'protection' in pagedict:
_update_protection(page, pagedict)
- if 'revisions' in pagedict:
- _update_revisions(page, pagedict['revisions'])
-
if 'lastrevid' in pagedict:
page.latest_revision_id = pagedict['lastrevid']
@@ -1006,24 +1020,6 @@
if 'categoryinfo' in pagedict:
page._catinfo = pagedict['categoryinfo']
- if 'templates' in pagedict:
- _update_templates(page, pagedict['templates'])
- elif 'templates' in props:
- page._templates = set()
-
- if 'categories' in pagedict:
- _update_categories(page, pagedict['categories'])
- elif 'categories' in props:
- page._categories = set()
-
- if 'langlinks' in pagedict:
- _update_langlinks(page, pagedict['langlinks'])
- elif 'langlinks' in props:
- page._langlinks = set()
-
- if 'coordinates' in pagedict:
- _update_coordinates(page, pagedict['coordinates'])
-
if 'pageimage' in pagedict:
page._pageimage = pywikibot.FilePage(page.site, pagedict['pageimage'])
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/904743?usp=email
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: I5959bfe9686d918774529b98d45a3ac084848366
Gerrit-Change-Number: 904743
Gerrit-PatchSet: 12
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/1017835?usp=email )
Change subject: Localisation updates from https://translatewiki.net.
......................................................................
Localisation updates from https://translatewiki.net.
Change-Id: Iccc1b4eae7bbdc3e9f35d57ffdcd174b37dc7982
---
M checkimages/de.json
1 file changed, 15 insertions(+), 5 deletions(-)
Approvals:
jenkins-bot: Verified
L10n-bot: Looks good to me, approved
diff --git a/checkimages/de.json b/checkimages/de.json
index 923f9c3..0812037 100644
--- a/checkimages/de.json
+++ b/checkimages/de.json
@@ -3,6 +3,7 @@
"authors": [
"Filnik",
"Metalhead64",
+ "TomatoCake",
"Xqt"
]
},
@@ -10,13 +11,13 @@
"checkimages-doubles-file-comment": "Bot: Datei liegt bereits auf Commons, kann gelöscht werden",
"checkimages-doubles-head": "Datei-Duplikat",
"checkimages-doubles-talk-comment": "Bot: Benachrichtigung, dass die Datei bereits auf Commons vorhanden ist",
- "checkimages-doubles-talk-text": "Vielen Dank für das Hochladen von %(upload)s. Diese Datei ist jedoch eine Kopie von:%(image)sDer Bot hat die Datei, die am wenigsten verwendet wurde oder aktuell war, als Duplikat markiert. Wenn Sie es für angebrachter halten, die Datei als sofort zu löschend markiert zu belassen, können Sie die doppelten Dateien löschen und die Löschvorlage von der zu belassenden Datei entfernen. Dies ist eine automatisierte Nachricht von %(bot)s.",
- "checkimages-forced-mode": "('''Zwangsmodus''')",
- "checkimages-has-duplicates": "hat folgende Dubletten%(force)s:",
- "checkimages-log-comment": "Bot: Aktualisiere das Log",
+ "checkimages-doubles-talk-text": "Vielen Dank für das Hochladen von %(upload)s. Diese Datei ist jedoch eine Kopie von:%(image)sDer Bot hat die Datei, die am wenigsten verwendet wurde oder aktuell war, als Duplikat markiert. Wenn du es für angebrachter hältst, die Datei als sofort zu löschend markiert zu belassen, kannst du die doppelten Dateien löschen und die Löschvorlage von der zu belassenden Datei entfernen. Dies ist eine automatisierte Nachricht von %(bot)s.",
+ "checkimages-forced-mode": "('''erzwungener Modus''')",
+ "checkimages-has-duplicates": "hat die folgenden Duplikate%(force)s:",
+ "checkimages-log-comment": "Bot: Log wird aktualisiert",
"checkimages-no-license-head": "Bild ohne Lizenz",
"checkimages-source-tag-comment": "Bot: Markiere zur Dateiüberprüfung, da keine Lizenzvorlage gefunden.",
- "checkimages-source-notice-comment": "Bot: Benachrichtigung über Lizenzprobleme.",
+ "checkimages-source-notice-comment": "Bot: Quellinformationen anfordern.",
"checkimages-unknown-extension-head": "Unbekannte Erweiterung!",
"checkimages-unknown-extension-msg": "Die Datei %(file)s scheint eine falsche Erweiterung zu haben. Bitte überprüfen."
}
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/i18n/+/1017835?usp=email
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: Iccc1b4eae7bbdc3e9f35d57ffdcd174b37dc7982
Gerrit-Change-Number: 1017835
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
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017485?usp=email )
Change subject: [bugfix] Fix TypeError in colors.py with backports.batched
......................................................................
[bugfix] Fix TypeError in colors.py with backports.batched
Bug: T362035
Change-Id: I68d7a7c3451fce91e13385a57138c0ed50f26d64
Signed-off-by: Xqt <info(a)gno.de>
---
M pywikibot/backports.py
M scripts/maintenance/colors.py
2 files changed, 19 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/backports.py b/pywikibot/backports.py
index 155effd..8b9d989 100644
--- a/pywikibot/backports.py
+++ b/pywikibot/backports.py
@@ -177,9 +177,13 @@
:param strict: raise a ValueError if the final batch is shorter
than *n*.
:raise ValueError: batched(): incomplete batch
+ :raise TypeError: *n* cannot be interpreted as an integer
"""
msg = 'batched(): incomplete batch'
if PYTHON_VERSION < (3, 12):
+ if not isinstance(n, int):
+ raise TypeError(f'{type(n),__name__!r} object cannot be'
+ ' interpreted as an integer')
group = []
for item in iterable:
group.append(item)
diff --git a/scripts/maintenance/colors.py b/scripts/maintenance/colors.py
index bf73742..63c46a5 100755
--- a/scripts/maintenance/colors.py
+++ b/scripts/maintenance/colors.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Utility to show pywikibot colors."""
#
-# (C) Pywikibot team, 2016-2023
+# (C) Pywikibot team, 2016-2024
#
# Distributed under the terms of the MIT license.
#
@@ -17,10 +17,8 @@
fg_colors = [col for col in colors if col != 'default']
bg_colors = fg_colors[:]
n_fg_colors = len(fg_colors)
- fg_colors.insert(3 * int(n_fg_colors / 4), 'default')
- fg_colors.insert(2 * int(n_fg_colors / 4), 'default')
- fg_colors.insert(int(n_fg_colors / 4), 'default')
- fg_colors.insert(0, 'default')
+ for i in range(4):
+ fg_colors.insert((3 - i) * (n_fg_colors // 4), 'default')
# Max len of color names for padding.
max_len_fg_colors = len(max(fg_colors, key=len))
@@ -28,7 +26,7 @@
for bg_col in bg_colors:
# Three lines per each backgoung color.
- for fg_col_group in batched(fg_colors, n_fg_colors / 4 + 1):
+ for fg_col_group in batched(fg_colors, n_fg_colors // 4 + 1):
line = ''
for fg_col in fg_col_group:
line += ' '
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017485?usp=email
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: I68d7a7c3451fce91e13385a57138c0ed50f26d64
Gerrit-Change-Number: 1017485
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017512?usp=email )
Change subject: [doc] update ROADMAP.rst
......................................................................
[doc] update ROADMAP.rst
Change-Id: I992550ef6b9b82e3819a48b44599485c42bc2b0a
---
M ROADMAP.rst
1 file changed, 17 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst
index b00b932..850f0a3 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,7 +1,14 @@
Current release
---------------
-* (no changes yet)
+* File title of :class:`specialbots.UploadRobot` must have a valid file extension (:phab:`T345786`)
+* Add a :attr:`post_processor<specialbots.UploadRobot.post_processor>` attribute to :class:`specialbots.UploadRobot`
+ which can be called after each upload (:phab:`T359766`)
+* Avoid using :meth:`pywikibot.handle_args` in private scripts;
+ use :mod:`pwb<pywikibot.scripts.wrapper>` wrapper instead (:phab:`T359766`)
+* Show upload count with :class:`specialbots.UploadRobot`
+* Use the same ``iiprop`` properties in :class:`data.api.PageGenerator` as in
+ :meth:`APISite.loadimageinfo<pywikibot.site._apisite.APISite.loadimageinfo>` (:phab:`T360093`)
Deprecations
------------
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1017512?usp=email
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: I992550ef6b9b82e3819a48b44599485c42bc2b0a
Gerrit-Change-Number: 1017512
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1015994?usp=email )
Change subject: [fix] file title must have a valid file extension
......................................................................
[fix] file title must have a valid file extension
An invalid file extension will lead to a ValueError.
Skip the current file or retry to enter a valid filename.
Bug: T345786
Change-Id: Ie95c837156d893e2e8faa6eaac96fc95a63531a8
---
M pywikibot/specialbots/_upload.py
1 file changed, 20 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index ce8bd29..0aad35d 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -3,7 +3,7 @@
Do not import classes directly from here but from specialbots.
"""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -270,13 +270,13 @@
if self.opt.always:
pywikibot.info('File format is not one of [{}]'
.format(' '.join(allowed_formats)))
- continue
- if not pywikibot.input_yn(
- 'File format is not one of [{}], but {!r}. Continue?'
- .format(' '.join(allowed_formats), ext),
- default=False):
- continue
+ elif pywikibot.input_yn(
+ 'File format is not one of [{}], but {!r}. Skip?'
+ .format(' '.join(allowed_formats), ext)):
+ return None
+
+ continue
potential_file_page = pywikibot.FilePage(self.target_site,
filename)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1015994?usp=email
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: Ie95c837156d893e2e8faa6eaac96fc95a63531a8
Gerrit-Change-Number: 1015994
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged