jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/801654 )
Change subject: [doc] Update eventstreams documentation
......................................................................
[doc] Update eventstreams documentation
- remove rcstream.p hin which was removed 5 years ago
- add type hints to keyword arguments
- refer https://stream.wikimedia.org
Change-Id: I28da3e0f0ddf7ac95fe67944bdb000551318c76b
---
M pywikibot/comms/eventstreams.py
1 file changed, 24 insertions(+), 22 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index dd4d844..2f1ce69 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -5,7 +5,7 @@
This module requires sseclient to be installed::
- pip install sseclient
+ pip install "sseclient<0.0.23,>=0.0.18"
.. versionadded:: 3.0
"""
@@ -44,7 +44,6 @@
"""Basic EventStreams iterator class for Server-Sent Events (SSE) protocol.
It provides access to arbitrary streams of data including recent changes.
- It replaces rcstream.py implementation.
Usage:
@@ -75,28 +74,31 @@
def __init__(self, **kwargs) -> None:
"""Initializer.
- :keyword site: a project site object. Used when no url is given
- :type site: APISite
- :keyword since: a timestamp for older events; there will likely be
- between 7 and 31 days of history available but is not guaranteed.
- It may be given as a pywikibot.Timestamp, an ISO 8601 string
- or a mediawiki timestamp string.
- :type since: pywikibot.Timestamp or str
- :keyword streams: event stream types. Mandatory when no url is given.
- Multiple streams may be given as a string with comma separated
- stream types or an iterable of strings
- Refer https://stream.wikimedia.org/?doc for available
- Wikimedia stream types.
- :type streams: str or iterable
- :keyword timeout: a timeout value indication how long to wait to send
- data before giving up
- :type timeout: int, float or a tuple of two values of int or float
- :keyword url: an url retrieving events from. Will be set up to a
- default url using _site.family settings, stream types and timestamp
- :type url: str
- :param kwargs: keyword arguments passed to SSEClient and requests lib
+ :keyword APISite site: a project site object. Used if no url is
+ given
+ :keyword pywikibot.Timestamp or str since: a timestamp for older
+ events; there will likely be between 7 and 31 days of
+ history available but is not guaranteed. It may be given as
+ a pywikibot.Timestamp, an ISO 8601 string or a mediawiki
+ timestamp string.
+ :keyword Iterable[str] or str streams: event stream types.
+ Mandatory when no url is given. Multiple streams may be
+ given as a string with comma separated stream types or an
+ iterable of strings
+ :keyword int or float or Tuple[int or float, int or float] timeout:
+ a timeout value indication how long to wait to send data
+ before giving up
+ :keyword str url: an url retrieving events from. Will be set up
+ to a default url using _site.family settings, stream types
+ and timestamp
+ :param kwargs: keyword arguments passed to `SSEClient` and
+ `requests` library
:raises ImportError: sseclient is not installed
:raises NotImplementedError: no stream types specified
+
+ .. seealso:: https://stream.wikimedia.org/?doc#streams for
+ available Wikimedia stream types to be passed with `streams`
+ parameter.
"""
if isinstance(EventSource, Exception):
raise ImportError('sseclient is required for EventStreams;\n'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/801654
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: I28da3e0f0ddf7ac95fe67944bdb000551318c76b
Gerrit-Change-Number: 801654
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/+/801701 )
Change subject: [doc] Don't use Sphinx 5.0
......................................................................
[doc] Don't use Sphinx 5.0
There are problems with parameters which are shown with double colons.
Change-Id: Ic90b40ed78903ae6714472c5429aa7a1220f4f54
---
M docs/requirements-py3.txt
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/requirements-py3.txt b/docs/requirements-py3.txt
index 3a80334..afbaa42 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.1.0
\ No newline at end of file
+sphinx >= 4.1.0,!=5.0.0
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/801701
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: Ic90b40ed78903ae6714472c5429aa7a1220f4f54
Gerrit-Change-Number: 801701
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/+/799904 )
Change subject: [IMPR] Move login.py to pywikibot/scripts folder
......................................................................
[IMPR] Move login.py to pywikibot/scripts folder
- login.py to pywikibot/scripts folder
- add the script to the sphinx documentation
- update other documentation
- remove this script from pywikibot_script_docstring_fixups
- update script_tests.py
Bug: T309290
Change-Id: I5fc9cd0263e155fc923e71aa0f91863ecffedb90
---
M docs/conf.py
M docs/utilities/scripts.rst
M docs/utilities/scripts_ref.rst
M pywikibot/CONTENT.rst
R pywikibot/scripts/login.py
M scripts/README.rst
M tests/script_tests.py
7 files changed, 36 insertions(+), 25 deletions(-)
Approvals:
D3r1ck01: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 1b2a310..ab2130c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -470,9 +470,6 @@
'in :py:mod:`pywikibot.fixes`.')
elif name == 'scripts.cosmetic_changes' and line == '&warning;':
lines[index] = warning
- elif name == 'scripts.login' and '*' in line:
- # Escape star wildcard in scripts/login.py
- lines[index] = line.replace('*', '\\*')
elif (line.endswith(':') and not line.lstrip().startswith(':')
and 'Traceback (most recent call last)' not in line):
# Initiate code block except pagegenerator arguments follows
diff --git a/docs/utilities/scripts.rst b/docs/utilities/scripts.rst
index d47ea1b..8c8ff0f 100644
--- a/docs/utilities/scripts.rst
+++ b/docs/utilities/scripts.rst
@@ -22,6 +22,12 @@
.. automodule:: pywikibot.scripts.generate_user_files
:no-members:
+login script
+------------
+
+.. automodule:: pywikibot.scripts.login
+ :no-members:
+
preload_sites script
--------------------
diff --git a/docs/utilities/scripts_ref.rst b/docs/utilities/scripts_ref.rst
index 5188659..4720fbf 100644
--- a/docs/utilities/scripts_ref.rst
+++ b/docs/utilities/scripts_ref.rst
@@ -19,6 +19,11 @@
.. automodule:: pywikibot.scripts.generate_user_files
+login script
+------------
+
+.. automodule:: pywikibot.scripts.login
+
preload_sites script
--------------------
diff --git a/pywikibot/CONTENT.rst b/pywikibot/CONTENT.rst
index cf03bbc..5404ec6 100644
--- a/pywikibot/CONTENT.rst
+++ b/pywikibot/CONTENT.rst
@@ -129,6 +129,8 @@
+----------------------------+------------------------------------------------------+
| generate_user_files.py | Creates user-config.py or user-fixes.py |
+----------------------------+------------------------------------------------------+
+ | login.py | Script to log the bot in to a wiki account. |
+ +----------------------------+------------------------------------------------------+
| preload_sites.py | Preload and cache site information for each |
| | WikiMedia family within seconds. Useful for bots |
| | running on multiple sites. |
diff --git a/scripts/login.py b/pywikibot/scripts/login.py
similarity index 81%
rename from scripts/login.py
rename to pywikibot/scripts/login.py
index 6462206..b4627c2 100755
--- a/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -5,27 +5,27 @@
Suggestion is to make a special account to use for bot use only. Make
sure this bot account is well known on your home wiki before using.
-The following parameters are supported:
+The following parameters are supported::
- -family:FF Log in to the LL language of the FF family.
- -lang:LL Example: -family:wiktionary -lang:fr will log you in at
- fr.wiktionary.org.
+ -family:FF Log in to the LL language of the FF family.
+ -lang:LL Example: -family:wiktionary -lang:fr will log you in at
+ fr.wiktionary.org.
- -site:FF:LL Log in to the LL language of the FF family
+ -site:FF:LL Log in to the LL language of the FF family
- -all Try to log in on all sites where a username is defined in
- user-config.py.
+ -all Try to log in on all sites where a username is defined in
+ user-config.py.
- -logout Log out of the current site. Combine with -all to log out of
- all sites, or with -family and -lang to log out of a specific
- site.
+ -logout Log out of the current site. Combine with -all to log out of
+ all sites, or with -family and -lang to log out of a specific
+ site.
- -oauth Generate OAuth authentication information.
- NOTE: Need to copy OAuth tokens to your user-config.py
- manually. -logout is not compatible with -oauth.
+ -oauth Generate OAuth authentication information.
+ NOTE: Need to copy OAuth tokens to your user-config.py
+ manually. -logout is not compatible with -oauth.
- -autocreate Auto-create an account using unified login when necessary.
- Note: the global account must exist already before using this.
+ -autocreate Auto-create an account using unified login when necessary.
+ Note: the global account must exist already before using this.
If not given as parameter, the script will ask for your username and
password (password entry will be hidden), log in to your home wiki using
@@ -37,14 +37,16 @@
To log out, throw away the *.lwp file that is created in the data
subdirectory.
+
+.. versionchanged:: 7.4
+ moved to :mod:`pywikibot.scripts` folder
"""
#
-# (C) Pywikibot team, 2003-2021
+# (C) Pywikibot team, 2003-2022
#
# Distributed under the terms of the MIT license.
#
import pywikibot
-import pywikibot.bot
from pywikibot import config
from pywikibot.backports import Tuple
from pywikibot.exceptions import SiteDefinitionError
diff --git a/scripts/README.rst b/scripts/README.rst
index 99d6d38..2d65034 100644
--- a/scripts/README.rst
+++ b/scripts/README.rst
@@ -84,8 +84,6 @@
+------------------------+---------------------------------------------------------+
| listpages.py | Print a list of pages, defined by a page generator. |
+------------------------+---------------------------------------------------------+
- | login.py | Script to log the bot in to a wiki account. |
- +------------------------+---------------------------------------------------------+
| misspelling.py | Similar to solve_disambiguation.py. It is supposed to |
| | fix links that contain common spelling mistakes. |
+------------------------+---------------------------------------------------------+
diff --git a/tests/script_tests.py b/tests/script_tests.py
index cc5b3dd..0080f53 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -19,7 +19,9 @@
ci_test_run = os.environ.get('PYWIKIBOT_TESTS_RUNNING', '0') == '1'
scripts_path = join_root_path('scripts')
-framework_scripts = ['shell']
+
+# login scritpt should be the first to test
+framework_scripts = ['login', 'shell']
# These dependencies are not always the package name which is in setup.py.
# Here, the name given to the module which will be imported is required.
@@ -58,8 +60,7 @@
return scripts
-script_list = ['login'] + list_scripts(scripts_path,
- exclude='login.py') + framework_scripts
+script_list = framework_scripts + list_scripts(scripts_path)
script_input = {
'interwiki': 'Test page that should not exist\n',
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/799904
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: I5fc9cd0263e155fc923e71aa0f91863ecffedb90
Gerrit-Change-Number: 799904
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.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/+/791780 )
Change subject: [IMPR] Print the page list immediately except pages are preloaded
......................................................................
[IMPR] Print the page list immediately except pages are preloaded
- pages are collected in the the output_list due to T220905 but as long
as pages aren't preloaded the list entries can be printed immediately.
- clear list if self.opt.put is not True
Change-Id: I66399022f0e76ec7d74883ecf15ff5e8bd841bad
---
M scripts/listpages.py
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/listpages.py b/scripts/listpages.py
index dfedc77..1ca7def 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -181,6 +181,7 @@
'notitle': False,
'outputlang': None,
'overwrite': False,
+ 'preloading': None,
'summary': '',
'get': False,
'put': None,
@@ -207,6 +208,10 @@
f.write(page.text.encode(self.opt.encode))
self.counter['save'] += 1
+ if self.opt.preloading is False:
+ pywikibot.stdout(self.output_list[-1]
+ if self.opt.put else self.output_list.pop())
+
def setup(self) -> None:
"""Initialize `output_list` and `num` and adjust base directory."""
self.output_list = []
@@ -240,7 +245,9 @@
if self.opt.put:
self.current_page = self.opt.put
self.put_current(text, summary=self.opt.summary, show_diff=False)
- pywikibot.stdout(text)
+
+ if self.opt.preloading is True:
+ pywikibot.stdout(text)
def main(*args: str) -> None:
@@ -297,6 +304,7 @@
.format(page_target))
gen = gen_factory.getCombinedGenerator()
+ options['preloading'] = gen_factory.is_preloading
if not suggest_help(missing_generator=not gen,
unknown_parameters=unknown_args,
additional_text=additional_text):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/791780
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: I66399022f0e76ec7d74883ecf15ff5e8bd841bad
Gerrit-Change-Number: 791780
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-MessageType: merged