Meno25 has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081507?usp=email )
Change subject: [doc] Fix typo
......................................................................
[doc] Fix typo
* plattforms --> platforms
Change-Id: I0e38f7c9e53857b461a74cba46f8394e62816f66
---
M pywikibot/config.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Meno25: Verified; Looks good to me, approved
diff --git a/pywikibot/config.py b/pywikibot/config.py
index e886663..b5c9032 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -571,7 +571,7 @@
# editor will be used. If set to False, no editor will be used. In
# script tests to be a noop (like /bin/true) so the script continues.
# If set to None, the EDITOR environment variable will be used as
-# command. If EDITOR is not set, on windows plattforms it tries to
+# command. If EDITOR is not set, on Windows platforms it tries to
# determine the default text editor from registry. Finally, Tkinter is
# used as fallback.
editor: bool | str | None = None
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081507?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0e38f7c9e53857b461a74cba46f8394e62816f66
Gerrit-Change-Number: 1081507
Gerrit-PatchSet: 2
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Xqt <info(a)gno.de>
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081499?usp=email )
Change subject: [doc] Fix typo
......................................................................
[doc] Fix typo
Change-Id: Icae902f5f275f7c4aab48307fa92ff11a8b2f484
---
M scripts/cosmetic_changes.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Meno25: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 2964c61..a916aef 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -17,7 +17,7 @@
-ignore: Ignores if an error occurred and either skips the page or
only that method. It can be set to:
- all - dos not ignore errors
+ all - does not ignore errors
match - ignores ISBN related errors (default)
method - ignores fixing method errors
page - ignores page related errors
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081499?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Icae902f5f275f7c4aab48307fa92ff11a8b2f484
Gerrit-Change-Number: 1081499
Gerrit-PatchSet: 2
Gerrit-Owner: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: Meno25 <meno25mail(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Xqt <info(a)gno.de>
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081496?usp=email )
Change subject: [doc] user options list with add_text script
......................................................................
[doc] user options list with add_text script
Change-Id: Iddffefc4ba9b9510a4ff040037e293ce7b2f7220
---
M docs/conf.py
M scripts/add_text.py
2 files changed, 41 insertions(+), 27 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 89c4abf..5d151ce 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -44,6 +44,7 @@
os.environ['PYWIKIBOT_NO_USER_CONFIG'] = '1'
import pywikibot # noqa: E402
+from pywikibot.backports import removeprefix # noqa: E402
# -- General configuration ------------------------------------------------
@@ -532,6 +533,9 @@
"""Pywikibot specific conversions."""
from scripts.cosmetic_changes import warning
+ # these scripts are skipped for fixing options lists
+ skipscripts = {'add_text'}
+
if what != 'module':
return
@@ -539,6 +543,7 @@
return
length = 0
+ shortname = removeprefix(name, 'scripts.')
for index, line in enumerate(lines):
# highlight the first line
if index == 0: # highlight the first line
@@ -559,8 +564,10 @@
lines[index] = warning
# Initiate code block except pagegenerator arguments follows
- elif (line.endswith(':') and not line.lstrip().startswith(':')
- and 'Traceback (most recent call last)' not in line):
+ elif (shortname not in skipscripts
+ and line.endswith(':')
+ and not line.lstrip().startswith(':')
+ and 'Traceback (most recent call last)' not in line):
for afterline in lines[index + 1:]:
if not afterline:
continue
@@ -569,7 +576,7 @@
break
# adjust options
- if line.startswith('-'):
+ if shortname not in skipscripts and line.startswith('-'):
# Indent options
match = re.match(r'-[^ ]+? +', line)
if match:
diff --git a/scripts/add_text.py b/scripts/add_text.py
index 277511a..c5d66f9 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -1,35 +1,36 @@
#!/usr/bin/env python3
-r"""
-Append text to the top or bottom of a page.
+r"""Append text to the top or bottom of a page.
-By default this adds the text to the bottom above the categories and interwiki.
+By default this adds the text to the bottom above the categories and
+interwiki.
Use the following command line parameters to specify what to add:
--text Text to append. "\n" are interpreted as newlines.
+-text Text to append. "\n" are interpreted as newlines.
--textfile Path to a file with text to append
+-textfile Path to a file with text to append
--summary Change summary to use
+-summary Change summary to use
--up Append text to the top of the page rather than the bottom
+-up Append text to the top of the page rather than the bottom
--create Create the page if necessary. Note that talk pages are
- created already without of this option.
+-create Create the page if necessary. Note that talk pages are
+ created already without of this option.
--createonly Only create the page but do not edit existing ones
+-createonly Only create the page but do not edit existing ones
--always If used, the bot won't ask if it should add the specified
- text
+-always If used, the bot won't ask if it should add the specified
+ text
--major If used, the edit will be saved without the "minor edit" flag
+-major If used, the edit will be saved without the "minor edit"
+ flag
--talkpage Put the text onto the talk page instead
--talk
+-talk, -talkpage
+ Put the text onto the talk page instead
--excepturl Skip pages with a url that matches this regular expression
+-excepturl Skip pages with a url that matches this regular expression
--noreorder Place the text beneath the categories and interwiki
+-noreorder Place the text beneath the categories and interwiki
Furthermore, the following can be used to specify which pages to process...
@@ -40,20 +41,26 @@
Append 'hello world' to the bottom of the sandbox:
- python pwb.py add_text -page:Wikipedia:Sandbox \
- -summary:"Bot: pywikibot practice" -text:"hello world"
+.. code-block:: batch
+
+ python pwb.py add_text -page:Wikipedia:Sandbox
+ -summary:"Bot: pywikibot practice" -text:"hello world"
Add a template to the top of the pages with 'category:catname':
- python pwb.py add_text -cat:catname -summary:"Bot: Adding a template" \
- -text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up
+.. code-block:: batch
+
+ python pwb.py add_text -cat:catname -summary:"Bot: Adding a template"
+ -text:"{{Something}}" -except:"\{\{([Tt]emplate:|)[Ss]omething" -up
Command used on it.wikipedia to put the template in the page without any
category:
- python pwb.py add_text -except:"\{\{([Tt]emplate:|)[Cc]ategorizzare" \
- -text:"{{Categorizzare}}" -excepturl:"class='catlinks'>" -uncat \
- -summary:"Bot: Aggiungo template Categorizzare"
+.. code-block:: batch
+
+ python pwb.py add_text -except:"\{\{([Tt]emplate:|)[Cc]ategorizzare"
+ -text:"{{Categorizzare}}" -excepturl:"class='catlinks'>" -uncat
+ -summary:"Bot: Aggiungo template Categorizzare"
"""
#
# (C) Pywikibot team, 2007-2024
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081496?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iddffefc4ba9b9510a4ff040037e293ce7b2f7220
Gerrit-Change-Number: 1081496
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <dalangi-ctr(a)wikimedia.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081490?usp=email )
Change subject: [doc] use options list with login script
......................................................................
[doc] use options list with login script
Change-Id: Iec9f5942fa022ef88bd30cbcd17b85aa5c99d178
---
M pywikibot/scripts/login.py
1 file changed, 21 insertions(+), 24 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/scripts/login.py b/pywikibot/scripts/login.py
index 83be030..ce3f29f 100755
--- a/pywikibot/scripts/login.py
+++ b/pywikibot/scripts/login.py
@@ -1,44 +1,41 @@
#!/usr/bin/env python3
-"""
-Script to log the bot in to a wiki account.
+"""Script to log the bot in to a wiki account.
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.
+-all Try to log in on all sites where a username is defined in
+ user config file (user-config.py).
- -site:FF:LL Log in to the LL language of the FF family
+-logout Log out of the current site. Combine with ``-all`` to log
+ out of all sites, or with :ref:`global options` ``-family``,
+ ``-lang`` or ``-site`` to log out of a specific site.
- -all Try to log in on all sites where a username is defined in
- user config file (user-config.py).
+-oauth Generate OAuth authentication information.
- -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.
+ .. note:: Need to copy OAuth tokens to your user config
+ file manually. -logout is not compatible with -oauth.
- -oauth Generate OAuth authentication information.
+-autocreate Auto-create an account using unified login when necessary.
- .. note:: Need to copy OAuth tokens to your user config
- file manually. -logout is not compatible with -oauth.
+ .. note:: the global account must exist already before
+ using this.
- -autocreate Auto-create an account using unified login when necessary.
+-async Run the bot in parallel tasks, only usefull together with
+ ``-all`` option
- .. note:: the global account must exist already before
- using this.
-
- -async Run the bot in parallel tasks
+.. hint:: Use :ref:`global options` ``-code``, ``-family`` or ``-site``
+ to determine the site to login/logout.
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
-this combination, and store the resulting cookies (containing your password
-hash, so keep it secured!) in a file in the data subdirectory.
+this combination, and store the resulting cookies (containing your
+password hash, so keep it secured!) in a file in the data subdirectory.
-All scripts in this library will be looking for this cookie file and will
-use the login information if it is present.
+All scripts in this library will be looking for this cookie file and
+will use the login information if it is present.
To log out, throw away the ``*.lwp`` file that is created in the data
subdirectory.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081490?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iec9f5942fa022ef88bd30cbcd17b85aa5c99d178
Gerrit-Change-Number: 1081490
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081475?usp=email )
Change subject: [fix] no longer raise UnsupportedPageError within PageGenerator.result()
......................................................................
[fix] no longer raise UnsupportedPageError within PageGenerator.result()
Bug: T377651
Change-Id: I6f55ca09c55f3c3fd0368a59be2bf0d5164aa9fb
---
M pywikibot/data/api/_generators.py
M tests/page_tests.py
2 files changed, 14 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py
index 69ca560..6f1206d 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -727,6 +727,10 @@
This can be overridden in subclasses to return a different type
of object.
+ .. versionchanged:: 9.4
+ no longer raise :exc:`exceptions.UnsupportedPageError` but
+ return a generic :class:`pywikibot.Page` obect. The exception
+ is raised when getting the content for example.
"""
p = pywikibot.Page(self.site, pagedata['title'], pagedata['ns'])
ns = pagedata['ns']
@@ -738,7 +742,10 @@
p = pywikibot.FilePage(p)
elif ns == Namespace.CATEGORY:
p = pywikibot.Category(p)
- update_page(p, pagedata, self.props)
+
+ with suppress(UnsupportedPageError):
+ update_page(p, pagedata, self.props)
+
return p
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 0651e34..716bb8c 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -853,6 +853,12 @@
self.assertFalse(page.botMayEdit())
del page
+ def test_real_page(self):
+ """Test botMayEdit for real example due to T377651."""
+ site = pywikibot.Site('wikipedia:en')
+ page = pywikibot.Page(site, 'Talk:Alan Turing')
+ self.assertTrue(page.botMayEdit())
+
class TestPageHistory(DefaultSiteTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081475?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6f55ca09c55f3c3fd0368a59be2bf0d5164aa9fb
Gerrit-Change-Number: 1081475
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081477?usp=email )
Change subject: [doc] fix docstring in /data/superset.py
......................................................................
[doc] fix docstring in /data/superset.py
Change-Id: Ia5b5a2c30f928889c68e7958e43ab8899053b53e
---
M pywikibot/data/superset.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/superset.py b/pywikibot/data/superset.py
index aabcfa2..6e223df 100644
--- a/pywikibot/data/superset.py
+++ b/pywikibot/data/superset.py
@@ -114,7 +114,7 @@
instance is not connected, it attempts to log in first.
:raises ServerError: For any http errors
- :return CSRF token string
+ :return: CSRF token string
"""
if not self.connected:
self.login()
@@ -172,7 +172,7 @@
:raises TypeError: if site and schema_name are both defined'
:raises TypeError: If determined database_id is not an integer.
:raises TypeError: If neither site nor schema_name is determined.
- :return A tuple containing database_id and schema_name.
+ :return: A tuple containing database_id and schema_name.
"""
if site and schema_name:
msg = 'Only one of schema_name and site parameters can be defined'
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081477?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ia5b5a2c30f928889c68e7958e43ab8899053b53e
Gerrit-Change-Number: 1081477
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot