jenkins-bot has submitted this change and it was merged.
Change subject: Fix backwards compatibility of APISite.hasExtension()
......................................................................
Fix backwards compatibility of APISite.hasExtension()
Previously that method used "name" and "unknown", but "unknown" was
removed in d42d519adf59b92998ba7b87008c58b7193a7014 so tests broke
which used it as a positional parameter.
This adds a method has_extension which only accepts one parameter
while the old hasExtension supports both (but ignores the second
completely).
This also fixes the site tests which may relied on it so various
tests aren't applicable anymore. There is only one test which makes
sense but is deactived, because it won't work unless it is possible
to make "need_version" believe that the current version doesn't
support it.
Change-Id: I22a17b0f9eca208daaa3b3eeeab1b86b5c34b399
---
M pywikibot/data/api.py
M pywikibot/page.py
M pywikibot/site.py
M tests/site_tests.py
4 files changed, 27 insertions(+), 18 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index b02c263..643369c 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -158,7 +158,7 @@
# This situation is only tripped when one of the first actions
# on the site is a write action and the extension isn't installed.
if 'extensions' in self.site.siteinfo:
- use_assert_edit_extension = self.site.hasExtension('AssertEdit', False)
+ use_assert_edit_extension = self.site.has_extension('AssertEdit')
else:
use_assert_edit_extension = True
diff --git a/pywikibot/page.py b/pywikibot/page.py
index fb5bffe..22adbcf 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -678,7 +678,7 @@
@return: bool
"""
- if self.site.hasExtension('Disambiguator', False):
+ if self.site.has_extension('Disambiguator'):
# If the Disambiguator extension is loaded, use it
return 'disambiguation' in self.properties()
@@ -1747,7 +1747,7 @@
@return: bool
"""
- if not self.site.hasExtension('Flow', False):
+ if not self.site.has_extension('Flow'):
return False
if not hasattr(self, '_flowinfo'):
self.site.loadflowinfo(self)
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 59a5ac4..5132dfc 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1691,8 +1691,25 @@
self._namespaces[ns].aliases.append(item['*'])
@need_version("1.14")
- @deprecate_arg("unknown", None)
- def hasExtension(self, name):
+ @deprecated("has_extension")
+ def hasExtension(self, name, unknown=None):
+ """ Determine whether extension `name` is loaded.
+
+ Use L{has_extension} instead!
+
+ @param name: The extension to check for, case insenstive
+ @type name: str
+ @param unknown: Old parameter which shouldn't be used anymore.
+ @return: If the extension is loaded
+ @rtype: bool
+ """
+ if unknown is not None:
+ pywikibot.debug(u'unknown argument of hasExtension is deprecated.',
+ _logger)
+ return self.has_extension(name)
+
+ @need_version("1.14")
+ def has_extension(self, name):
""" Determine whether extension `name` is loaded.
@param name: The extension to check for, case insenstive
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 241bcbe..de281f0 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -980,24 +980,16 @@
# test automatically getting extensions cache
if 'extensions' in mysite.siteinfo:
del mysite.siteinfo._cache['extensions']
- self.assertTrue(mysite.hasExtension('Disambiguator'))
+ self.assertTrue(mysite.has_extension('Disambiguator'))
# test case-sensitivity
- self.assertTrue(mysite.hasExtension('disambiguator'))
+ self.assertTrue(mysite.has_extension('disambiguator'))
- self.assertFalse(mysite.hasExtension('ThisExtensionDoesNotExist'))
+ self.assertFalse(mysite.has_extension('ThisExtensionDoesNotExist'))
# test behavior for sites that do not report extensions
- mysite.siteinfo._cache['extensions'] = (None, True)
- self.assertRaises(NotImplementedError, mysite.hasExtension, ('anything'))
-
- class MyException(Exception):
- pass
- self.assertRaises(MyException, mysite.hasExtension, 'anything', MyException)
-
- self.assertTrue(mysite.hasExtension('anything', True))
- self.assertFalse(mysite.hasExtension('anything', False))
- del mysite.siteinfo._cache['extensions']
+ # TODO: Simulate a version to old to support this
+ # self.assertRaises(NotImplementedError, mysite.has_extension, ('anything'))
def test_API_limits_with_site_methods(self):
# test step/total parameters for different sitemethods
--
To view, visit https://gerrit.wikimedia.org/r/155026
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I22a17b0f9eca208daaa3b3eeeab1b86b5c34b399
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: use need_version decorator for hasExtension method
......................................................................
use need_version decorator for hasExtension method
Change-Id: I62d6a832c23d1cece6e16491fe44b613693ada76
---
M pywikibot/site.py
1 file changed, 8 insertions(+), 15 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 5e0d28b..59a5ac4 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1690,24 +1690,17 @@
if item['*'] not in self._namespaces[ns]:
self._namespaces[ns].aliases.append(item['*'])
- def hasExtension(self, name, unknown=NotImplementedError):
+ @need_version("1.14")
+ @deprecate_arg("unknown", None)
+ def hasExtension(self, name):
""" Determine whether extension `name` is loaded.
- @param name: The extension to check for
- @param unknown: The value to return if the site does not list loaded
- extensions. Valid values are an exception to raise,
- True or False. Default: NotImplementedError
-
- @return: bool
+ @param name: The extension to check for, case insenstive
+ @type name: str
+ @return: If the extension is loaded
+ @rtype: bool
"""
- try:
- extensions = self.siteinfo['extensions']
- except KeyError:
- if isinstance(unknown, type) and issubclass(unknown, Exception):
- raise unknown(
- "Feature 'hasExtension' only available in MW 1.14+")
- else:
- return unknown
+ extensions = self.siteinfo['extensions']
for ext in extensions:
if ext['name'].lower() == name.lower():
return True
--
To view, visit https://gerrit.wikimedia.org/r/139092
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I62d6a832c23d1cece6e16491fe44b613693ada76
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Category.py script handles empty and redirect pages
......................................................................
Category.py script handles empty and redirect pages
This patch fixes three problems: First if the to-be-edited page is empty
it was skipped even when "-create" is set, because the actual content
("", an empty string) was never returned. The same problem was there
when the to-be-edited page is a redirect, but that doesn't fix all
problems there.
The second part only affects adding categories to redirect targets.
If the same fix is applied that "-redirect" actually returns the
target contents it still crash because it's unable to save the page.
This is due to the fact that it only checks if the currently edited
page is a redirect when it's loading the content but nowhere else.
The fix there is simply to change the Page instance from the redirect
page to the redirect target page (if "-redirect" is given) and skip it
otherwise.
And lastly when creating a page, it can't of course get the text
afterwards to show the difference. So the third part of that changeset
is using the cached content from the beginning to show the difference.
Bug: 69185
Bug: 69186
Change-Id: I4bfd4db128e8398df43f847cc3cbd8143088686d
---
M scripts/category.py
1 file changed, 23 insertions(+), 14 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/category.py b/scripts/category.py
index 38dddc9..d5f5492 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -294,7 +294,9 @@
pywikibot.output(u"%d page(s) processed." % counter)
def load(self, page):
- """Load the given page, do some changes, and save it."""
+ """Load the given page's content.
+
+ If page doesn't exists returns an empty string."""
try:
# Load the page
text = page.get()
@@ -302,26 +304,20 @@
if self.create:
pywikibot.output(u"Page %s doesn't exist yet; creating."
% (page.title(asLink=True)))
- text = ''
+ return ''
else:
pywikibot.output(u"Page %s does not exist; skipping."
% page.title(asLink=True))
- except pywikibot.IsRedirectPage:
- redirTarget = page.getRedirectTarget()
- if self.follow_redirects:
- text = redirTarget.get()
- else:
- pywikibot.warning(u"Page %s is a redirect to %s; skipping."
- % (page.title(asLink=True),
- redirTarget.title(asLink=True)))
else:
return text
- def save(self, text, page, newcatTitle, minorEdit=True, botflag=True):
+ def save(self, text, page, newcatTitle, minorEdit=True, botflag=True, old_text=None):
+ if old_text is None:
+ old_text = self.load(page)
# only save if something was changed
- if text != page.get():
+ if text != old_text:
# show what was changed
- pywikibot.showDiff(page.get(), text)
+ pywikibot.showDiff(old_text, text)
comment = self.editSummary
if not comment:
comment = i18n.twtranslate(page.site, 'category-adding',
@@ -364,9 +360,22 @@
return False
def treat(self, page):
+ if page.isRedirectPage():
+ # if it's a redirect use the redirect target instead
+ redirTarget = page.getRedirectTarget()
+ if self.follow_redirects:
+ page = redirTarget
+ else:
+ pywikibot.warning(u"Page %s is a redirect to %s; skipping."
+ % (page.title(asLink=True),
+ redirTarget.title(asLink=True)))
+ # loading it will throw an error if we don't jump out before
+ return
text = self.load(page)
if text is None:
return
+ # store old text, so we don't have reload it every time
+ old_text = text
cats = [c for c in page.categories()]
# Show the title of the page we're working on.
# Highlight the title in purple.
@@ -389,7 +398,7 @@
pywikibot.output(u'Adding %s' % catpl.title(asLink=True))
cats.append(catpl)
text = pywikibot.replaceCategoryLinks(text, cats, site=page.site)
- if not self.save(text, page, newcatTitle):
+ if not self.save(text, page, newcatTitle, old_text=old_text):
pywikibot.output(u'Page %s not saved.'
% page.title(asLink=True))
--
To view, visit https://gerrit.wikimedia.org/r/152107
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4bfd4db128e8398df43f847cc3cbd8143088686d
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: flickrripper.py: Protect the import of flickrapi with a try block.
......................................................................
flickrripper.py: Protect the import of flickrapi with a try block.
Bug: 68606
Change-Id: Iba332b3462eb7e188df4ae049db59d946b0aa92e
---
M scripts/flickrripper.py
1 file changed, 29 insertions(+), 21 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/flickrripper.py b/scripts/flickrripper.py
index 7446331..069a0b9 100644
--- a/scripts/flickrripper.py
+++ b/scripts/flickrripper.py
@@ -42,7 +42,15 @@
from pywikibot import config
import upload
-import flickrapi # see: http://stuvel.eu/projects/flickrapi
+try:
+ import flickrapi # see: http://stuvel.eu/projects/flickrapi
+except ImportError:
+ import sys
+ pywikibot.error('This script requires the python flickrapi module')
+ pywikibot.error('See: http://stuvel.eu/projects/flickrapi')
+ pywikibot.exception()
+ sys.exit()
+
from Tkinter import (
Tk, Label, Entry, Scrollbar, Text, Button,
END, VERTICAL, NORMAL, WORD
@@ -72,9 +80,9 @@
while True:
try:
photoInfo = flickr.photos_getInfo(photo_id=photo_id)
- #xml.etree.ElementTree.dump(photoInfo)
+ # xml.etree.ElementTree.dump(photoInfo)
photoSizes = flickr.photos_getSizes(photo_id=photo_id)
- #xml.etree.ElementTree.dump(photoSizes)
+ # xml.etree.ElementTree.dump(photoSizes)
return photoInfo, photoSizes
except flickrapi.exceptions.FlickrError:
pywikibot.output(u'Flickr api problem, sleeping')
@@ -166,7 +174,7 @@
title = cleanUpTitle(title)
if not title:
- #find the max length for a mw title
+ # find the max length for a mw title
maxBytes = 240 - len(project.encode('utf-8')) \
- len(username.encode('utf-8'))
description = photoInfo.find('photo').find('description').text
@@ -260,12 +268,12 @@
pywikibot.output(str(photo_id))
(photoInfo, photoSizes) = getPhoto(flickr, photo_id)
if isAllowedLicense(photoInfo) or override:
- #Get the url of the largest photo
+ # Get the url of the largest photo
photoUrl = getPhotoUrl(photoSizes)
- #Should download the photo only once
+ # Should download the photo only once
photo = downloadPhoto(photoUrl)
- #Don't upload duplicate images, should add override option
+ # Don't upload duplicate images, should add override option
duplicates = findDuplicateImages(photo)
if duplicates:
pywikibot.output(u'Found duplicate image at %s' % duplicates.pop())
@@ -276,7 +284,7 @@
flickrreview, reviewer,
override, addCategory,
removeCategories)
- #pywikibot.output(photoDescription)
+ # pywikibot.output(photoDescription)
if not autonomous:
(newPhotoDescription, newFilename, skip) = Tkdialog(
photoDescription, photo, filename).run()
@@ -284,14 +292,14 @@
newPhotoDescription = photoDescription
newFilename = filename
skip = False
- #pywikibot.output(newPhotoDescription)
- #if (pywikibot.Page(title=u'File:'+ filename, site=pywikibot.Site()).exists()):
+ # pywikibot.output(newPhotoDescription)
+ # if (pywikibot.Page(title=u'File:'+ filename, site=pywikibot.Site()).exists()):
# I should probably check if the hash is the same and if not upload it under a different name
- #pywikibot.output(u'File:' + filename + u' already exists!')
- #else:
- #Do the actual upload
- #Would be nice to check before I upload if the file is already at Commons
- #Not that important for this program, but maybe for derived programs
+ # pywikibot.output(u'File:' + filename + u' already exists!')
+ # else:
+ # Do the actual upload
+ # Would be nice to check before I upload if the file is already at Commons
+ # Not that important for this program, but maybe for derived programs
if not skip:
bot = upload.UploadRobot(photoUrl,
description=newPhotoDescription,
@@ -309,7 +317,7 @@
""" The user dialog. """
def __init__(self, photoDescription, photo, filename):
self.root = Tk()
- #"%dx%d%+d%+d" % (width, height, xoffset, yoffset)
+ # "%dx%d%+d%+d" % (width, height, xoffset, yoffset)
self.root.geometry("%ix%i+10-10" % (config.tkhorsize, config.tkvertsize))
self.root.title(filename)
@@ -319,7 +327,7 @@
self.skip = False
self.exit = False
- ## Init of the widgets
+ # --Init of the widgets
# The image
self.image = self.getImage(self.photo, 800, 600)
self.imagePanel = Label(self.root, image=self.image)
@@ -343,7 +351,7 @@
self.okButton = Button(self.root, text="OK", command=self.okFile)
self.skipButton = Button(self.root, text="Skip", command=self.skipFile)
- ## Start grid
+ # --Start grid
# The image
self.imagePanel.grid(row=0, column=0, rowspan=11, columnspan=4)
@@ -396,7 +404,7 @@
# https://www.flickr.com/services/api/flickr.groups.pools.getPhotos.html
# Get the photos in a group
if group_id:
- #First get the total number of photo's in the group
+ # First get the total number of photo's in the group
photos = flickr.groups_pools_getPhotos(group_id=group_id,
user_id=user_id, tags=tags,
per_page='100', page='1')
@@ -460,7 +468,7 @@
photos = flickr.people_getPublicPhotos(user_id=user_id,
per_page='100', page='1')
pages = photos.find('photos').attrib['pages']
- #flickrapi.exceptions.FlickrError
+ # flickrapi.exceptions.FlickrError
for i in range(1, int(pages) + 1):
gotPhotos = False
while not gotPhotos:
@@ -502,7 +510,7 @@
def main():
- #Get the api key
+ # Get the api key
if not config.flickr['api_key']:
pywikibot.output('Flickr api key not found! Get yourself an api key')
pywikibot.output(
--
To view, visit https://gerrit.wikimedia.org/r/151998
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iba332b3462eb7e188df4ae049db59d946b0aa92e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Audiodude <audiodude(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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: APISite: factor out validation of iterations params
......................................................................
APISite: factor out validation of iterations params
A few methods in APISite were reusing the exact same code to validate
parameters used with an iterator (start, end, reverse). The new
assert_valid_iter_params() now takes care of it.
Change-Id: I3e90ec613080c5257ce1ed1ebbd981841f0a192e
---
M pywikibot/site.py
1 file changed, 22 insertions(+), 50 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
Objections:
John Vandenberg: There's a problem with this change, please improve
diff --git a/pywikibot/site.py b/pywikibot/site.py
index b319a99..5e0d28b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1392,6 +1392,17 @@
# User blocked
raise UserBlocked('User is blocked in site %s' % self)
+ def assert_valid_iter_params(self, msg_prefix, start, end, reverse):
+ """Validate iterating API parameters."""
+ if reverse:
+ if end < start:
+ raise Error(
+ "%s: end must be later than start with reverse=True" % msg_prefix)
+ else:
+ if start < end:
+ raise Error(
+ "%s: start must be later than end with reverse=False" % msg_prefix)
+
def has_right(self, right, sysop=False):
"""Return true if and only if the user has a specific right.
@@ -2871,16 +2882,8 @@
"""
if start and end:
- if reverse:
- if end < start:
- raise Error(
- "logevents: "
- "end must be later than start with reverse=True")
- else:
- if start < end:
- raise Error(
- "logevents: "
- "start must be later than end with reverse=False")
+ self.assert_valid_iter_params('logevents', start, end, reverse)
+
legen = self._generator(api.LogEntryListGenerator, type_arg=logtype,
step=step, total=total)
if logtype is not None:
@@ -2941,16 +2944,8 @@
"""
if start and end:
- if reverse:
- if end < start:
- raise Error(
- "recentchanges: "
- "end must be later than start with reverse=True")
- else:
- if start < end:
- raise Error(
- "recentchanges: "
- "start must be later than end with reverse=False")
+ self.assert_valid_iter_params('recentchanges', start, end, reverse)
+
rcgen = self._generator(api.ListGenerator, type_arg="recentchanges",
rcprop="user|comment|timestamp|title|ids"
"|sizes|redirect|loginfo|flags",
@@ -3056,17 +3051,10 @@
if not (user or userprefix):
raise Error(
"usercontribs: either user or userprefix must be non-empty")
+
if start and end:
- if reverse:
- if end < start:
- raise Error(
- "usercontribs: "
- "end must be later than start with reverse=True")
- else:
- if start < end:
- raise Error(
- "usercontribs: "
- "start must be later than end with reverse=False")
+ self.assert_valid_iter_params('usercontribs', start, end, reverse)
+
ucgen = self._generator(api.ListGenerator, type_arg="usercontribs",
ucprop="ids|title|timestamp|comment|flags",
namespaces=namespaces, step=step,
@@ -3106,16 +3094,8 @@
"""
if start and end:
- if reverse:
- if end < start:
- raise Error(
- "watchlist_revs: "
- "end must be later than start with reverse=True")
- else:
- if start < end:
- raise Error(
- "watchlist_revs: "
- "start must be later than end with reverse=False")
+ self.assert_valid_iter_params('watchlist_revs', start, end, reverse)
+
wlgen = self._generator(api.ListGenerator, type_arg="watchlist",
wlprop="user|comment|timestamp|title|ids|flags",
wlallrev="", namespaces=namespaces,
@@ -3157,16 +3137,8 @@
"""
if start and end:
- if reverse:
- if end < start:
- raise Error(
- "deletedrevs: "
- "end must be later than start with reverse=True")
- else:
- if start < end:
- raise Error(
- "deletedrevs: "
- "start must be later than end with reverse=False")
+ self.assert_valid_iter_params('deletedrevs', start, end, reverse)
+
if not self.logged_in():
self.login()
if "deletedhistory" not in self.userinfo['rights']:
--
To view, visit https://gerrit.wikimedia.org/r/145698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3e90ec613080c5257ce1ed1ebbd981841f0a192e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <hashar(a)free.fr>
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: The Final Flakes
......................................................................
The Final Flakes
hashar has enabled the flake8 tests on jenkins to be voting,
so new flakes will be hard to push into the codebase in future.
This changeset removes two that have slipped into the codebase
over the last week.
setup.py:37:9: F401 'unittest' imported but unused
scripts/protect.py:222:41: F812 list comprehension redefines 'p_type'
from line 189
Change-Id: I19fb7ca525383ef1ab13e807edc9b4b00394cbb1
---
M scripts/protect.py
M setup.py
2 files changed, 4 insertions(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/protect.py b/scripts/protect.py
index 256d76b..f3f4fc5 100644
--- a/scripts/protect.py
+++ b/scripts/protect.py
@@ -186,10 +186,10 @@
if arg.startswith('-'):
delimiter = arg.find(':')
if delimiter > 0:
- p_type = arg[1:delimiter]
+ p_type_arg = arg[1:delimiter]
level = arg[delimiter + 1:]
- if p_type in protection_types:
- protections[p_type] = level
+ if p_type_arg in protection_types:
+ protections[p_type_arg] = level
is_p_type = True
if not is_p_type:
if not genFactory.handleArg(arg):
diff --git a/setup.py b/setup.py
index b4dc10f..4d64d1f 100644
--- a/setup.py
+++ b/setup.py
@@ -34,7 +34,7 @@
raise RuntimeError("ERROR: Pywikibot only runs under Python 2.6.5 or higher")
elif sys.version_info[1] == 6:
# work around distutils hardcoded unittest dependency
- import unittest
+ import unittest # flake8: noqa
if 'test' in sys.argv and sys.version_info < (2, 7):
import unittest2
sys.modules['unittest'] = unittest2
--
To view, visit https://gerrit.wikimedia.org/r/154832
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I19fb7ca525383ef1ab13e807edc9b4b00394cbb1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Allow sleeps to occur during scripts
......................................................................
Allow sleeps to occur during scripts
Most of the scripts which performed a login too
early have been fixed in:
I63e1699a4b70dde161c0430beaaa5ed0b44093cb
However other scripts auto-run, and still may unexpectedly report sleeps
on stderr. Separate them from other stderr output,
Change-Id: I0c10a96e55dadfe84d824253f82a7593afb4cfd4
---
M tests/script_tests.py
1 file changed, 6 insertions(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index abfdcc4..f65404f 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -178,7 +178,12 @@
result['stderr'])
elif (args and '-help' in args) or \
script_name not in auto_run_script_list:
- self.assertEqual(result['stderr'], '')
+ stderr = [l for l in result['stderr'].split('\n')
+ if not l.startswith('Sleeping for ')]
+ pywikibot.output('\n'.join(
+ [l for l in result['stderr'].split('\n')
+ if l.startswith('Sleeping for ')]))
+ self.assertEqual('\n'.join(stderr), '')
self.assertIn('Global arguments available for all',
result['stdout'])
self.assertEqual(result['exit_code'], 0)
--
To view, visit https://gerrit.wikimedia.org/r/153004
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0c10a96e55dadfe84d824253f82a7593afb4cfd4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>