jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[BUGFIX] replace archive pattern fields to string conversion

use string conversion format fields to support non latin numbers
introduced with https://gerrit.wikimedia.org/r/c/pywikibot/core/+/163213
backported from master branch

Bug: T313692
Change-Id: Ic543ad607d35a68cdde04a18653804996f96fdb2
---
M docs/requirements-py3.txt
M pywikibot/__metadata__.py
M scripts/archivebot.py
3 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/docs/requirements-py3.txt b/docs/requirements-py3.txt
index c213a4a..7c9fd27 100644
--- a/docs/requirements-py3.txt
+++ b/docs/requirements-py3.txt
@@ -1,4 +1,4 @@
# This is a PIP requirements file for building Sphinx documentation of pywikibot
# requirements.txt is also needed

-sphinx >= 4.5.0,!=5.0.0,!=5.0.1,!=5.0.2
\ No newline at end of file
+sphinx == 4.5.0
\ No newline at end of file
diff --git a/pywikibot/__metadata__.py b/pywikibot/__metadata__.py
index 0c0e1f8..21e0e01 100644
--- a/pywikibot/__metadata__.py
+++ b/pywikibot/__metadata__.py
@@ -11,7 +11,7 @@


__name__ = 'pywikibot'
-__version__ = '7.5.0'
+__version__ = '7.5.1'
__description__ = 'Python MediaWiki Bot Framework'
__maintainer__ = 'The Pywikibot team'
__maintainer_email__ = 'pywikibot@lists.wikimedia.org'
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index 4ab18e6..ecc33d6 100755
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -54,16 +54,16 @@

Variables below can be used in the value for "archive" in the template above:

-%(counter)d the current value of the counter
-%(year)d year of the thread being archived
-%(isoyear)d ISO year of the thread being archived
-%(isoweek)d ISO week number of the thread being archived
-%(semester)d semester term of the year of the thread being archived
-%(quarter)d quarter of the year of the thread being archived
-%(month)d month (as a number 1-12) of the thread being archived
+%(counter)s the current value of the counter
+%(year)s year of the thread being archived
+%(isoyear)s ISO year of the thread being archived
+%(isoweek)s ISO week number of the thread being archived
+%(semester)s semester term of the year of the thread being archived
+%(quarter)s quarter of the year of the thread being archived
+%(month)s month (as a number 1-12) of the thread being archived
%(monthname)s localized name of the month above
%(monthnameshort)s first three letters of the name above
-%(week)d week number of the thread being archived
+%(week)s week number of the thread being archived

The ISO calendar starts with the Monday of the week which has at least four
days in the new Gregorian calendar. If January 1st is between Monday and
@@ -86,6 +86,10 @@
-namespace:NS only archive pages from a given namespace
-page:PAGE archive a single PAGE, default ns is a user talk page
-salt:SALT specify salt
+
+.. versionchanged:: 7.5.1
+ string presentation type should be used for "archive" variable in the
+ template to support non latin values
"""
#
# (C) Pywikibot team, 2006-2022
@@ -434,7 +438,6 @@
self.maxsize = 2096128 # 2 MB - 1 KB gap

self.page = DiscussionPage(page, self)
- self.load_config()
self.comment_params = {
'from': self.page.title(),
}
@@ -444,6 +447,7 @@
self.month_num2orig_names = {}
for n, (long, short) in enumerate(self.site.months_names, start=1):
self.month_num2orig_names[n] = {'long': long, 'short': short}
+ self.load_config()

def get_attr(self, attr, default='') -> Any:
"""Get an archiver attribute."""
@@ -480,25 +484,38 @@
return self.get_attr('key') == hexdigest

def load_config(self) -> None:
- """Load and validate archiver template."""
- pywikibot.output('Looking for: {{{{{}}}}} in {}'.format(
- self.tpl.title(), self.page))
+ """Load and validate archiver template.
+
+ .. versionchanged:: 7.5.1
+ replace archive pattern fields to string conversion
+ """
+ pywikibot.info('Looking for: {{{{{}}}}} in {}'
+ .format(self.tpl.title(), self.page))
+
+ fields = self.get_params(self.now, 0).keys() # dummy parameters
+ pattern = re.compile(r'%(\((?:{})\))d'.format('|'.join(fields)))
for tpl, params in self.page.raw_extracted_templates:
try: # Check tpl name before comparing; it might be invalid.
tpl_page = pywikibot.Page(self.site, tpl, ns=10)
tpl_page.title()
except Error:
continue
+
if tpl_page == self.tpl:
for item, value in params.items():
+ # convert archive pattern fields to string
+ # to support non latin digits
+ if item == 'archive':
+ value = pattern.sub(r'%\1s', value)
self.set_attr(item.strip(), value.strip())
break
else:
raise MissingConfigError('Missing or malformed template')
- if not self.get_attr('algo', ''):
- raise MissingConfigError('Missing argument "algo" in template')
- if not self.get_attr('archive', ''):
- raise MissingConfigError('Missing argument "archive" in template')
+
+ for field in ('algo', 'archive'):
+ if not self.get_attr(field, ''):
+ raise MissingConfigError('Missing argument {!r} in template'
+ .format(field))

def should_archive_thread(self, thread: DiscussionThread
) -> Optional[ShouldArchive]:

To view, visit change 816346. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: stable
Gerrit-Change-Id: Ic543ad607d35a68cdde04a18653804996f96fdb2
Gerrit-Change-Number: 816346
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged