jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462463 )
Change subject: [cleanup] cleanup scripts/newitem.py
......................................................................
[cleanup] cleanup scripts/newitem.py
- remove preleading "u" fron strings
- use single quotes for string literals and double quotes
**only** if they consist of single quotes within them
- use str.format(...) instead of modulo for type specifier
arguments
Change-Id: I84b6e27a75eed4f111e423d3a18db408fcbfc06a
---
M scripts/newitem.py
1 file changed, 15 insertions(+), 13 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/newitem.py b/scripts/newitem.py
index aab642f..64e3360 100755
--- a/scripts/newitem.py
+++ b/scripts/newitem.py
@@ -56,9 +56,9 @@
days=self.pageAge)
self.lastEditBefore = self.repo.getcurrenttime() - timedelta(
days=self.lastEdit)
- pywikibot.output('Page age is set to %s days so only pages created'
- '\nbefore %s will be considered.'
- % (self.pageAge, self.pageAgeBefore.isoformat()))
+ pywikibot.output('Page age is set to {0} days so only pages created'
+ '\nbefore {1} will be considered.'
+ .format(self.pageAge, self.pageAgeBefore.isoformat()))
pywikibot.output(
'Last edit is set to {0} days so only pages last edited'
'\nbefore {1} will be considered.'.format(
@@ -85,34 +85,36 @@
def treat_page_and_item(self, page, item):
"""Treat page/item."""
if item and item.exists():
- pywikibot.output(u'%s already has an item: %s.' % (page, item))
+ pywikibot.output('{0} already has an item: {1}.'
+ .format(page, item))
if self.getOption('touch'):
- pywikibot.output(u'Doing a null edit on the page.')
+ pywikibot.output('Doing a null edit on the page.')
self._touch_page(page)
return
if page.isRedirectPage():
- pywikibot.output(u'%s is a redirect page. Skipping.' % page)
+ pywikibot.output('{0} is a redirect page. Skipping.'.format(page))
return
if page.editTime() > self.lastEditBefore:
pywikibot.output(
- u'Last edit on %s was on %s.\nToo recent. Skipping.'
- % (page, page.editTime().isoformat()))
+ 'Last edit on {0} was on {1}.\nToo recent. Skipping.'
+ .format(page, page.editTime().isoformat()))
return
if page.oldest_revision.timestamp > self.pageAgeBefore:
pywikibot.output(
- u'Page creation of %s on %s is too recent. Skipping.'
- % (page, page.editTime().isoformat()))
+ 'Page creation of {0} on {1} is too recent. Skipping.'
+ .format(page, page.editTime().isoformat()))
return
if page.isCategoryRedirect():
- pywikibot.output('%s is a category redirect. Skipping.' % page)
+ pywikibot.output('{0} is a category redirect. Skipping.'
+ .format(page))
return
if page.langlinks():
# FIXME: Implement this
pywikibot.output(
- "Found language links (interwiki links).\n"
+ 'Found language links (interwiki links).\n'
"Haven't implemented that yet so skipping.")
return
@@ -155,5 +157,5 @@
return True
-if __name__ == "__main__":
+if __name__ == '__main__':
main()
--
To view, visit https://gerrit.wikimedia.org/r/462463
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I84b6e27a75eed4f111e423d3a18db408fcbfc06a
Gerrit-Change-Number: 462463
Gerrit-PatchSet: 2
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462466 )
Change subject: [cleanup] cleanup scripts/ndashredir.py
......................................................................
[cleanup] cleanup scripts/ndashredir.py
- use single quotes for string literals and double quotes
**only** if they consist of single quotes within them
- use str.format(...) instead of modulo for type specifier
arguments
Change-Id: I9f0d0409495b4c2e6280be886b1fabe94576e974
---
M scripts/ndashredir.py
1 file changed, 5 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/ndashredir.py b/scripts/ndashredir.py
index 86dd098..7339090 100644
--- a/scripts/ndashredir.py
+++ b/scripts/ndashredir.py
@@ -91,8 +91,8 @@
# skip unchanged
if redir.title() == origin:
- pywikibot.output('No need to process %s, skipping…'
- % redir.title())
+ pywikibot.output('No need to process {0}, skipping...'
+ .format(redir.title()))
# suggest -reversed parameter
if '-' in origin and not self.getOption('reversed'):
pywikibot.output('Consider using -reversed parameter '
@@ -100,13 +100,13 @@
else:
# skip existing
if redir.exists():
- pywikibot.output('%s already exists, skipping…'
- % redir.title())
+ pywikibot.output('{0} already exists, skipping...'
+ .format(redir.title()))
else:
# confirm and save redirect
if self.user_confirm(
color_format(
- 'Redirect from {lightblue}{0}{default} doesn\'t exist '
+ "Redirect from {lightblue}{0}{default} doesn't exist "
'yet.\nDo you want to create it?',
redir.title())):
# If summary option is None, it takes the default
--
To view, visit https://gerrit.wikimedia.org/r/462466
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9f0d0409495b4c2e6280be886b1fabe94576e974
Gerrit-Change-Number: 462466
Gerrit-PatchSet: 1
Gerrit-Owner: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <alangiderick(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/447390 )
Change subject: Move methods for simple claim adding/removing to WikibasePage
......................................................................
Move methods for simple claim adding/removing to WikibasePage
This object already assumes in WikibasePage.get() that all WikibasePage
instances have claims. This is the case for items, properties and also
upcoming lexemes and mediainfo entities.
Bug: T113131
Change-Id: Iea1c82e47328588aa7f44fa3364c538d689c0cd3
---
M pywikibot/page.py
M pywikibot/site.py
2 files changed, 49 insertions(+), 48 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 1a67eeb..dba0e7d 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4230,6 +4230,46 @@
"""
raise NotImplementedError
+ @allow_asynchronous
+ def addClaim(self, claim, bot=True, **kwargs):
+ """
+ Add a claim to the entity.
+
+ @param claim: The claim to add
+ @type claim: Claim
+ @param bot: Whether to flag as bot (if possible)
+ @type bot: bool
+ @keyword asynchronous: if True, launch a separate thread to add claim
+ asynchronously
+ @type asynchronous: bool
+ @keyword callback: a callable object that will be called after the
+ claim has been added. It must take two arguments:
+ (1) a WikibasePage object, and (2) an exception instance,
+ which will be None if the entity was saved successfully. This is
+ intended for use by bots that need to keep track of which saves
+ were successful.
+ @type callback: callable
+ """
+ self.repo.addClaim(self, claim, bot=bot, **kwargs)
+ claim.on_item = self
+
+ def removeClaims(self, claims, **kwargs):
+ """
+ Remove the claims from the entity.
+
+ @param claims: list of claims to be removed
+ @type claims: list or pywikibot.Claim
+ """
+ # this check allows single claims to be removed by pushing them into a
+ # list of length one.
+ if isinstance(claims, pywikibot.Claim):
+ claims = [claims]
+ data = self.repo.removeClaims(claims, **kwargs)
+ for claim in claims:
+ claim.on_item.latest_revision_id = data['pageinfo']['lastrevid']
+ claim.on_item = None
+ claim.snak = None
+
class ItemPage(WikibasePage):
@@ -4534,45 +4574,6 @@
data = {'sitelinks': data}
self.editEntity(data, **kwargs)
- @allow_asynchronous
- def addClaim(self, claim, bot=True, **kwargs):
- """
- Add a claim to the item.
-
- @param claim: The claim to add
- @type claim: Claim
- @param bot: Whether to flag as bot (if possible)
- @type bot: bool
- @keyword asynchronous: if True, launch a separate thread to add claim
- asynchronously
- @type asynchronous: bool
- @keyword callback: a callable object that will be called after the
- claim has been added. It must take two arguments: (1) an ItemPage
- object, and (2) an exception instance, which will be None if the
- item was saved successfully. This is intended for use by bots that
- need to keep track of which saves were successful.
- @type callback: callable
- """
- self.repo.addClaim(self, claim, bot=bot, **kwargs)
- claim.on_item = self
-
- def removeClaims(self, claims, **kwargs):
- """
- Remove the claims from the item.
-
- @param claims: list of claims to be removed
- @type claims: list or pywikibot.Claim
- """
- # this check allows single claims to be removed by pushing them into a
- # list of length one.
- if isinstance(claims, pywikibot.Claim):
- claims = [claims]
- data = self.repo.removeClaims(claims, **kwargs)
- for claim in claims:
- claim.on_item.latest_revision_id = data['pageinfo']['lastrevid']
- claim.on_item = None
- claim.snak = None
-
def mergeInto(self, item, **kwargs):
"""
Merge the item into another item.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index ea6c6b3..db1569d 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7719,12 +7719,12 @@
return data
@must_be(group='user')
- def addClaim(self, item, claim, bot=True, summary=None):
+ def addClaim(self, entity, claim, bot=True, summary=None):
"""
Add a claim.
- @param item: Entity to modify
- @type item: WikibasePage
+ @param entity: Entity to modify
+ @type entity: WikibasePage
@param claim: Claim to be added
@type claim: pywikibot.Claim
@param bot: Whether to mark the edit as a bot edit
@@ -7732,8 +7732,8 @@
@param summary: Edit summary
@type summary: str
"""
- params = {'action': 'wbcreateclaim', 'entity': item.getID(),
- 'baserevid': item.latest_revision_id,
+ params = {'action': 'wbcreateclaim', 'entity': entity.getID(),
+ 'baserevid': entity.latest_revision_id,
'snaktype': claim.getSnakType(), 'property': claim.getID(),
'summary': summary, 'bot': bot}
@@ -7745,11 +7745,11 @@
data = req.submit()
claim.snak = data['claim']['id']
# Update the item
- if claim.getID() in item.claims:
- item.claims[claim.getID()].append(claim)
+ if claim.getID() in entity.claims:
+ entity.claims[claim.getID()].append(claim)
else:
- item.claims[claim.getID()] = [claim]
- item.latest_revision_id = data['pageinfo']['lastrevid']
+ entity.claims[claim.getID()] = [claim]
+ entity.latest_revision_id = data['pageinfo']['lastrevid']
@must_be(group='user')
def changeClaimTarget(self, claim, snaktype='value',
--
To view, visit https://gerrit.wikimedia.org/r/447390
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iea1c82e47328588aa7f44fa3364c538d689c0cd3
Gerrit-Change-Number: 447390
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: ArthurPSmith <arthurpsmith(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462336 )
Change subject: Revert "Temporarily add vcrpy!=2.0.0 as requirement for nose-detecthttp"
......................................................................
Revert "Temporarily add vcrpy!=2.0.0 as requirement for nose-detecthttp"
This reverts commit 53a3f2033e414e741ce7be77a4cf6562c47162f3.
Reason for revert: The upstream issue has been resolved.[1]
[1]:
https://github.com/kevin1024/vcrpy/issues/393
Bug: T205073
Change-Id: I3ed7635f9b8fed2252c4db8dce27e0d06dbe6cff
---
M tox.ini
1 file changed, 0 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index ac1e6e0..599af03 100644
--- a/tox.ini
+++ b/tox.ini
@@ -77,8 +77,6 @@
deps =
nose
nose-detecthttp
- # Temporary requirement. Should be fixed in vcrpy or required in nose-detecthttp.
- vcrpy!=2.0.0
unicodecsv
mock
@@ -93,8 +91,6 @@
beautifulsoup4
nose
nose-detecthttp>=0.1.3
- # Temporary requirement. Should be fixed in vcrpy or required in nose-detecthttp.
- vcrpy!=2.0.0
six
mock
--
To view, visit https://gerrit.wikimedia.org/r/462336
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3ed7635f9b8fed2252c4db8dce27e0d06dbe6cff
Gerrit-Change-Number: 462336
Gerrit-PatchSet: 1
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/462332 )
Change subject: Revert "[tests] add check in pagegenerators_tests.TestWantedFactoryGenerator"
......................................................................
Revert "[tests] add check in pagegenerators_tests.TestWantedFactoryGenerator"
This reverts commit 5db84a897683232d250b9beca7eb6cad575caa15.
The results of this querypage are rarely updated, there is no guarantee
that the page does not exist.
Bug: T205233
Change-Id: I6e71023f384ac4f1b1920ce38eb8b0c879c7651a
---
M tests/pagegenerators_tests.py
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index 9d5d7a9..39b8fec 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -1286,7 +1286,6 @@
pages = list(gen)
self.assertLessEqual(len(pages), 5)
for page in pages:
- self.assertFalse(page.exists())
yield page
def test_wanted_pages(self):
--
To view, visit https://gerrit.wikimedia.org/r/462332
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I6e71023f384ac4f1b1920ce38eb8b0c879c7651a
Gerrit-Change-Number: 462332
Gerrit-PatchSet: 2
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)