jenkins-bot has submitted this change and it was merged.
Change subject: i18n for lonelypages.py, synchronized with core
......................................................................
i18n for lonelypages.py, synchronized with core
- i18n from twn
- raise exception, when templatea aren't localized
- fix for isRedirectPage exception
- continue outer loop if inner loop was completed i.e. nothing found
- indentation for always hotkey
Change-Id: Ie55c3c3830ce1fada6cbd2c6293d0e6a66368c49
---
M lonelypages.py
1 file changed, 39 insertions(+), 81 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lonelypages.py b/lonelypages.py
index 8a8d71c..538a8d5 100644
--- a/lonelypages.py
+++ b/lonelypages.py
@@ -1,8 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
-This is a script written to add the template "orphan" to the pages that aren't linked by other pages.
-It can give some strange Errors sometime, I hope that all of them are fixed in this version.
+This is a script written to add the template "orphan" to the pages that aren't
+linked by other pages. It can give some strange Errors sometime, I hope that
+all of them are fixed in this version.
These command line parameters can be used to specify which pages to work on:
@@ -18,21 +19,15 @@
Furthermore, the following command line parameters are supported:
--enable: - Enable or disable the bot via a Wiki Page.
+-enable: Enable or disable the bot via a Wiki Page.
--disambig: - Set a page where the bot save the name of the disambig pages found (default: skip the pages)
+-disambig: Set a page where the bot save the name of the disambig
+ pages found (default: skip the pages)
--limit: - Set how many pages check.
+-limit: Set how many pages check.
--always - Always say yes, won't ask
+-always Always say yes, won't ask
---- FixMes ---
-* Check that all the code hasn't bugs
-
---- Credit and Help ---
-This Script has been developed by Pietrodn and Filnik on botwiki. If you want to help us
-improving our script archive and pywikibot's archive or you simply need help
-you can find us here: http://botwiki.sno.cc
--- Examples ---
python lonelypages.py -enable:User:Bot/CheckBot -always
@@ -47,9 +42,11 @@
__version__ = '$Id$'
#
-import pywikibot
-import pagegenerators
import re
+
+import pywikibot
+from pywikibot import i18n
+import pagegenerators
# This is required for the text that is shown when you run this script
# with the parameter -help.
@@ -57,13 +54,6 @@
'¶ms;': pagegenerators.parameterHelp,
}
-#####################################################
-# Here you have to put the config for your Project. #
-#####################################################
-
-# ************* Modify only below! ************* #
-
-# Template to add in the orphan pages
Template = {
'ar': u'{{يتيمة|تاريخ={{نسخ:اسم_شهر}} {{نسخ:عام}}}}',
'ca': u'{{Orfe|date={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}}}',
@@ -73,30 +63,8 @@
'zh': u'{{subst:Orphan/auto}}',
}
-# Comment that the Bot will use to put the template
-commento = {
- 'ar': u'بوت: صفحة يتيمة، إضافة قالب',
- 'ca': u'Bot:Pàgina orfe, afegint plantilla',
- 'en': u'Robot: Orphan page, add template',
- 'it': u'[[Project:Bot|Bot]]: Voce orfana, aggiungo template {{O}}',
- 'ja': u'ロボットによる: 孤立したページへのテンプレート貼付け',
- 'zh': u'機器人: 本頁的鏈入頁面太少',
-}
-
-# When you add a disambig to the list of disambig pages
-#(if you set disambigPage to None, you can put here nothing)
-commenttodisambig = {
- 'ar': u'بوت: إضافة صفحة توضيح',
- 'ca': u'Bot; Afegint una desambiguació',
- 'en': u'Robot: Adding a disambig page',
- 'it': u'[[Project:Bot|Bot]]: Aggiungo una disambigua',
- 'ja': u'ロボットによる: 曖昧さ回避の追加',
- 'zh': u'機器人: 增加消歧義頁面',
-}
-
# Use regex to prevent to put the same template twice!
-# Warning: put always "()" inside the regex, so the bot will find "something"
-exception = {
+exception_regex = {
'ar': [ur'\{\{(?:قالب:|)(يتيمة)[\|\}]'],
'ca': [r'\{\{(?:template:|)(orfe)[\|\}]'],
'en': [r'\{\{(?:template:|)(orphan)[\|\}]',
@@ -106,24 +74,12 @@
'zh': [r'\{\{(?:template:|)(orphan)[\|\}]'],
}
-# ************* Modify only above! ************* #
-
def main():
- # Load the configurations in the function namespace
- global commento
- global Template
- global disambigPage
- global commenttodisambig
- global exception
-
enablePage = None # Check if someone set an enablePage or not
- # All the pages! (I hope that there aren't so many lonely pages in a
- # project..)
- limit = 50000
- # Check if the bot should use the default generator or not
- generator = None
- # Load all the default generators!
+ limit = 50000 # Hope that there aren't so many lonely pages in a project
+ generator = None # Check if bot should use default generator or not
+ # Load all default generators!
genFactory = pagegenerators.GeneratorFactory()
nwpages = False # Check variable for newpages
always = False # Check variable for always
@@ -169,12 +125,14 @@
if not generator:
generator = wikiSite.lonelypages(repeat=True, number=limit)
# Take the configurations according to our project
- comment = pywikibot.translate(wikiSite, commento)
- commentdisambig = pywikibot.translate(wikiSite, commenttodisambig)
- template = pywikibot.translate(wikiSite, Template)
- exception = pywikibot.translate(wikiSite, exception)
+ comment = i18n.twtranslate(wikiSite, 'lonelypages-comment-add-template')
+ commentdisambig = i18n.twtranslate(wikiSite, 'lonelypages-comment-add-disambig-template')
+ template = i18n.translate(wikiSite, Template)
+ exception = i18n.translate(wikiSite, exception_regex)
+ if template is None or exception is None:
+ raise Exception("Missing configuration for site %r" % wikiSite)
# EnablePage part
- if enablePage:
+ if enablePage is not None:
# Define the Page Object
enable = pywikibot.Page(wikiSite, enablePage)
# Loading the page's data
@@ -185,7 +143,7 @@
u"%s doesn't esist, I use the page as if it was blank!"
% enable.title())
getenable = ''
- except pywikibot.IsRedirect:
+ except pywikibot.IsRedirectPage:
pywikibot.output(u"%s is a redirect, skip!" % enable.title())
getenable = ''
# If the enable page is set to disable, turn off the bot
@@ -201,14 +159,14 @@
except pywikibot.NoPage:
pywikibot.output(u"%s doesn't esist, skip!" % disambigpage.title())
disambigtext = ''
- except pywikibot.IsRedirect:
+ except pywikibot.IsRedirectPage:
pywikibot.output(u"%s is a redirect, don't use it!"
% disambigpage.title())
disambigPage = None
# Main Loop
for page in generator:
if nwpages:
- # newpages generator returns a tuple, not a Page object.
+ # The newpages generator returns a tuple, not a Page object.
page = page[0]
pywikibot.output(u"Checking %s..." % page.title())
if page.isRedirectPage(): # If redirect, skip!
@@ -233,8 +191,7 @@
pywikibot.error(u'2 --> Skip page')
continue
else:
- # Ok, no refs, no redirect...
- # let's check if there's already the template
+ # no refs, no redirect; check if there's already the template
try:
oldtxt = page.get()
except pywikibot.NoPage:
@@ -243,9 +200,9 @@
except pywikibot.IsRedirectPage:
pywikibot.output(u"%s is a redirect! Skip..." % page.title())
continue
- # I've used a loop in a loop. If I use continue in the second loop, it won't do anything
- # in the first. So let's create a variable to avoid this problem.
- Find = False
+ # I've used a loop in a loop. If I use continue in the second loop,
+ # it won't do anything in the first. So let's create a variable to
+ # avoid this problem.
for regexp in exception:
res = re.findall(regexp, oldtxt.lower())
# Found a template! Let's skip the page!
@@ -253,11 +210,10 @@
pywikibot.output(
u'Your regex has found something in %s, skipping...'
% page.title())
- Find = True
break
- if Find:
- continue # Skip the page..
- if page.isDisambig() and disambigPage:
+ else:
+ continue
+ if page.isDisambig() and disambigPage is not None:
pywikibot.output(u'%s is a disambig page, report..'
% page.title())
if not page.title().lower() in disambigtext.lower():
@@ -277,10 +233,12 @@
pywikibot.showDiff(oldtxt, newtxt)
choice = 'y'
if not always:
- choice = pywikibot.inputChoice(u'Orphan page found, shall I add the template?', ['Yes', 'No', 'All'], ['y', 'n', 'a'])
- if choice == 'a':
- always = True
- choice = 'y'
+ choice = pywikibot.inputChoice(
+ u'Orphan page found, add template?',
+ ['Yes', 'No', 'All'], 'yna')
+ if choice == 'a':
+ always = True
+ choice = 'y'
if choice == 'y':
try:
page.put(newtxt, comment)
--
To view, visit https://gerrit.wikimedia.org/r/134302
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie55c3c3830ce1fada6cbd2c6293d0e6a66368c49
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Alex S.H. Lin <alexsh(a)mail2000.com.tw>
Gerrit-Reviewer: DrTrigon <dr.trigon(a)surfeu.ch>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fixing D203 error
......................................................................
Fixing D203 error
in PEP257
Change-Id: I0460374f31f205d141946e5d9f6931189024e06e
---
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/botirc.py
M pywikibot/exceptions.py
M pywikibot/i18n.py
M pywikibot/interwiki_graph.py
M pywikibot/logentries.py
M pywikibot/page.py
M pywikibot/pagegenerators.py
M pywikibot/site.py
M pywikibot/textlib.py
M pywikibot/throttle.py
M pywikibot/tools.py
M pywikibot/version.py
M pywikibot/xmlreader.py
M setup.py
16 files changed, 66 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Ricordisamoa: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 390432b..1a4101c 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -35,6 +35,7 @@
class Timestamp(datetime.datetime):
+
"""Class for handling Mediawiki timestamps.
This inherits from datetime.datetime, so it can use all of the methods
@@ -94,6 +95,7 @@
class Coordinate(object):
+
"""
Class for handling and storing Coordinates.
For now its just being used for DataSite, but
@@ -209,6 +211,7 @@
class WbTime(object):
+
""" A Wikibase time representation"""
PRECISION = {'1000000000': 0, '100000000': 1, '10000000': 2, '1000000': 3, '100000': 4, '10000': 5, 'millenia': 6, 'century': 7, 'decade': 8, 'year': 9, 'month': 10, 'day': 11, 'hour': 12, 'minute': 13, 'second': 14}
@@ -314,6 +317,7 @@
class WbQuantity(object):
+
""" A Wikibase quantity representation"""
def __init__(self, amount, unit=None, error=None):
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index a41183a..78e291a 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -107,6 +107,7 @@
class LoggingFormatter(logging.Formatter):
+
"""Format LogRecords for output to file.
This formatter *ignores* the 'newline' key of the LogRecord, because
@@ -751,6 +752,7 @@
class Bot(object):
+
"""
Generic Bot to be subclassed
"""
@@ -834,6 +836,7 @@
class WikidataBot:
+
"""
Generic Wikidata Bot to be subclassed
used in claimit.py, coordinate_import.py and harvest_template.py
diff --git a/pywikibot/botirc.py b/pywikibot/botirc.py
index 9a7073c..b58325a 100644
--- a/pywikibot/botirc.py
+++ b/pywikibot/botirc.py
@@ -38,6 +38,7 @@
class IRCBot(pywikibot.Bot, SingleServerIRCBot):
+
"""
Generic IRC Bot to be subclassed
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 17296a2..fa0469e 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -17,6 +17,7 @@
class Error(UnicodeMixin, Exception):
+
"""Wikipedia error"""
# NOTE: UnicodeMixin must be the first object Error class is derived from.
def __init__(self, arg):
@@ -27,6 +28,7 @@
class PageRelatedError(Error):
+
"""Abstract Exception, used when the Exception concerns a particular
Page, and when a generic message can be written once for all"""
# Preformated UNICODE message where the page title will be inserted
@@ -49,29 +51,35 @@
class NoUsername(Error):
+
"""Username is not in user-config.py"""
class NoPage(PageRelatedError):
+
"""Page does not exist"""
message = u"Page %s doesn't exist."
class NoSuchSite(Error):
+
"""Site does not exist"""
class IsRedirectPage(PageRelatedError):
+
"""Page is a redirect page"""
message = u"Page %s is a redirect page."
class IsNotRedirectPage(PageRelatedError):
+
"""Page is not a redirect page"""
message = u"Page %s is not a redirect page."
class CircularRedirect(Error):
+
"""Page is a circular redirect
Exception argument is the redirect target; this may be the same title
@@ -82,27 +90,33 @@
class InvalidTitle(Error):
+
"""Invalid page title"""
class LockedPage(PageRelatedError):
+
"""Page is locked"""
message = u"Page %s is locked."
class SectionError(Error):
+
"""The section specified by # does not exist"""
class PageNotSaved(Error):
+
"""Saving the page has failed"""
class EditConflict(PageNotSaved):
+
"""There has been an edit conflict while uploading the page"""
class SpamfilterError(PageNotSaved):
+
"""Saving the page has failed because the MediaWiki spam filter detected a
blacklisted URL.
"""
@@ -114,19 +128,23 @@
class ServerError(Error):
+
"""Got unexpected server response"""
class FatalServerError(ServerError):
+
"""A fatal server error that's not going to be corrected by just sending
the request again."""
class Server504Error(Error):
+
"""Server timed out with http 504 code"""
class BadTitle(Error):
+
"""Server responded with BadTitle."""
# UserBlocked exceptions should in general not be caught. If the bot has
@@ -135,22 +153,27 @@
class UserBlocked(Error):
+
"""Your username or IP has been blocked"""
class PageNotFound(Error):
+
"""Page not found in list"""
class CaptchaError(Error):
+
"""Captcha is asked and config.solve_captcha == False."""
class UploadWarning(Error):
+
"""Upload failed with a warning message (passed as the argument)."""
class AutoblockUser(Error):
+
"""
The class AutoblockUserError is an exception that is raised whenever
an action is requested on a virtual autoblock user that's not available
@@ -167,4 +190,5 @@
class CoordinateGlobeUnknownException(WikiBaseError, NotImplementedError):
+
""" This globe is not implemented yet in either WikiBase or pywikibot """
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index c204121..fea4130 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -221,6 +221,7 @@
class TranslationError(Error):
+
""" Raised when no correct translation could be found """
pass
diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py
index 7e27d01..3fec68b 100644
--- a/pywikibot/interwiki_graph.py
+++ b/pywikibot/interwiki_graph.py
@@ -19,10 +19,12 @@
class GraphImpossible(Exception):
+
"Drawing a graph is not possible on your system."
class GraphSavingThread(threading.Thread):
+
"""
Rendering a graph can take extremely long. We use
multithreading because of that.
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index fcdf029..be6d08b 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -17,6 +17,7 @@
class LogDict(dict):
+
"""
Simple custom dictionary that raises a custom KeyError and logs
debugging information when a key is missing
@@ -28,6 +29,7 @@
class LogEntry(object):
+
"""Generic log entry"""
# Log type expected. None for every type, or one of the (letype) str :
@@ -205,6 +207,7 @@
class LogEntryFactory(object):
+
"""
LogEntry Factory
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1f1877b..b19c09a 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -43,6 +43,7 @@
# Page objects (defined here) represent the page itself, including its contents.
class Page(pywikibot.UnicodeMixin, ComparableMixin):
+
"""Page: A MediaWiki page
This object only implements internally methods that do not require
@@ -1641,6 +1642,7 @@
class ImagePage(Page):
+
"""A subclass of Page representing an image descriptor wiki page.
Supports the same interface as Page, with the following added methods:
@@ -1756,6 +1758,7 @@
class Category(Page):
+
"""A page in the Category: namespace"""
@deprecate_arg("insite", None)
@@ -2091,6 +2094,7 @@
class User(Page):
+
"""A class that represents a Wiki user.
"""
@@ -2391,6 +2395,7 @@
class WikibasePage(Page):
+
"""
The base page for the Wikibase extension.
There really should be no need to call this directly
@@ -2809,6 +2814,7 @@
class PropertyPage(WikibasePage, Property):
+
"""
Any page in the property namespace
Should be created as:
@@ -2842,6 +2848,7 @@
class QueryPage(WikibasePage):
+
"""
For future usage, not implemented yet
"""
@@ -2853,6 +2860,7 @@
class Claim(Property):
+
"""
Claims are standard claims as well as references.
"""
@@ -3091,6 +3099,7 @@
class Revision(object):
+
"""A structure holding information about a single revision of a Page."""
def __init__(self, revid, timestamp, user, anon=False, comment=u"",
text=None, minor=False):
@@ -3123,6 +3132,7 @@
class Link(ComparableMixin):
+
"""A MediaWiki link (local or interwiki)
Has the following attributes:
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 9a2c6f5..98e292b 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -194,6 +194,7 @@
class GeneratorFactory(object):
+
"""Process command line arguments and return appropriate page generator.
This factory is responsible for processing command line arguments
that are used by many scripts and that determine which pages to work on.
@@ -1221,6 +1222,7 @@
class YahooSearchPageGenerator:
+
""" To use this generator, install pYsearch """
# values larger than 100 fail
@@ -1253,6 +1255,7 @@
class GoogleSearchPageGenerator:
+
"""
To use this generator, you must install the pyGoogle module from
http://pygoogle.sf.net/ and get a Google Web API license key from
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 578febf..b614f1b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -38,10 +38,12 @@
class PageInUse(pywikibot.Error):
+
"""Page cannot be reserved for writing due to existing lock."""
class LoginStatus(object):
+
""" Enum for Login statuses.
>>> LoginStatus.NOT_ATTEMPTED
@@ -96,6 +98,7 @@
class BaseSite(object):
+
"""Site methods that are independent of the communication interface."""
# to implement a specific interface, define a Site class that inherits
# from this
@@ -575,6 +578,7 @@
class APISite(BaseSite):
+
"""API interface to MediaWiki site.
Do not use directly; use pywikibot.Site function.
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index df37f95..182359e 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1134,6 +1134,7 @@
# ---------------------------------------
class tzoneFixedOffset(datetime.tzinfo):
+
"""
Class building tzinfo objects for fixed-offset time zones
@@ -1162,6 +1163,7 @@
class TimeStripper(object):
+
"""
Find timestamp in page text and returns it as timezone aware datetime object
"""
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 1d8da7a..7957fee 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -28,6 +28,7 @@
class Throttle(object):
+
"""Control rate of access to wiki server
Calling this object blocks the calling thread until at least 'delay'
diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index 31ca0ef..6f0c26c 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -18,6 +18,7 @@
class UnicodeMixin(object):
+
"""Mixin class to handle defining the proper __str__/__unicode__
methods in Python 2 or 3.
"""
@@ -60,6 +61,7 @@
class ThreadedGenerator(threading.Thread):
+
"""Look-ahead generator class.
Runs a generator in a separate thread and queues the results; can
@@ -171,6 +173,7 @@
class ThreadList(list):
+
"""A simple threadpool class to limit the number of simultaneous threads.
Any threading.Thread object can be added to the pool using the append()
diff --git a/pywikibot/version.py b/pywikibot/version.py
index ab455f3..608d7e1 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -20,6 +20,7 @@
class ParseError(Exception):
+
""" Parsing went wrong """
diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index 55191ad..1ad4e2e 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -44,6 +44,7 @@
class XmlEntry:
+
"""
Represents a page.
"""
@@ -66,6 +67,7 @@
class XmlParserThread(threading.Thread):
+
"""
This XML parser will run as a single thread. This allows the XmlDump
generator to yield pages before the parser has finished reading the
@@ -83,6 +85,7 @@
class XmlDump(object):
+
"""
Represents an XML dump file. Reads the local file at initialization,
parses it, and offers access to the resulting XmlEntries via a generator.
diff --git a/setup.py b/setup.py
index 357a1fe..069dc46 100644
--- a/setup.py
+++ b/setup.py
@@ -46,6 +46,7 @@
class pwb_install(install.install):
+
"""
Setuptools' install command subclassed to automatically call
`generate_user_files.py` after installing the package.
--
To view, visit https://gerrit.wikimedia.org/r/139580
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0460374f31f205d141946e5d9f6931189024e06e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: (bug 66466) Exception getting edit token for Claim
......................................................................
(bug 66466) Exception getting edit token for Claim
Site.editSource and other Claim modification methods fetched an edit token
using the claim itself as 'page', which was previously the Property:Pxx page.
Due to Id63969c045ac63a5b0276f696ce5797c4ee8b6df, Claim objects are no longer
a Page, and these methods need to select a page for which to fetch the token.
Standard practise is to use 'Main Page' to fetch an edit token, which is
what this changeset does.
Change-Id: Ic7f8308438c910e5b4ce798a36a1e6e5d77c4a96
---
M pywikibot/site.py
1 file changed, 8 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Verified; Looks good to me, approved
JAn Dudík: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 578febf..e3ad6cc 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -3752,7 +3752,8 @@
params['value'] = json.dumps(claim._formatDataValue())
if 'summary' in kwargs:
params['summary'] = kwargs['summary']
- params['token'] = self.token(item, 'edit')
+ params['token'] = self.token(pywikibot.Page(self, u'Main Page'),
+ 'edit')
req = api.Request(site=self, **params)
data = req.submit()
claim.snak = data['claim']['id']
@@ -3782,7 +3783,8 @@
params['bot'] = 1
if 'summary' in kwargs:
params['summary'] = kwargs['summary']
- params['token'] = self.token(claim, 'edit')
+ params['token'] = self.token(pywikibot.Page(self, u'Main Page'),
+ 'edit')
if snaktype == 'value':
params['value'] = json.dumps(claim._formatDataValue())
@@ -3811,7 +3813,8 @@
params['baserevid'] = claim.on_item.lastrevid
if bot:
params['bot'] = 1
- params['token'] = self.token(claim, 'edit')
+ params['token'] = self.token(pywikibot.Page(self, u'Main Page'),
+ 'edit')
# build up the snak
if isinstance(source, list):
sources = source
@@ -3881,7 +3884,8 @@
hasattr(qualifier, 'hash') and
qualifier.hash is not None):
params['snakhash'] = qualifier.hash
- params['token'] = self.token(claim, 'edit')
+ params['token'] = self.token(pywikibot.Page(self, u'Main Page'),
+ 'edit')
# build up the snak
if qualifier.getSnakType() == 'value':
params['value'] = json.dumps(qualifier._formatDataValue())
--
To view, visit https://gerrit.wikimedia.org/r/139366
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7f8308438c910e5b4ce798a36a1e6e5d77c4a96
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: JAn Dudík <jan.dudik(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>