jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692862 )
Change subject: [IMPR] use itertools.count in reflinks.py
......................................................................
[IMPR] use itertools.count in reflinks.py
Change-Id: I7ff4e138a61ea27813367fad503248b21ae93981
---
M scripts/reflinks.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Matěj Suchánek: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index dc437c4..2c4a9d1 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -41,11 +41,13 @@
#
import codecs
import http.client as httplib
+import itertools
import os
import re
import socket
import subprocess
import tempfile
+
from contextlib import suppress
from functools import partial
from http import HTTPStatus
@@ -353,7 +355,7 @@
used_numbers.add(int(number))
# generator to give the next free number
- free_number = (str(i) for i in range(1, 1000) # should be enough
+ free_number = (str(i) for i in itertools.count(start=1)
if i not in used_numbers)
for (g, d) in found_refs.items():
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692862
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: I7ff4e138a61ea27813367fad503248b21ae93981
Gerrit-Change-Number: 692862
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Meno25 <meno25mail(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/+/692846 )
Change subject: [docs] Add a glossary to docs
......................................................................
[docs] Add a glossary to docs
Change-Id: Ia31b2ecd5d180e212414126151d0c01ed058370f
---
A docs/glossary.rst
M docs/index.rst
2 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/glossary.rst b/docs/glossary.rst
new file mode 100644
index 0000000..1adafff
--- /dev/null
+++ b/docs/glossary.rst
@@ -0,0 +1,61 @@
+Glossary
+========
+
+.. if you add new entries, keep the alphabetical sorting!
+
+.. glossary::
+
+ ``>>>``
+ The default Python prompt of the interactive Pywikibot shell.
+ Often seen for code examples which can be executed interactively
+ in the interpreter. The :mod:`pywikibot` module is preloaded. The
+ :mod:`scripts.shell` script is part of the :mod:`scripts` module.
+
+ compat
+ The first Pywikibot package formerly known as *Pywikipediabot*
+ also called :term:`trunk` was started in 2003. MediaWiki didn't
+ have an API so a `screen scrapping
+ <https://en.wikipedia.org/Screen_scraper>`_ was used.
+
+ core
+ In 2007 a new branch of Pywikibot formerly known as
+ :term:`trunk` was started using the new MediaWiki API. The
+ current release is |release|.
+
+ master
+ The development branch of Pywikibot. It should not be used for
+ production systems, use :term:`stable` instead. The master branch
+ may have untested features. Use master branch if you want to
+ support development and report undetected problems.
+
+ pwb
+ Can refer to:
+
+ - short for Pywikibot
+ - the :mod:`pwb` wrapper script
+
+ pywikibot
+ **Py**\ thon Media\ **Wiki Bot** Framework, a Python library and
+ collection of scripts that automate work on MediaWiki sites.
+ Originally designed for Wikipedia, it is now used throughout the
+ Wikimedia Foundation's projects and on many other wikis based of
+ MediaWiki software.
+
+ rewrite
+ A former name of :term:`core`.
+
+ stable
+ A stable branch of Pywikibot updated roughly every month
+ after tests passes. This branch is preinstalled at :term:`PAWS`
+ and should be used for production systems.
+
+ trunk
+ A former name of :term:`compat`.
+
+ PAWS
+ PAWS (PAWS: A Web Shell) formerly known as *Pywikibot: A Web Shell*
+ is a Jupyter notebooks deployment hosted by Wikimedia. It has
+ preinstalled the :term:`stable` release of Pywikibot. Refer:
+
+ - https://wikitech.wikimedia.org/wiki/PAWS
+ - https://www.mediawiki.org/wiki/Manual:Pywikibot/PAWS
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index 8db7805..e6cb09a 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -79,6 +79,7 @@
.. toctree::
:maxdepth: 1
+ glossary
changelog
licenses
credits
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692846
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: Ia31b2ecd5d180e212414126151d0c01ed058370f
Gerrit-Change-Number: 692846
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/+/692710 )
Change subject: [cleanup] Remove toStdout parameter of ui.output()
......................................................................
[cleanup] Remove toStdout parameter of ui.output()
toStdout parameter was never used.
The targetStream is passed via TerminalHandler
Change-Id: Iba42257962d94917a2df623449e2fcf256ecf7b0
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 4 insertions(+), 7 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 4b026b0..bdd2672 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -189,14 +189,14 @@
# set the new color, but only if they change
self.encounter_color(color_stack[-1], target_stream)
- def output(self, text, toStdout=False, targetStream=None):
+ def output(self, text, targetStream=None):
"""Forward text to cache and flush if output is not locked.
All input methods locks the output to a stream but collect them
in cache. They will be printed with next unlocked output call or
at termination time.
"""
- self.cache_output(text, toStdout, targetStream)
+ self.cache_output(text, targetStream=targetStream)
if not self.lock.locked():
self.flush()
@@ -213,7 +213,7 @@
"""
self.cache.put_nowait((args, kwargs))
- def stream_output(self, text, toStdout=False, targetStream=None):
+ def stream_output(self, text, targetStream=None):
"""
Output text to a stream.
@@ -268,10 +268,7 @@
text = transliteratedText
if not targetStream:
- if toStdout:
- targetStream = self.stdout
- else:
- targetStream = self.stderr
+ targetStream = self.stderr
self._print(text, targetStream)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692710
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: Iba42257962d94917a2df623449e2fcf256ecf7b0
Gerrit-Change-Number: 692710
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/+/692572 )
Change subject: [tests] Re-implement YearPageGenerator tests
......................................................................
[tests] Re-implement YearPageGenerator tests
A lot of YearPageGenerator tests aren't tests but skipped because
site.lang is missing in date.formats['YearAD'] mapping but
date.formats['YearAD'] was changes to a defaultdict which maps
every missing lang to dh_simpleYearAD function.
Change-Id: I0534651184fe41cdd77164d6d76eaead2ded3192
---
M tests/pagegenerators_tests.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 484bd0c..afcc382 100644
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -476,10 +476,10 @@
"""Test YearPageGenerator."""
site = self.get_site()
# Some languages are missing (T85681)
- if (site.lang not in date.formats['YearBC']
- or site.lang not in date.formats['YearAD']):
+ if site.lang not in date.formats['YearBC']:
self.skipTest(
- 'Date formats for this language are missing from date.py')
+ 'Date formats for {!r} language are missing from date.py'
+ .format(site.lang))
start = -20
end = 2026
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692572
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: I0534651184fe41cdd77164d6d76eaead2ded3192
Gerrit-Change-Number: 692572
Gerrit-PatchSet: 6
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/+/692270 )
Change subject: [IMPR] subclass TerminalHandler from logging.StreamHandler
......................................................................
[IMPR] subclass TerminalHandler from logging.StreamHandler
- rename strm parameter to stream
- use createLock to set thread lock
- flush of superclass to flush the stream which also acquires locking
- rename text to msg like usage in StreamHandler
Change-Id: Iccc67f233880dcc6c55e5980b3942695a03711fc
---
M pywikibot/userinterfaces/terminal_interface_base.py
1 file changed, 22 insertions(+), 26 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 9db7fc3..c7bc96b 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -22,7 +22,7 @@
StandardOption,
)
from pywikibot.logging import INFO, INPUT, STDOUT, VERBOSE, WARNING
-from pywikibot.tools import RLock
+from pywikibot.tools import deprecated_args, RLock
from pywikibot.userinterfaces import transliteration
from pywikibot.userinterfaces._interface_base import ABUIC
@@ -97,7 +97,7 @@
default_stream = self.stderr
# default handler for display to terminal
- default_handler = TerminalHandler(self, strm=default_stream)
+ default_handler = TerminalHandler(self, stream=default_stream)
if config.verbose_output:
default_handler.setLevel(VERBOSE)
else:
@@ -109,7 +109,7 @@
root_logger.addHandler(default_handler)
# handler for level STDOUT
- output_handler = TerminalHandler(self, strm=self.stdout)
+ output_handler = TerminalHandler(self, stream=self.stdout)
output_handler.setLevel(STDOUT)
output_handler.addFilter(MaxLevelFilter(STDOUT))
output_handler.setFormatter(
@@ -117,7 +117,7 @@
root_logger.addHandler(output_handler)
# handler for levels WARNING and higher
- warning_handler = TerminalHandler(self, strm=self.stderr)
+ warning_handler = TerminalHandler(self, stream=self.stderr)
warning_handler.setLevel(WARNING)
warning_handler.setFormatter(
TerminalFormatter(fmt='%(levelname)s: %(message)s%(newline)s'))
@@ -494,44 +494,40 @@
return list(self.argv)
-class TerminalHandler(logging.Handler):
+class TerminalHandler(logging.StreamHandler):
"""A handler class that writes logging records to a terminal.
- This class does not close the stream,
- as sys.stdout or sys.stderr may be (and usually will be) used.
+ This class does not close the stream, as sys.stdout or sys.stderr
+ may be (and usually will be) used.
Slightly modified version of the StreamHandler class that ships with
logging module, plus code for colorization of output.
-
"""
# create a class-level lock that can be shared by all instances
sharedlock = threading.RLock()
- def __init__(self, UI, strm=None):
+ @deprecated_args(strm='stream')
+ def __init__(self, UI, stream=None):
"""Initialize the handler.
- If strm is not specified, sys.stderr is used.
-
+ If stream is not specified, sys.stderr is used.
"""
- super().__init__()
- # replace Handler's instance-specific lock with the shared class lock
- # to ensure that only one instance of this handler can write to
- # the console at a time
- self.lock = TerminalHandler.sharedlock
- if strm is None:
- strm = sys.stderr
- self.stream = strm
- self.formatter = None
+ super().__init__(stream=stream)
self.UI = UI
- def flush(self):
- """Flush the stream."""
- self.stream.flush()
+ def createLock(self):
+ """Acquire a thread lock for serializing access to the underlying I/O.
+
+ Replace Handler's instance-specific lock with the shared
+ class lock to ensure that only one instance of this handler can
+ write to the console at a time.
+ """
+ self.lock = TerminalHandler.sharedlock
def emit(self, record):
- """Emit the record formatted to the output and return it."""
+ """Emit the record formatted to the output."""
if record.name == 'py.warnings':
# Each warning appears twice
# the second time it has a 'message'
@@ -540,8 +536,8 @@
record.__dict__.setdefault('newline', '\n')
- text = self.format(record)
- return self.UI.output(text, targetStream=self.stream)
+ msg = self.format(record)
+ self.UI.output(msg, targetStream=self.stream)
class TerminalFormatter(logging.Formatter):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/692270
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: Iccc67f233880dcc6c55e5980b3942695a03711fc
Gerrit-Change-Number: 692270
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged