jenkins-bot has submitted this change and it was merged.
Change subject: fix pep8 error E713 "test for membership should be 'not in'"
......................................................................
fix pep8 error E713 "test for membership should be 'not in'"
cleaned up all occurrences
using an ad-hoc helper script with manual check for every replacement
Change-Id: Ib4eca94b342a340efcffdcdaf284808727817778
---
M generate_user_files.py
M pywikibot/__init__.py
M pywikibot/data/api.py
M pywikibot/page.py
M pywikibot/site.py
M scripts/archivebot.py
M scripts/claimit.py
M scripts/cosmetic_changes.py
M scripts/featured.py
M scripts/interwiki.py
M scripts/makecat.py
M scripts/redirect.py
M scripts/reflinks.py
M scripts/replicate_wiki.py
M scripts/spamremove.py
15 files changed, 29 insertions(+), 29 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index eed4339..3f7fba5 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -91,7 +91,7 @@
except ValueError:
pass
if isinstance(choice, basestring):
- if not choice in clist:
+ if choice not in clist:
print("Invalid response")
else:
return choice
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 6843ec6..ef50bfc 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -155,7 +155,7 @@
for the Wikibase API.
FIXME Should this be in the DataSite object?
"""
- if not self.globe in self.site.globes():
+ if self.globe not in self.site.globes():
raise NotImplementedError(u"%s is not supported in Wikibase yet." % self.globe)
return {'latitude': self.lat,
'longitude': self.lon,
@@ -410,7 +410,7 @@
except ImportError:
raise ValueError("Invalid interface name '%(interface)s'" % locals())
key = '%s:%s:%s' % (fam, code, user)
- if not key in _sites or not isinstance(_sites[key], __Site):
+ if key not in _sites or not isinstance(_sites[key], __Site):
_sites[key] = __Site(code=code, fam=fam, user=user, sysop=sysop)
pywikibot.debug(u"Instantiating Site object '%(site)s'"
% {'site': _sites[key]}, _logger)
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 72ebb3b..d5fc032 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -733,7 +733,7 @@
# "random" module does not return "query-continue"
# now we loop for a new random query
continue
- if not "query-continue" in self.data:
+ if "query-continue" not in self.data:
return
if all(key not in self.data["query-continue"] for key in self.continuekey):
pywikibot.log(
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 0adbc0a..92607f7 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -328,7 +328,7 @@
# If not already stored, fetch revision
if not hasattr(self, "_revid") \
- or not self._revid in self._revisions \
+ or self._revid not in self._revisions \
or self._revisions[self._revid].text is None:
try:
self.site.loadrevisions(self, getText=True, sysop=sysop)
@@ -350,7 +350,7 @@
@param oldid: The revid of the revision desired.
"""
- if force or not oldid in self._revisions \
+ if force or oldid not in self._revisions \
or self._revisions[oldid].text is None:
self.site.loadrevisions(self,
getText=True,
@@ -2488,7 +2488,7 @@
self.labels = {}
if 'labels' in self._content:
for lang in self._content['labels']:
- if not 'removed' in self._content['labels'][lang]: # Bug 54767
+ if 'removed' not in self._content['labels'][lang]: # Bug 54767
self.labels[lang] = self._content['labels'][lang]['value']
#descriptions
@@ -2706,7 +2706,7 @@
if force or not hasattr(self, '_content'):
self.get(force=force)
dbname = self.getdbName(site)
- if not dbname in self.sitelinks:
+ if dbname not in self.sitelinks:
raise pywikibot.NoPage(self)
else:
return self.sitelinks[dbname]
diff --git a/pywikibot/site.py b/pywikibot/site.py
index db7c13e..fccf2f0 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -868,14 +868,14 @@
# Return all messages
if keys == u'*' or keys == [u'*']:
for msg in msg_query:
- if not 'missing' in msg:
+ if 'missing' not in msg:
self._msgcache[msg['name']] = msg['*']
return self._msgcache
# Return only given keys
else:
for _key in keys:
for msg in msg_query:
- if msg['name'] == _key and not 'missing' in msg:
+ if msg['name'] == _key and 'missing' not in msg:
self._msgcache[_key] = msg['*']
break
else:
@@ -3544,7 +3544,7 @@
params['props'] = '|'.join(props)
req = api.Request(site=self, **params)
data = req.submit()
- if not 'success' in data:
+ if 'success' not in data:
raise pywikibot.data.api.APIError(data['errors'])
return data['entities']
diff --git a/scripts/archivebot.py b/scripts/archivebot.py
index a3884b5..eea5189 100644
--- a/scripts/archivebot.py
+++ b/scripts/archivebot.py
@@ -383,7 +383,7 @@
and not self.Page.title() + '/' == archive[:len(self.Page.title()) + 1] \
and not self.key_ok():
raise ArchiveSecurityError("Archive page %r does not start with page title (%s)!" % (archive, self.Page.title()))
- if not archive in self.archives:
+ if archive not in self.archives:
self.archives[archive] = DiscussionPage(archive, self, vars)
return self.archives[archive].feedThread(thread, maxArchiveSize)
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 64beeb2..a8a0c09 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -141,7 +141,7 @@
if sorted(list1) != sorted(list2):
return False
for item in list1:
- if not item in list2:
+ if item not in list2:
return False
return True
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index e7836d2..7428f3e 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -259,9 +259,9 @@
# German Wikipedia. See
# http://de.wikipedia.org/wiki/Hilfe_Diskussion:Personendaten/Archiv/1#Positi…
# ignoring nn-wiki of cause of the comment line above iw section
- if not self.template and not '{{Personendaten' in text and \
- not '{{SORTIERUNG' in text and not '{{DEFAULTSORT' in text and \
- not self.site.lang in ('et', 'it', 'bg', 'ru'):
+ if not self.template and '{{Personendaten' not in text and \
+ '{{SORTIERUNG' not in text and '{{DEFAULTSORT' not in text and \
+ self.site.lang not in ('et', 'it', 'bg', 'ru'):
categories = pywikibot.getCategoryLinks(text, site=self.site)
if not self.talkpage: # and pywikibot.calledModuleName() <> 'interwiki':
diff --git a/scripts/featured.py b/scripts/featured.py
index 69409e3..f56e63c 100644
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -512,9 +512,9 @@
site.code), re.IGNORECASE)
tosite = self.site
- if not fromsite.lang in self.cache:
+ if fromsite.lang not in self.cache:
self.cache[fromsite.lang] = {}
- if not tosite.lang in self.cache[fromsite.lang]:
+ if tosite.lang not in self.cache[fromsite.lang]:
self.cache[fromsite.lang][tosite.lang] = {}
cc = self.cache[fromsite.lang][tosite.lang]
if self.getOption('nocache') is True or \
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 1de151a..019b478 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -733,7 +733,7 @@
def add(self, page):
site = page.site
- if not site in self.tree:
+ if site not in self.tree:
self.tree[site] = []
self.tree[site].append(page)
self.size += 1
@@ -1226,7 +1226,7 @@
if newhint == '?':
t += globalvar.showtextlinkadd
pywikibot.output(self.originPage.get()[:t])
- elif newhint and not ':' in newhint:
+ elif newhint and ':' not in newhint:
pywikibot.output(
u'Please enter a hint in the format '
u'language:pagename or type nothing if you do not '
@@ -1742,8 +1742,8 @@
import userlib
user = userlib.User(page.site, page.userName())
# erstmal auch keine namen mit bot
- if not 'bot' in user.groups() \
- and not 'bot' in page.userName().lower():
+ if 'bot' not in user.groups() \
+ and 'bot' not in page.userName().lower():
smallWikiAllowed = True
else:
_now = datetime.datetime.utcnow()
diff --git a/scripts/makecat.py b/scripts/makecat.py
index 73db257..f997906 100644
--- a/scripts/makecat.py
+++ b/scripts/makecat.py
@@ -85,7 +85,7 @@
pass
else:
cats = [x for x in pl.categories()]
- if not workingcat in cats:
+ if workingcat not in cats:
cats = [x for x in pl.categories()]
for c in cats:
if c in parentcats:
@@ -160,7 +160,7 @@
elif answer == 'a':
pagetitle = raw_input("Specify page to add:")
page = pywikibot.Page(pywikibot.Site(), pagetitle)
- if not page in checked.keys():
+ if page not in checked.keys():
include(page)
elif answer == 'x':
if pl.exists():
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 7d451c4..a4b625d 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -787,7 +787,7 @@
except ValueError:
#-namespace:all Process all namespaces. Works only with the API read interface.
pass
- if not ns in namespaces:
+ if ns not in namespaces:
namespaces.append(ns)
elif arg.startswith('-offset:'):
offset = int(arg[8:])
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index ee7037c..b23d369 100644
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -310,7 +310,7 @@
params = match.group('params')
group = self.GROUPS.match(params)
- if not group in foundRefs:
+ if group not in foundRefs:
foundRefs[group] = {}
groupdict = foundRefs[group]
@@ -331,7 +331,7 @@
if name == 'population':
pywikibot.output(content)
- if not name in foundRefNames:
+ if name not in foundRefNames:
# first time ever we meet this name
if name == 'population':
pywikibot.output("in")
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py
index 082b4ef..bdd6171 100644
--- a/scripts/replicate_wiki.py
+++ b/scripts/replicate_wiki.py
@@ -129,7 +129,7 @@
pages = imap(lambda p: p.title(),
self.original.allpages('!', namespace=namespace))
for p in pages:
- if not p in ['MediaWiki:Sidebar', 'MediaWiki:Mainpage',
+ if p not in ['MediaWiki:Sidebar', 'MediaWiki:Mainpage',
'MediaWiki:Sitenotice', 'MediaWiki:MenuSidebar']:
try:
self.check_page(p)
diff --git a/scripts/spamremove.py b/scripts/spamremove.py
index b024b61..60906f1 100755
--- a/scripts/spamremove.py
+++ b/scripts/spamremove.py
@@ -67,7 +67,7 @@
{'url': spamSite})
for i, p in enumerate(pages, 1):
text = p.text
- if not spamSite in text:
+ if spamSite not in text:
continue
# Show the title of the page we're working on.
# Highlight the title in purple.
--
To view, visit https://gerrit.wikimedia.org/r/130214
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib4eca94b342a340efcffdcdaf284808727817778
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: improved checks for precision when initializing WbTime objects
......................................................................
improved checks for precision when initializing WbTime objects
also used the 'self' keyword instead of the hardcoded class name
and added two tests
Change-Id: Ieffc18ebac19050ceb4d71246a042db1d4b29db3
---
M pywikibot/__init__.py
M tests/wikibase_tests.py
2 files changed, 13 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 784ca29..6843ec6 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -224,21 +224,21 @@
"""
if year is None:
raise ValueError('no year given')
- self.precision = WbTime.PRECISION['second']
+ self.precision = self.PRECISION['second']
if second is None:
- self.precision = WbTime.PRECISION['minute']
+ self.precision = self.PRECISION['minute']
second = 0
if minute is None:
- self.precision = WbTime.PRECISION['hour']
+ self.precision = self.PRECISION['hour']
minute = 0
if hour is None:
- self.precision = WbTime.PRECISION['day']
+ self.precision = self.PRECISION['day']
hour = 0
if day is None:
- self.precision = WbTime.PRECISION['month']
+ self.precision = self.PRECISION['month']
day = 1
if month is None:
- self.precision = WbTime.PRECISION['year']
+ self.precision = self.PRECISION['year']
month = 1
self.year = long(year)
self.month = month
@@ -253,10 +253,10 @@
# if precision is given it overwrites the autodetection above
if precision is not None:
- if isinstance(precision, int):
+ if isinstance(precision, int) and precision in self.PRECISION.values():
self.precision = precision
- elif precision in WbTime.PRECISION:
- self.precision = WbTime.PRECISION[precision]
+ elif precision in self.PRECISION:
+ self.precision = self.PRECISION[precision]
else:
raise ValueError('Invalid precision: "%s"' % precision)
@@ -274,8 +274,8 @@
"""
Function which converts the the data to a UTC date/time string
"""
- return WbTime.FORMATSTR.format(self.year, self.month, self.day,
- self.hour, self.minute, self.second)
+ return self.FORMATSTR.format(self.year, self.month, self.day,
+ self.hour, self.minute, self.second)
def toWikibase(self):
"""
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index fc0e267..d1338ad 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -49,6 +49,8 @@
# test WbTime
t = pywikibot.WbTime(year=2010, hour=12, minute=43)
self.assertEqual(t.toTimestr(), '+00000002010-01-01T12:43:00Z')
+ self.assertRaises(ValueError, pywikibot.WbTime, precision=15)
+ self.assertRaises(ValueError, pywikibot.WbTime, precision='invalid_precision')
# test WikibasePage.__cmp__
self.assertEqual(pywikibot.ItemPage.fromPage(mainpage), pywikibot.ItemPage(repo, 'q5296'))
--
To view, visit https://gerrit.wikimedia.org/r/129975
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ieffc18ebac19050ceb4d71246a042db1d4b29db3
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)live.it>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] QueryGenerator may have action="query" parameter
......................................................................
[bugfix] QueryGenerator may have action="query" parameter
The constructor of QueryGenerator may have action="query" as
arcument.
The current release always raise the Error message when an action
parameter is given, even the parameter's value is "query" because
"action" != "query" is always true.
This patch fixes the constructor in the right way.
Change-Id: I7b4f957b3aa344f8836e0a360f32b6af3a7dd589
---
M pywikibot/data/api.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index f129665..72ebb3b 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -499,9 +499,9 @@
assumed.
"""
- if "action" in kwargs and "action" != "query":
+ if "action" in kwargs and kwargs["action"] != "query":
raise Error("%s: 'action' must be 'query', not %s"
- % (self.__class__.__name__, kwargs["query"]))
+ % (self.__class__.__name__, kwargs["action"]))
else:
kwargs["action"] = "query"
try:
--
To view, visit https://gerrit.wikimedia.org/r/129937
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7b4f957b3aa344f8836e0a360f32b6af3a7dd589
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>