jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/588166 )
Change subject: [cleanup] use xml.etree.ElementTree instead of cElementTree
......................................................................
[cleanup] use xml.etree.ElementTree instead of cElementTree
xml.etree.cElementTree is deprecated since Python 3.3
and has been removed in Python 3.9
- update wikistats.py
- update xmlreader.py
- updat README.rst
Bug: T250039
Change-Id: I5e8484cbccbbedcc14d77dcba671ef35a9c2e1c0
---
M pywikibot/README.rst
M pywikibot/data/wikistats.py
M pywikibot/xmlreader.py
3 files changed, 6 insertions(+), 7 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/README.rst b/pywikibot/README.rst
index 6e46698..4513f58 100644
--- a/pywikibot/README.rst
+++ b/pywikibot/README.rst
@@ -24,7 +24,6 @@
are not installed by default on some Linux distributions:
* python-xml (required to parse XML via SaX2)
- * python-celementtree (recommended if you use XML dumps)
* python-tkinter (optional, used by some experimental GUI stuff)
diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py
index 2f2d06f..931fcd9 100644
--- a/pywikibot/data/wikistats.py
+++ b/pywikibot/data/wikistats.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Objects representing WikiStats API."""
#
-# (C) Pywikibot team, 2014-2019
+# (C) Pywikibot team, 2014-2020
#
# Distributed under the terms of the MIT license.
from __future__ import absolute_import, division, unicode_literals
@@ -169,12 +169,12 @@
if table in self._data.setdefault('xml', {}):
return self._data['xml'][table]
- from xml.etree import cElementTree
+ from xml.etree import ElementTree
data = self.raw_cached(table, 'xml')
f = BytesIO(data)
- tree = cElementTree.parse(f)
+ tree = ElementTree.parse(f)
data = []
diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index 67154c8..b46315b 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -9,7 +9,7 @@
XmlEntry objects which can be used by other bots.
"""
#
-# (C) Pywikibot team, 2005-2018
+# (C) Pywikibot team, 2005-2020
#
# Distributed under the terms of the MIT license.
#
@@ -18,7 +18,7 @@
import re
import threading
-from xml.etree.cElementTree import iterparse
+from xml.etree.ElementTree import iterparse
import xml.sax
@@ -116,7 +116,7 @@
self._parse = self._parse_only_latest
def parse(self):
- """Generator using cElementTree iterparse function."""
+ """Generator using ElementTree iterparse function."""
with open_archive(self.filename) as source:
# iterparse's event must be a str but they are unicode with
# unicode_literals in Python 2
--
To view, visit https://gerrit.wikimedia.org/r/588166
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5e8484cbccbbedcc14d77dcba671ef35a9c2e1c0
Gerrit-Change-Number: 588166
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/588154 )
Change subject: [IMPR] rename different args variables to be more informative
......................................................................
[IMPR] rename different args variables to be more informative
- rename local_args to global_args: these are local args for
pwb.py wrapper but they are global options like -family and -lang
- rename args to script_args: these are options passed to the
called script
- rename pwb_args to unknown_args: they collect unknown global
options which aren't script args because they are entered
in fron of the script name
Change-Id: I1b8f604a8c56f514f05096250cfe0494d82f3d35
---
M pwb.py
1 file changed, 8 insertions(+), 8 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index e50d678..c1c24a9 100755
--- a/pwb.py
+++ b/pwb.py
@@ -212,7 +212,7 @@
if not check_modules():
sys.exit()
-filename, args, local_args = handle_args(*sys.argv)
+filename, script_args, global_args = handle_args(*sys.argv)
# Search for user-config.py before creating one.
# If successful, user-config.py already exists in one of the candidate
@@ -337,12 +337,12 @@
if not filename:
return False
- if local_args: # don't use sys.argv
- pwb_args = pwb.handle_args(local_args)
- if pwb_args:
+ if global_args: # don't use sys.argv
+ unknown_args = pwb.handle_args(global_args)
+ if unknown_args:
print('ERROR: unknown pwb.py argument{}: {}\n'
- .format('' if len(pwb_args) == 1 else 's',
- ', '.join(pwb_args)))
+ .format('' if len(unknown_args) == 1 else 's',
+ ', '.join(unknown_args)))
return False
file_package = None
@@ -378,9 +378,9 @@
warn('Parent module %s not found: %s'
% (file_package, e), ImportWarning)
- if check_modules(filename) or '-help' in args:
+ if check_modules(filename) or '-help' in script_args:
run_python_file(filename,
- [filename] + args,
+ [filename] + script_args,
[Path(filename).stem] + argvu[1:],
file_package)
return True
--
To view, visit https://gerrit.wikimedia.org/r/588154
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1b8f604a8c56f514f05096250cfe0494d82f3d35
Gerrit-Change-Number: 588154
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)