jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
Update template to py3

Bug: T257399
Change-Id: Ibffd45d7445f3dedbc358e374d5014259f83323c
---
M scripts/template.py
1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/scripts/template.py b/scripts/template.py
index 766f8a8..2dab17b 100755
--- a/scripts/template.py
+++ b/scripts/template.py
@@ -110,22 +110,18 @@
#
# Distributed under the terms of the MIT license.
#
-from __future__ import absolute_import, division, unicode_literals
-
-from itertools import chain
import re

+from itertools import chain
from warnings import warn

import pywikibot

from pywikibot import i18n, pagegenerators, textlib
-
from pywikibot.bot import SingleSiteBot
from pywikibot.exceptions import ArgumentDeprecationWarning
from pywikibot.pagegenerators import XMLDumpPageGenerator
from pywikibot.tools import deprecated, filter_unique
-
from scripts.replace import ReplaceRobot as ReplaceBot


@@ -139,7 +135,7 @@
(cur table), and may not still transclude the template.
"""

- def __init__(self, templates, xmlfilename):
+ def __init__(self, templates, xmlfilename) -> None:
"""
Initializer.

@@ -169,15 +165,15 @@
r'\{\{ *([mM][sS][gG]:)?(?:%s) *(?P<parameters>\|[^}]+|) *}}'
% '|'.join(template_patterns))

- super(XmlDumpTemplatePageGenerator, self).__init__(
- xmlfilename, site=mysite, text_predicate=template_regex.search)
+ super().__init__(xmlfilename, site=mysite,
+ text_predicate=template_regex.search)


class TemplateRobot(ReplaceBot):

"""This bot will replace, remove or subst all occurrences of a template."""

- def __init__(self, generator, templates, **kwargs):
+ def __init__(self, generator, templates, **kwargs) -> None:
"""
Initializer.

@@ -256,14 +252,14 @@
replacements.append((template_regex,
r'{{%s\g<parameters>}}' % new))

- super(TemplateRobot, self).__init__(
+ super().__init__(
generator, replacements, exceptions,
always=self.getOption('always'),
addcat=self.getOption('addcat'),
summary=self.getOption('summary'))


-def main(*args):
+def main(*args) -> None:
"""
Process command line arguments and invoke bot.

@@ -381,7 +377,4 @@


if __name__ == '__main__':
- try:
- main()
- except Exception:
- pywikibot.error('Fatal error:', exc_info=True)
+ main()

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibffd45d7445f3dedbc358e374d5014259f83323c
Gerrit-Change-Number: 611936
Gerrit-PatchSet: 1
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged