[MediaWiki-commits] [Gerrit] pywikibot...FLOSSbot[master]: plugin: make search_entity fail if entity not found

2016-10-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: plugin: make search_entity fail if entity not found
..


plugin: make search_entity fail if entity not found

Change-Id: Ib3ee3d76d5420536b2a1853e55776d0566f32768
Signed-off-by: Loic Dachary 
---
M FLOSSbot/plugin.py
1 file changed, 9 insertions(+), 6 deletions(-)

Approvals:
  Dachary: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/FLOSSbot/plugin.py b/FLOSSbot/plugin.py
index a4e04cf..5625675 100644
--- a/FLOSSbot/plugin.py
+++ b/FLOSSbot/plugin.py
@@ -211,12 +211,15 @@
 return super(Plugin, self).__getattribute__(name)
 label = " ".join(name.split('_')[1:])
 found = self.lookup_entity(label, type=type)
-if not found and self.args.test:
-self.create_entity(type, label)
-for i in range(120):
-found = self.lookup_entity(label, type=type)
-if found is not None:
-break
+if not found:
+if self.args.test:
+self.create_entity(type, label)
+for i in range(120):
+found = self.lookup_entity(label, type=type)
+if found is not None:
+break
+else:
+raise ValueError("found no items for " + name)
 return found
 
 def get_source(self, claim, id):

-- 
To view, visit https://gerrit.wikimedia.org/r/316698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3ee3d76d5420536b2a1853e55776d0566f32768
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/bots/FLOSSbot
Gerrit-Branch: master
Gerrit-Owner: Dachary 
Gerrit-Reviewer: Dachary 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] pywikibot...FLOSSbot[master]: plugin: make search_entity fail if entity not found

2016-10-18 Thread Dachary (Code Review)
Dachary has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316698

Change subject: plugin: make search_entity fail if entity not found
..

plugin: make search_entity fail if entity not found

Change-Id: Ib3ee3d76d5420536b2a1853e55776d0566f32768
Signed-off-by: Loic Dachary 
---
M FLOSSbot/plugin.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/bots/FLOSSbot 
refs/changes/98/316698/1

diff --git a/FLOSSbot/plugin.py b/FLOSSbot/plugin.py
index a4e04cf..963b010 100644
--- a/FLOSSbot/plugin.py
+++ b/FLOSSbot/plugin.py
@@ -130,7 +130,7 @@
 else:
 candidates.append(pywikibot.ItemPage(site, p['id'], 0))
 if len(candidates) == 0:
-return None
+raise ValueError("found no items for " + name)
 elif len(candidates) > 1 and kwargs['type'] == 'item':
 found = []
 for candidate in candidates:

-- 
To view, visit https://gerrit.wikimedia.org/r/316698
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3ee3d76d5420536b2a1853e55776d0566f32768
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/bots/FLOSSbot
Gerrit-Branch: master
Gerrit-Owner: Dachary 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits