jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030595?usp=email )
Change subject: [IMPR] Show the replacements pairs if they are incomplete as user hint
......................................................................
[IMPR] Show the replacements pairs if they are incomplete as user hint
Bug: T364689
Change-Id: I360e76aed1258c39facf5dac90a6fb81f7ac670b
---
M scripts/replace.py
M tests/replacebot_tests.py
2 files changed, 13 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index ea12617..e9f4db5 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -142,7 +142,7 @@
the top of the help.
"""
#
-# (C) Pywikibot team, 2004-2023
+# (C) Pywikibot team, 2004-2024
#
# Distributed under the terms of the MIT license.
#
@@ -820,6 +820,8 @@
"""Handle -pairsfile argument.
.. versionadded:: 7.0
+ .. versionchanged:: 9.2
+ replacement patterns are printed it they are incomplete.
"""
if not filename:
filename = pywikibot.input(
@@ -835,8 +837,8 @@
return None
if len(replacements) % 2:
- pywikibot.error(
- f'{filename} contains an incomplete pattern replacement pair.')
+ pywikibot.error(f'{filename} contains an incomplete pattern '
+ f'replacement pair:\n{replacements}')
return None
# Strip BOM from first line
@@ -893,11 +895,13 @@
def main(*args: str) -> None: # noqa: C901
- """
- Process command line arguments and invoke bot.
+ """Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
+ .. versionchanged:: 9.2
+ replacement patterns are printed it they are incomplete.
+
:param args: command line arguments
"""
options = {}
@@ -976,7 +980,8 @@
return
if len(commandline_replacements) % 2:
- pywikibot.error('Incomplete command line pattern replacement pair.')
+ pywikibot.error('Incomplete command line pattern replacement pair:\n'
+ f'{commandline_replacements}')
return
commandline_replacements += file_replacements
diff --git a/tests/replacebot_tests.py b/tests/replacebot_tests.py
index 2237ba5..a1e7eaf 100755
--- a/tests/replacebot_tests.py
+++ b/tests/replacebot_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the replace script and ReplaceRobot class."""
#
-# (C) Pywikibot team, 2015-2023
+# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
@@ -109,7 +109,7 @@
with empty_sites():
self._run('foo')
self.assertEqual([
- 'Incomplete command line pattern replacement pair.',
+ "Incomplete command line pattern replacement pair:\n['foo']",
], pywikibot.bot.ui.pop_output())
# In the end no bots should've been created
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030595?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: I360e76aed1258c39facf5dac90a6fb81f7ac670b
Gerrit-Change-Number: 1030595
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
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/+/1030593?usp=email )
Change subject: [doc] Fix sphinx roles
......................................................................
[doc] Fix sphinx roles
Change-Id: Ia1c2b24afb8bb07c25fe0747aab424b2ab8c03b0
---
M pywikibot/families/lingualibre_family.py
M pywikibot/i18n.py
M pywikibot/site/_apisite.py
M pywikibot/site/_generators.py
M setup.py
5 files changed, 8 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/lingualibre_family.py b/pywikibot/families/lingualibre_family.py
index 99a36ad..6b81c93 100644
--- a/pywikibot/families/lingualibre_family.py
+++ b/pywikibot/families/lingualibre_family.py
@@ -1,9 +1,9 @@
"""Family module for Lingua Libre.
-.. versionaddded: 6.5
+.. versionadded:: 6.5
"""
#
-# (C) Pywikibot team, 2021-2023
+# (C) Pywikibot team, 2021-2024
#
# Distributed under the terms of the MIT license.
#
@@ -16,7 +16,7 @@
"""Family class for Lingua Libre.
- .. versionaddded: 6.5
+ .. versionadded:: 6.5
"""
name = 'lingualibre'
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 51146cc..9a5ceb7 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -15,7 +15,7 @@
See :py:obj:`twtranslate` for more information on the messages.
"""
#
-# (C) Pywikibot team, 2004-2023
+# (C) Pywikibot team, 2004-2024
#
# Distributed under the terms of the MIT license.
#
@@ -657,7 +657,7 @@
) -> str:
"""Get the bot prefix string like 'Bot: ' including space delimiter.
- .. note: If *source* is a str and ``config.bot_prefix`` is set to
+ .. note:: If *source* is a str and ``config.bot_prefix`` is set to
None, it cannot be determined whether the current user is a bot
account. In this cas the prefix will be returned.
.. versionadded:: 8.1
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 4924b60..729a7ec 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2516,7 +2516,7 @@
Requires appropriate privileges.
- .. seealso: :api:`Delete`
+ .. seealso:: :api:`Delete`
Page to be deleted can be given either as Page object or as pageid.
To delete a specific version of an image the oldimage identifier
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 6d954e3..1ee5a29 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1856,7 +1856,7 @@
Pages are listed in a fixed sequence, only the starting point is
random.
- .. seealso: :api:`Random`
+ .. seealso:: :api:`Random`
.. versionchanged:: 9.0
Raises ``TypeError`` instead of ``AssertionError`` if
*redirects* is invalid.
diff --git a/setup.py b/setup.py
index 5428b45..cb14e17 100755
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@
``pywikibot.__metadata__.py`` and adding developmental identifier
- upload this patchset to Gerrit and merge it.
-.. warning: do not upload a development release to pypi.
+.. warning:: do not upload a development release to pypi.
"""
#
# (C) Pywikibot team, 2009-2024
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030593?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: Ia1c2b24afb8bb07c25fe0747aab424b2ab8c03b0
Gerrit-Change-Number: 1030593
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/+/1030534?usp=email )
Change subject: [doc] use `code-block` directive instead of `code`
......................................................................
[doc] use `code-block` directive instead of `code`
but keep it in README.rst which is used by Github.
Change-Id: Ibb1c7fae346daeac6e8174d4fee650c4b81d79ce
---
M pywikibot/site/_generators.py
M pywikibot/specialbots/_upload.py
M pywikibot/textlib.py
3 files changed, 4 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index bdb7b63..6d954e3 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1001,7 +1001,7 @@
:ref:`Http Settings` in your ``user-config.py`` file. Or
increase it partially within your code like:
- .. code:: python
+ .. code-block:: python
from pywikibot import config
save_timeout = config.socket_timeout # save the timeout config
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 7e3a8d8..c10f519 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -36,7 +36,7 @@
origin *file_url* passed to the :meth:`upload` method and the
*filename* returned from that method. It can be used like this:
- .. code:: python
+ .. code-block:: python
def summarize(old: str, new: str | None) -> None:
if new is None:
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index db243e7..8cc33a7 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -574,7 +574,7 @@
The parser is used by :func:`removeHTMLParts` similar to this:
- .. code:: python
+ .. code-block:: python
from contextlib import closing
from pywikibot.textlib import _GetDataHTML
@@ -586,7 +586,7 @@
The result is:
- .. code:: text
+ .. code-block:: html
<html>Test me!</html>
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030534?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: Ibb1c7fae346daeac6e8174d4fee650c4b81d79ce
Gerrit-Change-Number: 1030534
Gerrit-PatchSet: 1
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/+/1030528?usp=email )
Change subject: [doc] Update documentation of scripts
......................................................................
[doc] Update documentation of scripts
Change-Id: I2809512eda5fb6e40908359a41e7a733ccb2ff7b
---
M scripts/change_pagelang.py
M scripts/download_dump.py
2 files changed, 17 insertions(+), 15 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/change_pagelang.py b/scripts/change_pagelang.py
index d977639..473b785 100755
--- a/scripts/change_pagelang.py
+++ b/scripts/change_pagelang.py
@@ -1,8 +1,8 @@
#!/usr/bin/env python3
-"""
-This script changes the content language of pages.
+"""This script changes the content language of pages.
-These command line parameters can be used to specify which pages to work on:
+These command line parameters can be used to specify which pages to work
+on:
¶ms;
@@ -10,18 +10,20 @@
-setlang What language the pages should be set to
--always If a language is already set for a page, always change it
- to the one set in -setlang.
+-always If a language is already set for a page, always change
+ it to the one set in -setlang.
--never If a language is already set for a page, never change it to
- the one set in -setlang (keep the current language).
+-never If a language is already set for a page, never change
+ it to the one set in -setlang (keep the current
+ language).
.. note:: This script is a
- :py:obj:`ConfigParserBot <bot.ConfigParserBot>`. All options
- can be set within a settings file which is scripts.ini by default.
+ :class:`ConfigParserBot<bot.ConfigParserBot>`. All options can be set
+ within a settings file which is scripts.ini by default.
+.. versionadded:: 5.1
"""
#
-# (C) Pywikibot team, 2018-2023
+# (C) Pywikibot team, 2018-2024
#
# Distributed under the terms of the MIT license.
#
diff --git a/scripts/download_dump.py b/scripts/download_dump.py
index 8fb42f7..f374923 100755
--- a/scripts/download_dump.py
+++ b/scripts/download_dump.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
-"""
-This bot downloads dump from dumps.wikimedia.org.
+"""This bot downloads dump from dumps.wikimedia.org.
This script supports the following command line parameters:
@@ -12,11 +11,12 @@
formatted as YYYYMMDD.
.. note:: This script is a
- :py:obj:`ConfigParserBot <bot.ConfigParserBot>`. All options
- can be set within a settings file which is scripts.ini by default.
+ :class:`ConfigParserBot<bot.ConfigParserBot>`. All options can be set
+ within a settings file which is scripts.ini by default.
+.. versionadded:: 3.0.20180108
"""
#
-# (C) Pywikibot team, 2017-2022
+# (C) Pywikibot team, 2017-2024
#
# Distributed under the terms of the MIT license.
#
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030528?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: I2809512eda5fb6e40908359a41e7a733ccb2ff7b
Gerrit-Change-Number: 1030528
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
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/+/1030176?usp=email )
Change subject: [IMPR] Use a set for lang_tmp_cat category content instead of a generator
......................................................................
[IMPR] Use a set for lang_tmp_cat category content instead of a generator
lang_tmp_cat is a generator for a category that holds the languages templates.
instead using the generator for __contains__ operator create a set first.
Change-Id: I5d5a07bd7acee977d9ecd59bf7556d12ec2feffc
---
M scripts/commons_information.py
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/commons_information.py b/scripts/commons_information.py
index 2cf69eb..e71aecd 100755
--- a/scripts/commons_information.py
+++ b/scripts/commons_information.py
@@ -62,7 +62,7 @@
"""Initialzer."""
super().__init__(**kwargs)
lang_tmp_cat = pywikibot.Category(self.site, self.lang_tmp_cat)
- self.lang_tmps = lang_tmp_cat.articles(namespaces=[10])
+ self.lang_tmps = set(lang_tmp_cat.articles(namespaces=[10]))
def get_description(self, template):
"""Get description parameter."""
@@ -129,23 +129,29 @@
page = self.current_page
code = mwparserfromhell.parse(page.text)
edited = False # to prevent unwanted changes
+
for template in code.ifilter_templates():
if not page.site.sametitle(template.name.strip(), 'Information'):
continue
+
desc = self.get_description(template)
if desc is None:
continue
+
for tmp in desc.value.filter_templates(recursive=False):
if self.process_desc_template(tmp):
edited = True
+
desc_clean = copy.deepcopy(desc.value)
for tmp in desc_clean.filter_templates(recursive=False):
# TODO: emit a debug item?
desc_clean.remove(tmp)
+
value = desc_clean.strip()
if value == '':
pywikibot.info('Empty description')
continue
+
pywikibot.info(value)
langs = self.detect_langs(value)
if langs:
@@ -153,6 +159,7 @@
for language in langs:
pywikibot.info(
f'<<lightblue>>{language.lang}: {language.prob}')
+
lang = pywikibot.input(
'Enter the language of the displayed text:').strip()
if lang != '':
@@ -163,6 +170,7 @@
new = mwparserfromhell.nodes.template.Template(lang, [value])
self.replace_value(desc, new)
edited = True
+
if edited:
text = str(code)
summary = i18n.translate(page.site.lang, self.comment,
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1030176?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: I5d5a07bd7acee977d9ecd59bf7556d12ec2feffc
Gerrit-Change-Number: 1030176
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged