[MediaWiki-commits] [Gerrit] [FIX] QueryGenerator: Allow missing 'query' entry - change (pywikibot/core)

2014-12-19 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: [FIX] QueryGenerator: Allow missing 'query' entry
..


[FIX] QueryGenerator: Allow missing 'query' entry

The QueryGenerator stopped when the result didn't contain a 'query'
entry. If the result doesn't contain anything yet (but needs to be
continued) it's not returning a 'query' entry when used with the
'generator' API feature.

Instead of stopping the iteration when there is not 'query' entry it's
just stopping the iteration if there is no continuation provided.
Because the exact nature why the condition was there in the first place
(it was added in 54bc6aafa591e31274dc3630e9c6c1039f80839b) is not known
the output was raised from 'debug' to 'log'. Prior to that revision no
condition was found in the repository which looks like that.

Bug: T84860
Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
---
M pywikibot/data/api.py
M tests/category_tests.py
2 files changed, 5 insertions(+), 12 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  Unicodesnowman: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 04420c2..5b70fe1 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1483,14 +1483,7 @@
 % self.__class__.__name__,
 _logger)
 return
-if query not in self.data:
-pywikibot.debug(
-u%s: stopped iteration because 'query' not found in api 
-uresponse. % self.__class__.__name__,
-_logger)
-pywikibot.debug(unicode(self.data), _logger)
-return
-if self.resultkey in self.data[query]:
+if 'query' in self.data and self.resultkey in self.data[query]:
 resultdata = self.data[query][self.resultkey]
 if isinstance(resultdata, dict):
 pywikibot.debug(u%s received %s; limit=%s
@@ -1538,6 +1531,10 @@
 # self.resultkey in data in last request.submit()
 previous_result_had_data = True
 else:
+if 'query' not in self.data:
+pywikibot.log(%s: 'query' not found in api response. %
+  self.__class__.__name__)
+pywikibot.log(unicode(self.data))
 # if (query-)continue is present, self.resultkey might not have
 # been fetched yet
 if self.continue_name not in self.data:
diff --git a/tests/category_tests.py b/tests/category_tests.py
index 6ba5abb..9e57069 100644
--- a/tests/category_tests.py
+++ b/tests/category_tests.py
@@ -11,7 +11,6 @@
 import pywikibot.page
 
 from tests.aspects import unittest, TestCase
-from tests.utils import allowed_failure
 
 
 class TestCategoryObject(TestCase):
@@ -100,11 +99,8 @@
 subcategories_total = list(cat.subcategories(total=2))
 self.assertEqual(len(subcategories_total), 2)
 
-@allowed_failure
 def test_subcategories_recurse(self):
 Test the subcategories method with recurse=True.
-# FIXME: Broken, some subcategories are missing.
-# See: T84860
 site = self.get_site()
 cat = pywikibot.Category(site, 'Category:Wikipedians by gender')
 c1 = pywikibot.Category(site, 'Category:Female Wikipedians')

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise commodorefabia...@gmx.de
Gerrit-Reviewer: John Vandenberg jay...@gmail.com
Gerrit-Reviewer: Ladsgroup ladsgr...@gmail.com
Gerrit-Reviewer: Merlijn van Deen valhall...@arctus.nl
Gerrit-Reviewer: Unicodesnowman ad...@glados.cc
Gerrit-Reviewer: XZise commodorefabia...@gmx.de
Gerrit-Reviewer: jenkins-bot 

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


[MediaWiki-commits] [Gerrit] [FIX] QueryGenerator: Allow missing 'query' entry - change (pywikibot/core)

2014-12-18 Thread XZise (Code Review)
XZise has uploaded a new change for review.

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

Change subject: [FIX] QueryGenerator: Allow missing 'query' entry
..

[FIX] QueryGenerator: Allow missing 'query' entry

The QueryGenerator stopped when the result didn't contain a 'query'
entry. If the result doesn't contain anything yet (but needs to be
continued) it's not returning a 'query' entry when used with the
'generator' API feature.

Instead of stopping the iteration when there is not 'query' entry it's
just stopping the iteration if there is no continuation provided.

Bug: T84860
Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
---
M pywikibot/data/api.py
1 file changed, 6 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/79/180779/1

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 04420c2..864e0ea 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1483,14 +1483,7 @@
 % self.__class__.__name__,
 _logger)
 return
-if query not in self.data:
-pywikibot.debug(
-u%s: stopped iteration because 'query' not found in api 
-uresponse. % self.__class__.__name__,
-_logger)
-pywikibot.debug(unicode(self.data), _logger)
-return
-if self.resultkey in self.data[query]:
+if 'query' in self.data and self.resultkey in self.data[query]:
 resultdata = self.data[query][self.resultkey]
 if isinstance(resultdata, dict):
 pywikibot.debug(u%s received %s; limit=%s
@@ -1538,6 +1531,11 @@
 # self.resultkey in data in last request.submit()
 previous_result_had_data = True
 else:
+if 'query' not in self.data:
+pywikibot.debug(%s: 'query' not found in api response. %
+self.__class__.__name__,
+_logger)
+pywikibot.debug(unicode(self.data), _logger)
 # if (query-)continue is present, self.resultkey might not have
 # been fetched yet
 if self.continue_name not in self.data:

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f8c4986d69be18134987c951fd65237300e277e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise commodorefabia...@gmx.de

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