jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022005?usp=email )
Change subject: [fix] use filter_unique() in Site.alllinks() for MW >= 1.43
......................................................................
[fix] use filter_unique() in Site.alllinks() for MW >= 1.43
unique parameter is not supported with MW 1.43 currently and it might
be dropped in misermode. Therefore use filter_unique() to ensure
getting unique pages.
Bug: T359427
Change-Id: I16b7bd439dccfcc67b814e913955dea02a2700b4
---
M pywikibot/site/_generators.py
M tests/site_generators_tests.py
2 files changed, 26 insertions(+), 14 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 457ae3c..a1be9e6 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -984,33 +984,47 @@
) -> Generator[pywikibot.Page, None, None]:
"""Iterate all links to pages (which need not exist) in one namespace.
- Note that, in practice, links that were found on pages that have
- been deleted may not have been removed from the links table, so this
- method can return false positives.
+ .. note:: In practice, links that were found on pages that have
+ been deleted may not have been removed from the links table,
+ so this method can return false positives.
+
+ .. caution:: *unique* parameter is no longer supported by
+ MediaWiki 1.43 or higher. Pywikibot uses
+ :func:`tools.itertools.filter_unique` in that case which
+ might be memory intensive. Use it with care.
.. seealso:: :api:`Alllinks`
:param start: Start at this title (page need not exist).
:param prefix: Only yield pages starting with this string.
:param namespace: Iterate pages from this (single) namespace
- :param unique: If True, only iterate each link title once (default:
- iterate once for each linking page)
- :param fromids: if True, include the pageid of the page containing
- each link (default: False) as the '_fromid' attribute of the Page;
- cannot be combined with unique
- :raises KeyError: the namespace identifier was not resolved
- :raises TypeError: the namespace identifier has an inappropriate
- type such as bool, or an iterable with more than one namespace
+ :param unique: If True, only iterate each link title once
+ (default: False)
+ :param fromids: if True, include the pageid of the page
+ containing each link (default: False) as the '_fromid'
+ attribute of the Page; cannot be combined with *unique*
+ :raises KeyError: the *namespace* identifier was not resolved
+ :raises TypeError: the *namespace* identifier has an
+ inappropriate type such as bool, or an iterable with more
+ than one namespace
"""
if unique and fromids:
raise Error('alllinks: unique and fromids cannot both be True.')
algen = self._generator(api.ListGenerator, type_arg='alllinks',
namespaces=namespace, alfrom=start,
- total=total, alunique=unique)
+ total=total)
if prefix:
algen.request['alprefix'] = prefix
if fromids:
algen.request['alprop'] = 'title|ids'
+ if not unique:
+ pass
+ elif self.mw_version < '1.43':
+ algen.request['alunique'] = True
+ else:
+ # unique filter for mw >= 1.43, use (title, ns) as key
+ # See: T359425, T359427
+ algen = filter_unique(algen, key=lambda x: (x['title'], x['ns']))
for link in algen:
p = pywikibot.Page(self, link['title'], link['ns'])
if fromids:
diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py
index 87f97ba..bc56f4a 100755
--- a/tests/site_generators_tests.py
+++ b/tests/site_generators_tests.py
@@ -338,8 +338,6 @@
def test_all_links(self):
"""Test the site.alllinks() method."""
mysite = self.get_site()
- if mysite.sitename in ('wikipedia:de', 'wikipedia:en'):
- self.skipTest(f'skipping test on {mysite} due to T359427')
fwd = list(mysite.alllinks(total=10))
uniq = list(mysite.alllinks(total=10, unique=True))
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1022005?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: I16b7bd439dccfcc67b814e913955dea02a2700b4
Gerrit-Change-Number: 1022005
Gerrit-PatchSet: 3
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/+/1020869?usp=email )
Change subject: [doc] Fix user-config.py filename
......................................................................
[doc] Fix user-config.py filename
Bug: T362673
Change-Id: Ibb56e979a35331a5417c79ee92dd73cbdc124e41
---
M pywikibot/cosmetic_changes.py
M pywikibot/login.py
M pywikibot/specialbots/_upload.py
3 files changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 27650ef..e18a3ae 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -28,7 +28,7 @@
You may disable cosmetic changes by adding the all unwanted languages to
the `dictionary cosmetic_changes_disable` in your user config file
-(`user_config.py`). It should contain a tuple of languages for each site
+(`user-config.py`). It should contain a tuple of languages for each site
where you wish to disable cosmetic changes. You may use it with
`cosmetic_changes_mylang_only` is False, but you can also disable your
own language. This also overrides the settings in the dictionary
@@ -51,7 +51,7 @@
'your_script_name_2']
"""
#
-# (C) Pywikibot team, 2006-2023
+# (C) Pywikibot team, 2006-2024
#
# Distributed under the terms of the MIT license.
#
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 17c6924..c109a21 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -1,6 +1,6 @@
"""Library to log the bot in to a wiki account."""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -105,7 +105,7 @@
'ERROR: '
'username for {site.family.name}:{site.code} is undefined.'
'\nIf you have a username for that site, please add a '
- 'line to user config file (user_config.py) as follows:\n'
+ 'line to user config file (user-config.py) as follows:\n'
"usernames['{site.family.name}']['{site.code}'] = "
"'myUsername'".format(site=site))
self.password = password
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index 1695873..7e3a8d8 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -88,7 +88,7 @@
would be overwritten or another mistake would be risked. Set it to
an array of warning codes to selectively ignore specific warnings.
:param target_site: Set the site to upload to. If target site is not
- given it's taken from user config file (user_config.py).
+ given it's taken from user config file (user-config.py).
:type target_site: object
:param aborts: List of the warning types to abort upload on. Set to
True to abort on any warning.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1020869?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: Ibb56e979a35331a5417c79ee92dd73cbdc124e41
Gerrit-Change-Number: 1020869
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/+/1018947?usp=email )
Change subject: [L10N] localize noreferences.py for simple-wiki
......................................................................
[L10N] localize noreferences.py for simple-wiki
Bug: T362103
Change-Id: Ia0dc3a565f3c8f1dc629aa05b2889e59253af6f8
---
M scripts/noreferences.py
1 file changed, 58 insertions(+), 18 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index e1313da..eb63165 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -52,12 +52,15 @@
'¶ms;': pagegenerators.parameterHelp,
}
-# References sections are usually placed before further reading / external
-# link sections. This dictionary defines these sections, sorted by priority.
-# For example, on an English wiki, the script would place the "References"
-# section in front of the "Further reading" section, if that existed.
-# Otherwise, it would try to put it in front of the "External links" section,
-# or if that fails, the "See also" section, etc.
+placeBeforeSections: dict[str, list[str]]
+"""References sections are usually placed before further reading /
+external link sections. This dictionary defines these sections, sorted
+by priority. For example, on an English wiki, the script would place the
+"References" section in front of the "Further reading" section, if that
+existed. Otherwise, it would try to put it in front of the
+"External links" section, or if that fails, the "See also" section, etc.
+"""
+
placeBeforeSections = {
'ar': [ # no explicit policy on where to put the references
'وصلات خارجية',
@@ -208,6 +211,10 @@
'حوالا',
'خارجي ڳنڌڻا',
],
+ 'simple': [
+ 'Other websites',
+ 'Sources',
+ ],
'sk': [
'Pozri aj',
],
@@ -241,10 +248,30 @@
],
}
-# Titles of sections where a reference tag would fit into.
-# The first title should be the preferred one: It's the one that will be
-# used when a new section has to be created. Section titles can be regex
-# patterns except of the first.
+PLACE_AFTER_SECTIONS: dict[str, list[str]]
+"""References sections can also be placed after a given section. This
+dictionary defines these sections, sorted by priority. For example, on
+Simple wiki, the script would place the "References" section after the
+"Notes" section, if that existed. The PLACE_AFTER_SECTIONS is priorized
+over the placing of the "placeBeforeSections" sections.
+
+.. attention:: not implemented yet.
+"""
+
+# TODO: not implemented yet.
+PLACE_AFTER_SECTIONS = {
+ 'simple': [
+ 'Notes',
+ ],
+}
+
+referencesSections: dict[str, dict[str, list[str]]]
+"""Titles of sections where a reference tag would fit into. The first
+title should be the preferred one: It's the one that will be used when
+a new section has to be created. Section titles can be regex patterns
+except of the first.
+"""
+
referencesSections = {
'wikipedia': {
'ar': [ # not sure about which ones are preferred.
@@ -385,6 +412,9 @@
'sd': [
'حوالا',
],
+ 'simple': [
+ 'References',
+ ],
'sk': [
'Referencie',
],
@@ -419,8 +449,11 @@
referencesSections['wiktionary'] = dict(referencesSections['wikipedia'])
referencesSections['wiktionary'].update(cs=['poznámky', 'reference'])
-# Templates which include a <references /> tag. If there is no such template
-# on your wiki, you don't have to enter anything here.
+referencesTemplates: dict[str, dict[str, list[str]]]
+"""Templates which include a <references /> tag. If there is no such
+template on your wiki, you don't have to enter anything here.
+"""
+
referencesTemplates = {
'wikipedia': {
'ar': ['مراجع', 'المراجع', 'ثبت المراجع',
@@ -469,6 +502,7 @@
'Сноска', 'Сноски'],
'sd': ['Reflist', 'Refs', 'Reference',
'حوالا'],
+ 'simple': ['Reflist'],
'sr': ['Reflist', 'Референце', 'Извори', 'Рефлист'],
'szl': ['Przipisy', 'Připisy'],
'th': ['รายการอ้างอิง'],
@@ -478,8 +512,11 @@
},
}
-# Text to be added instead of the <references /> tag.
-# Define this only if required by your wiki.
+referencesSubstitute: dict[str, dict[str, list[str]]]
+"""Text to be added instead of the <references /> tag. Define this only
+if required by your wiki.
+"""
+
referencesSubstitute = {
'wikipedia': {
'ar': '{{مراجع}}',
@@ -498,6 +535,7 @@
'pl': '{{Przypisy}}',
'ru': '{{примечания}}',
'sd': '{{حوالا}}',
+ 'simple': '{{reflist}}',
'sr': '{{reflist}}',
'szl': '{{Przipisy}}',
'th': '{{รายการอ้างอิง}}',
@@ -506,11 +544,13 @@
},
}
-# Sites where no title is required for references template
-# as it is already included there
-noTitleRequired = ['be', 'szl']
+noTitleRequired: list[str] = ['be', 'szl']
+"""Sites where no title is required for references template as it is
+already included there
+"""
-maintenance_category = 'Q6483427'
+#: The maintenance category to retrieve pages for processing
+maintenance_category: str = 'Q6483427'
_ref_regex = re.compile('</ref>', re.IGNORECASE)
_references_regex = re.compile('<references.*?/>', re.IGNORECASE)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1018947?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: Ia0dc3a565f3c8f1dc629aa05b2889e59253af6f8
Gerrit-Change-Number: 1018947
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
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1019070?usp=email )
Change subject: [doc] Update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst
......................................................................
[doc] Update ROADMAP.rst, CHANGELOG.rst and AUTHORS.rst
Change-Id: I51c37a19ea24d979ca1c997766719a87495d8c43
---
M AUTHORS.rst
M ROADMAP.rst
M scripts/CHANGELOG.rst
3 files changed, 26 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/AUTHORS.rst b/AUTHORS.rst
index 1fad649..fa3654e 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -93,6 +93,7 @@
Egon
Enag2000
Eranroz
+ Eric Pien
Erwin
Evrifaessa
diff --git a/ROADMAP.rst b/ROADMAP.rst
index 850f0a3..e0cecfc 100644
--- a/ROADMAP.rst
+++ b/ROADMAP.rst
@@ -1,6 +1,7 @@
Current release
---------------
+* Skip process that requires login to logout (:phab:`T326614`)
* 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`)
@@ -9,6 +10,7 @@
* 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`)
+* i18n updates
Deprecations
------------
diff --git a/scripts/CHANGELOG.rst b/scripts/CHANGELOG.rst
index 975b13a..98733d3 100644
--- a/scripts/CHANGELOG.rst
+++ b/scripts/CHANGELOG.rst
@@ -1,6 +1,20 @@
Scripts Changelog
=================
+9.1.0
+-----
+
+colors
+^^^^^^
+
+* Fix TypeError with :func:`backports.batched` (:phab:`T362035`)
+
+noreferences
+^^^^^^^^^^^^
+
+* Show an error message and leave if script is not localized (:phab:`T362103`)
+
+
9.0.0
-----
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1019070?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: I51c37a19ea24d979ca1c997766719a87495d8c43
Gerrit-Change-Number: 1019070
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