jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/994187?usp=email )
Change subject: [cleanup] Drop pywikibot.BaseSite and pywikibotAPISite
......................................................................
[cleanup] Drop pywikibot.BaseSite and pywikibotAPISite
BaseSite and APISite are used for typing and interface check in Site()
constructor function. They were introduced with b903d0aa for typing
and b17ca6e8 for interface check. Other BaseSite subclasses like
DataSite and ClosedSite were already removed in an earlier version.
They were never intended for direct usage and it should never be used
directly. Therefore is not part of pywikibot.__all__ list. See also the
warning at
https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.html#pywikibot…
To be safe, remove direct imports of BaseSite and APISite in
pywikibot.__init__.py
Bug: T355915
Change-Id: I3de35e9780a1184cbb9492f2c9ab5b91c523805a
---
M pywikibot/__init__.py
M pywikibot/page/_wikibase.py
M scripts/redirect.py
M scripts/speedy_delete.py
M tests/category_bot_tests.py
5 files changed, 44 insertions(+), 16 deletions(-)
Approvals:
jenkins-bot: Verified
JJMC89: Looks good to me, approved
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 22002d8..4fc3a17 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1,6 +1,6 @@
"""The initialization file for the Pywikibot framework."""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
@@ -14,7 +14,7 @@
from contextlib import suppress
from queue import Queue
from time import sleep as time_sleep
-from typing import Any, cast
+from typing import Any, TYPE_CHECKING, cast
from urllib.parse import urlparse
from warnings import warn
@@ -67,11 +67,15 @@
stdout,
warning,
)
-from pywikibot.site import APISite, BaseSite
+from pywikibot.site import BaseSite as _BaseSite
from pywikibot.time import Timestamp
from pywikibot.tools import normalize_username
+if TYPE_CHECKING:
+ from pywikibot.site import APISite
+
+
__all__ = (
'__copyright__', '__description__', '__download_url__', '__license__',
'__maintainer__', '__maintainer_email__', '__name__', '__url__',
@@ -127,11 +131,11 @@
return matched_sites[0]
-def Site(code: str | None = None, # noqa: 134
+def Site(code: str | None = None, # noqa: N802
fam: str | Family | None = None,
user: str | None = None, *,
- interface: str | BaseSite | None = None,
- url: str | None = None) -> BaseSite:
+ interface: str | _BaseSite | None = None,
+ url: str | None = None) -> _BaseSite:
"""A factory method to obtain a Site object.
Site objects are cached and reused by this method.
@@ -242,7 +246,7 @@
else:
interface = getattr(tmp, interface)
- if not issubclass(interface, BaseSite):
+ if not issubclass(interface, _BaseSite):
warning(f'Site called with interface={interface.__name__}')
user = normalize_username(user)
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py
index 34607ce..b5de1b3 100644
--- a/pywikibot/page/_wikibase.py
+++ b/pywikibot/page/_wikibase.py
@@ -9,7 +9,7 @@
* WikibaseEntity: base interface for Wikibase entities.
"""
#
-# (C) Pywikibot team, 2013-2023
+# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of the MIT license.
#
@@ -65,7 +65,7 @@
)
if TYPE_CHECKING:
- LANGUAGE_IDENTIFIER = str | pywikibot.APISite
+ LANGUAGE_IDENTIFIER = str | pywikibot.site.APISite
ALIASES_TYPE = dict[LANGUAGE_IDENTIFIER, list[str]]
LANGUAGE_TYPE = dict[LANGUAGE_IDENTIFIER, str]
SITELINK_TYPE = (
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 3a31af2..bffa83c 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -66,7 +66,7 @@
¶ms;
"""
#
-# (C) Pywikibot team, 2004-2023
+# (C) Pywikibot team, 2004-2024
#
# Distributed under the terms of the MIT license.
#
@@ -408,11 +408,12 @@
else:
raise NotImplementedError(f'No valid action "{action}" found.')
- def get_sd_template(self, site=None) -> str | None:
+ def get_sd_template(
+ self, site: pywikibot.site.BaseSite | None = None
+ ) -> str | None:
"""Look for speedy deletion template and return it.
:param site: site for which the template has to be given
- :type site: pywikibot.BaseSite
:return: A valid speedy deletion template.
"""
title = None
diff --git a/scripts/speedy_delete.py b/scripts/speedy_delete.py
index 76dab20..0f4d0c3 100755
--- a/scripts/speedy_delete.py
+++ b/scripts/speedy_delete.py
@@ -22,7 +22,7 @@
.. note:: This script currently only works for the Wikipedia project.
"""
#
-# (C) Pywikibot team, 2007-2023
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
@@ -325,7 +325,7 @@
def __init__(self, **kwargs) -> None:
"""Initializer.
- :keyword pywikibot.APISite site: the site to work on
+ :keyword pywikibot.site.APISite site: the site to work on
"""
super().__init__(**kwargs)
csd_cat = i18n.translate(self.site, self.csd_cat_title)
diff --git a/tests/category_bot_tests.py b/tests/category_bot_tests.py
index 8122c32..e96cec3 100755
--- a/tests/category_bot_tests.py
+++ b/tests/category_bot_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the category bot script."""
#
-# (C) Pywikibot team, 2015-2022
+# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
@@ -12,7 +12,7 @@
from unittest.mock import Mock, patch
import pywikibot
-from pywikibot import BaseSite
+from pywikibot.site import BaseSite
from scripts.category import CategoryMoveRobot, CategoryPreprocess
from tests.aspects import DefaultSiteTestCase, TestCase
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/994187?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: I3de35e9780a1184cbb9492f2c9ab5b91c523805a
Gerrit-Change-Number: 994187
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/993750?usp=email )
Change subject: Fix casing of Mediawiki
......................................................................
Fix casing of Mediawiki
Change-Id: I1fda8383117524ad2252c2891f73f3c1208c23e0
---
M docs/api_ref/logentries.rst
M pywikibot/data/api/__init__.py
M pywikibot/logentries.py
M pywikibot/proofreadpage.py
M scripts/checkimages.py
M scripts/welcome.py
6 files changed, 16 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/docs/api_ref/logentries.rst b/docs/api_ref/logentries.rst
index e45b3f9..c7805e1 100644
--- a/docs/api_ref/logentries.rst
+++ b/docs/api_ref/logentries.rst
@@ -3,4 +3,4 @@
************************
.. automodule:: logentries
- :synopsis: Objects representing Mediawiki log entries
+ :synopsis: Objects representing MediaWiki log entries
diff --git a/pywikibot/data/api/__init__.py b/pywikibot/data/api/__init__.py
index 9f289ab..609d3c5 100644
--- a/pywikibot/data/api/__init__.py
+++ b/pywikibot/data/api/__init__.py
@@ -1,4 +1,4 @@
-"""Interface to Mediawiki's api.php."""
+"""Interface to MediaWiki's api.php."""
#
# (C) Pywikibot team, 2014-2024
#
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 5bda04e..67e6296 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -1,4 +1,4 @@
-"""Objects representing Mediawiki log entries."""
+"""Objects representing MediaWiki log entries."""
#
# (C) Pywikibot team, 2007-2023
#
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 8f217e9..8050443 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -395,7 +395,7 @@
class ProofreadPage(pywikibot.Page):
- """ProofreadPage page used in Mediawiki ProofreadPage extension."""
+ """ProofreadPage page used in MediaWiki ProofreadPage extension."""
WITHOUT_TEXT = 0
NOT_PROOFREAD = 1
@@ -1068,7 +1068,7 @@
class IndexPage(pywikibot.Page):
- """Index Page page used in Mediawiki ProofreadPage extension."""
+ """Index Page page used in MediaWiki ProofreadPage extension."""
INDEX_TEMPLATE = ':MediaWiki:Proofreadpage_index_template'
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index f0991bb..351a814 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1168,7 +1168,7 @@
"""
Check if template is in list.
- The problem is the calls to the Mediawiki system because they can be
+ The problem is the calls to the MediaWiki system because they can be
pretty slow. While searching in a list of objects is really fast, so
first of all let's see if we can find something in the info that we
already have, then make a deeper check.
diff --git a/scripts/welcome.py b/scripts/welcome.py
index a557bdc..4a48426 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -926,7 +926,7 @@
except ValueError:
# upon request, we could check for software version here
raise ValueError(fill(
- 'Mediawiki has changed, -offset:# is not supported anymore, but '
+ 'MediaWiki has changed, -offset:# is not supported anymore, but '
'-offset:TIMESTAMP is, assuming TIMESTAMP is yyyymmddhhmmss or '
'yyyymmdd. -timeoffset is now also supported. Please read this '
'script source header for documentation.'))
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/993750?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: I1fda8383117524ad2252c2891f73f3c1208c23e0
Gerrit-Change-Number: 993750
Gerrit-PatchSet: 5
Gerrit-Owner: Reedy <reedy(a)wikimedia.org>
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/+/993250?usp=email )
Change subject: [tests] Skip interwiki link test until the problem is solved upstream
......................................................................
[tests] Skip interwiki link test until the problem is solved upstream
Bug: T356009
Change-Id: I25afe1bd2042002bcd1bcd196d83106d701ef756
---
M tests/page_tests.py
1 file changed, 23 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/page_tests.py b/tests/page_tests.py
index b76de07..1104935 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -26,7 +26,7 @@
UnknownExtensionError,
)
from pywikibot.tools import suppress_warnings
-from tests import WARN_SITE_CODE
+from tests import WARN_SITE_CODE, unittest_print
from tests.aspects import (
DefaultDrySiteTestCase,
DefaultSiteTestCase,
@@ -522,15 +522,21 @@
mainpage = self.get_mainpage()
for p in mainpage.linkedPages():
self.assertIsInstance(p, pywikibot.Page)
- iw = list(mainpage.interwiki(expand=True))
- for p in iw:
- self.assertIsInstance(p, pywikibot.Link)
- for p2 in mainpage.interwiki(expand=False):
- self.assertIsInstance(p2, pywikibot.Link)
- self.assertIn(p2, iw)
+
+ if mainpage.site.sitename == 'wikipedia:en':
+ unittest_print('Skipping interwiki link test due to T356009')
+ else:
+ iw = set(mainpage.interwiki(expand=True))
+ for link in iw:
+ self.assertIsInstance(link, pywikibot.Link)
+ for link in mainpage.interwiki(expand=False):
+ self.assertIsInstance(link, pywikibot.Link)
+ self.assertIn(link, iw)
+
with suppress_warnings(WARN_SITE_CODE, category=UserWarning):
for p in mainpage.langlinks():
self.assertIsInstance(p, pywikibot.Link)
+
for p in mainpage.imagelinks():
self.assertIsInstance(p, pywikibot.FilePage)
for p in mainpage.templates():
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/993250?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: I25afe1bd2042002bcd1bcd196d83106d701ef756
Gerrit-Change-Number: 993250
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/+/990720?usp=email )
Change subject: Pass login token when using action=login
......................................................................
Pass login token when using action=login
This will take care of the warning currently shown when logging in
using a BotPassword, where MediaWiki API warns that fetching a
token via "action=login" is deprecated. We already have fetched
the token and we just need to provide it here.
Bug: T309898
Change-Id: I77d22d1d4d3a3dc66abe3a64107c59ec37ea3a2a
---
M pywikibot/login.py
1 file changed, 19 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 4ce3eea..17c6924 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -348,7 +348,6 @@
if botpassword:
self.action = 'login'
else:
- token = self.site.tokens['login']
self.action = 'clientlogin'
# prepare default login parameters
@@ -356,11 +355,14 @@
self.keyword('user'): self.login_name,
self.keyword('password'): self.password}
+ if self.action == 'login':
+ parameters['lgtoken'] = self.site.tokens['login']
+
if self.action == 'clientlogin':
# clientlogin requires non-empty loginreturnurl
parameters['loginreturnurl'] = 'https://example.com'
parameters['rememberMe'] = '1'
- parameters['logintoken'] = token
+ parameters['logintoken'] = self.site.tokens['login']
if self.site.family.ldapDomain:
parameters[self.keyword('ldap')] = self.site.family.ldapDomain
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/990720?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: I77d22d1d4d3a3dc66abe3a64107c59ec37ea3a2a
Gerrit-Change-Number: 990720
Gerrit-PatchSet: 2
Gerrit-Owner: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Huji <huji.huji(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/+/991917?usp=email )
Change subject: [flake8] Detect arguments shadowing of Python buildins and rename them
......................................................................
[flake8] Detect arguments shadowing of Python buildins and rename them
Change-Id: Ia3bc1df5bde80e90bceede3500421a9e530fad4b
---
M pywikibot/data/api/_optionset.py
M pywikibot/date.py
M pywikibot/site/_apisite.py
M pywikibot/site/_generators.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/userinterfaces/transliteration.py
M scripts/blockpageschecker.py
M scripts/dataextend.py
M tests/site_generators_tests.py
9 files changed, 93 insertions(+), 55 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_optionset.py b/pywikibot/data/api/_optionset.py
index 500da9c..d31f0e4 100644
--- a/pywikibot/data/api/_optionset.py
+++ b/pywikibot/data/api/_optionset.py
@@ -1,6 +1,6 @@
"""Object representing boolean API option."""
#
-# (C) Pywikibot team, 2015-2022
+# (C) Pywikibot team, 2015-2024
#
# Distributed under the terms of the MIT license.
#
@@ -8,6 +8,9 @@
from collections.abc import MutableMapping
+import pywikibot
+from pywikibot.tools import deprecate_arg
+
__all__ = ['OptionSet']
@@ -24,30 +27,33 @@
None and after setting it, any site (even None) will fail.
"""
- def __init__(self, site=None,
+ @deprecate_arg('dict', 'data') # since 9.0
+ def __init__(self,
+ site: pywikibot.site.APISite | None = None,
module: str | None = None,
param: str | None = None,
- dict: dict | None = None) -> None:
- """
- Initializer.
+ data: dict | None = None) -> None:
+ """Initializer.
If a site is given, the module and param must be given too.
+ .. versionchanged:: 9.0
+ *dict* parameter was renamed to *data*.
+
:param site: The associated site
- :type site: pywikibot.site.APISite or None
:param module: The module name which is used by paraminfo. (Ignored
when site is None)
:param param: The parameter name inside the module. That parameter must
have a 'type' entry. (Ignored when site is None)
- :param dict: The initializing dict which is used for
- :py:obj:`from_dict`
+ :param data: The initializing data dict which is used for
+ :meth:`from_dict`
"""
self._site_set = False
self._enabled = set()
self._disabled = set()
self._set_site(site, module, param)
- if dict:
- self.from_dict(dict)
+ if data:
+ self.from_dict(data)
def _set_site(self, site, module: str, param: str,
clear_invalid: bool = False):
diff --git a/pywikibot/date.py b/pywikibot/date.py
index d79aa47..4a85afc 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -1,6 +1,6 @@
"""Date data and manipulation module."""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -26,7 +26,7 @@
)
from pywikibot.site import BaseSite
from pywikibot.textlib import NON_LATIN_DIGITS
-from pywikibot.tools import first_lower, first_upper
+from pywikibot.tools import deprecate_arg, first_lower, first_upper
if TYPE_CHECKING:
@@ -459,8 +459,9 @@
@singledispatch
+@deprecate_arg('filter', 'filter_func') # since 9.0
def dh(value: int, pattern: str, encf: encf_type, decf: decf_type,
- filter: Callable[[int], bool] | None = None) -> str:
+ filter_func: Callable[[int], bool] | None = None) -> str:
"""Function to help with year parsing.
Usually it will be used as a lambda call in a map::
@@ -477,6 +478,9 @@
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
@@ -490,7 +494,7 @@
# Encode an integer value into a textual form.
# This will be called from outside as well as recursivelly to verify
# parsed value
- if filter and not filter(value):
+ if filter_func and not filter_func(value):
raise ValueError(f'value {value} is not allowed')
params = encf(value)
@@ -512,7 +516,7 @@
@dh.register(str)
def _(value: str, pattern: str, encf: encf_type, decf: decf_type,
- filter: Callable[[int], bool] | None = None) -> int:
+ filter_func: Callable[[int], bool] | None = None) -> int:
compPattern, _strPattern, decoders = escapePattern2(pattern)
m = compPattern.match(value)
if m:
@@ -525,8 +529,8 @@
'Decoder must not return a string!'
# recursive call to re-encode and see if we get the original
- # (may through filter exception)
- if value == dh(decValue, pattern, encf, decf, filter):
+ # (may through filter_func exception)
+ if value == dh(decValue, pattern, encf, decf, filter_func):
return decValue
raise ValueError("reverse encoding didn't match")
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 9aa95d4..53ec3a3 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -1,6 +1,6 @@
"""Objects representing API interface to MediaWiki site."""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
@@ -73,6 +73,7 @@
from pywikibot.tools import (
MediaWikiVersion,
cached,
+ deprecate_arg,
deprecated,
issue_deprecation_warning,
merge_unique_dicts,
@@ -1394,18 +1395,22 @@
# 'title' is expected to be URL-encoded already
return self.siteinfo['articlepath'].replace('$1', title)
- def namespace(self, num: int, all: bool = False) -> str | Namespace:
+ @deprecate_arg('all', 'all_ns') # since 9.0
+ def namespace(self, num: int, all_ns: bool = False) -> str | Namespace:
"""Return string containing local name of namespace 'num'.
- If optional argument 'all' is true, return all recognized
+ If optional argument *all_ns* is true, return all recognized
values for this namespace.
+ .. versionchanged:: 9.0
+ *all* parameter was renamed to *all_ns*.
+
:param num: Namespace constant.
- :param all: If True return a Namespace object. Otherwise
- return the namespace name.
- :return: local name or Namespace object
+ :param all_ns: If True return a :class:`Namespace` object.
+ Otherwise return the namespace name.
+ :return: local name or :class:`Namespace` object
"""
- if all:
+ if all_ns:
return self.namespaces[num]
return self.namespaces[num][0]
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 96be68e..1b36d19 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -1,6 +1,6 @@
"""Objects representing API generators to MediaWiki site."""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
@@ -26,7 +26,11 @@
)
from pywikibot.site._decorators import need_right
from pywikibot.site._namespace import NamespaceArgType
-from pywikibot.tools import is_ip_address, issue_deprecation_warning
+from pywikibot.tools import (
+ deprecate_arg,
+ is_ip_address,
+ issue_deprecation_warning,
+)
from pywikibot.tools.itertools import filter_unique
@@ -2070,41 +2074,43 @@
"""
return self.querypage('Listredirects', total)
+ @deprecate_arg('type', 'protect_type')
def protectedpages(
self,
namespace=0,
- type: str = 'edit',
+ protect_type: str = 'edit',
level: str | bool = False,
total=None
):
- """
- Return protected pages depending on protection level and type.
+ """Return protected pages depending on protection level and type.
For protection types which aren't 'create' it uses
:py:obj:`APISite.allpages`, while it uses for 'create' the
'query+protectedtitles' module.
+ .. versionchanged:: 9.0
+ *type* parameter was renamed to *protect_type*.
.. seealso:: :api:`Protectedtitles`
:param namespace: The searched namespace.
:type namespace: int or Namespace or str
- :param type: The protection type to search for (default 'edit').
- :type type: str
+ :param protect_type: The protection type to search for
+ (default 'edit').
:param level: The protection level (like 'autoconfirmed'). If False it
shows all protection levels.
:return: The pages which are protected.
:rtype: typing.Iterable[pywikibot.Page]
"""
namespaces = self.namespaces.resolve(namespace)
- # always assert that, so we are be sure that type could be 'create'
+ # always assert, so we are be sure that protect_type could be 'create'
assert 'create' in self.protection_types(), \
"'create' should be a valid protection type."
- if type == 'create':
+ if protect_type == 'create':
return self._generator(
api.PageGenerator, type_arg='protectedtitles',
namespaces=namespaces, gptlevel=level, total=total)
return self.allpages(namespace=namespaces[0], protect_level=level,
- protect_type=type, total=total)
+ protect_type=protect_type, total=total)
def pages_with_property(self, propname: str, *,
total: int | None = None):
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 8346abb..83f7f4a 100644
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -1,6 +1,6 @@
"""Base for terminal user interfaces."""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -313,10 +313,10 @@
if char == '?' and text[i] != '?':
try:
transliterated = transliterator.transliterate(
- text[i], default='?', prev=prev, next=text[i + 1])
+ text[i], default='?', prev=prev, succ=text[i + 1])
except IndexError:
transliterated = transliterator.transliterate(
- text[i], default='?', prev=prev, next=' ')
+ text[i], default='?', prev=prev, succ=' ')
# transliteration was successful. The replacement
# could consist of multiple letters.
# mark the transliterated letters in yellow.
diff --git a/pywikibot/userinterfaces/transliteration.py b/pywikibot/userinterfaces/transliteration.py
index 85755fa..0bbc083 100644
--- a/pywikibot/userinterfaces/transliteration.py
+++ b/pywikibot/userinterfaces/transliteration.py
@@ -1,11 +1,13 @@
"""Module to transliterate text."""
#
-# (C) Pywikibot team, 2006-2022
+# (C) Pywikibot team, 2006-2024
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
+from pywikibot.tools import deprecate_arg
+
#: Non latin digits used by the framework
NON_LATIN_DIGITS = {
@@ -1119,15 +1121,18 @@
trans[char] = value
self.trans = trans
+ @deprecate_arg('next', 'succ') # since 9.0
def transliterate(self, char: str, default: str = '?',
- prev: str = '-', next: str = '-') -> str:
- """
- Transliterate the character.
+ prev: str = '-', succ: str = '-') -> str:
+ """Transliterate the character.
+
+ .. versionchanged:: 9.0
+ *next* parameter was renamed to *succ*.
:param char: The character to transliterate.
:param default: The character used when there is no transliteration.
:param prev: The previous character
- :param next: The next character
+ :param succ: The succeeding character
:return: The transliterated character which may be an empty string
"""
result = default
@@ -1138,7 +1143,7 @@
result = prev
# Japanese
elif char == 'ッ':
- result = self.transliterate(next)[0]
+ result = self.transliterate(succ)[0]
elif char in '々仝ヽヾゝゞ〱〲〳〵〴〵':
result = prev
# Lao
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index 438cbc8..154dba0 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -44,7 +44,7 @@
"""
#
-# (C) Pywikibot team, 2007-2023
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
@@ -474,7 +474,7 @@
elif arg in ('-protectedpages', '-moveprotected'):
protect_type = 'move' if option.startswith('move') else 'edit'
generator = site.protectedpages(namespace=int(value or 0),
- type=protect_type)
+ protect_type=protect_type)
if not generator:
generator = gen_factory.getCombinedGenerator()
diff --git a/scripts/dataextend.py b/scripts/dataextend.py
index 0c97fe9..6c03a22 100755
--- a/scripts/dataextend.py
+++ b/scripts/dataextend.py
@@ -1282,9 +1282,9 @@
TAGRE = re.compile('<[^<>]*>')
SCRIPTRE = re.compile('(?s)<script.*?</script>')
- def __init__(self, id, data=None, item=None, bot=None):
+ def __init__(self, ident, data=None, item=None, bot=None):
"""Initializer."""
- self.id = id
+ self.id = ident
self.data = defaultdict(dict) if data is None else data
self.dbname = None
self.urlbase = None
@@ -16388,12 +16388,12 @@
class UrlAnalyzer(Analyzer):
- def __init__(self, id, data=None, item=None, bot=None):
+ def __init__(self, ident, data=None, item=None, bot=None):
"""Initializer."""
if data is None:
data = defaultdict(dict)
- super().__init__(id.split('/', 3)[-1], data, item, bot)
- self.urlbase = id
+ super().__init__(ident.split('/', 3)[-1], data, item, bot)
+ self.urlbase = ident
self.dbproperty = None
self.isurl = True
diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py
index f73189a..1f74014 100755
--- a/tests/site_generators_tests.py
+++ b/tests/site_generators_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for generators of the site module."""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
@@ -571,14 +571,15 @@
def test_protectedpages_create(self):
"""Test that protectedpages returns protected page titles."""
- pages = list(self.get_site().protectedpages(type='create', total=10))
+ pages = list(self.get_site().protectedpages(protect_type='create',
+ total=10))
# Do not check for the existence of pages as they might exist (T205883)
self.assertLessEqual(len(pages), 10)
def test_protectedpages_edit(self):
"""Test that protectedpages returns protected pages."""
site = self.get_site()
- pages = list(site.protectedpages(type='edit', total=10))
+ pages = list(site.protectedpages(protect_type='edit', total=10))
for page in pages:
self.assertTrue(page.exists())
self.assertIn('edit', page.protection())
@@ -590,7 +591,8 @@
levels = set()
all_levels = site.protection_levels().difference([''])
for level in all_levels:
- if list(site.protectedpages(type='edit', level=level, total=1)):
+ if list(site.protectedpages(protect_type='edit', level=level,
+ total=1)):
levels.add(level)
if not levels:
self.skipTest(
@@ -602,7 +604,8 @@
# if only one level found, then use any other except that
level = next(iter(all_levels.difference([level])))
invalid_levels = all_levels.difference([level])
- pages = list(site.protectedpages(type='edit', level=level, total=10))
+ pages = list(site.protectedpages(protect_type='edit', level=level,
+ total=10))
for page in pages:
self.assertTrue(page.exists())
self.assertIn('edit', page.protection())
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/991917?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: Ia3bc1df5bde80e90bceede3500421a9e530fad4b
Gerrit-Change-Number: 991917
Gerrit-PatchSet: 4
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/+/993213?usp=email )
Change subject: [dist] add pyproject.toml
......................................................................
[dist] add pyproject.toml
While build only installs setuptools and weel to isolated environment
but packaging is needed by setup.py. add pyproject.toml file to
determine requirements for build-system.
Remove flake8-executable due to false possitives.
Bug: T355988
Change-Id: Ib241d68109d87cc0924994729922c222ce0888e9
---
A pyproject.toml
1 file changed, 18 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..e94bba3
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,2 @@
+[build-system]
+requires = ["packaging", "setuptools", "wheel"]
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/993213?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: Ib241d68109d87cc0924994729922c222ce0888e9
Gerrit-Change-Number: 993213
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged