jenkins-bot submitted this change.

View Change

Approvals: D3r1ck01: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
[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(-)

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 change 799904. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5fc9cd0263e155fc923e71aa0f91863ecffedb90
Gerrit-Change-Number: 799904
Gerrit-PatchSet: 3
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