http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11380
Revision: 11380 Author: valhallasw Date: 2013-04-18 09:21:17 +0000 (Thu, 18 Apr 2013) Log Message: ----------- API-based search: [] means /every/ namespace, not just 0
In the scrape-based search, the namespaces=[] parameter meant to search /every/ namespace, not just 0. This commit adapts the API search behavior to be consistent with this.
Modified Paths: -------------- branches/rewrite/pywikibot/site.py trunk/pywikipedia/wikipedia.py
Modified: branches/rewrite/pywikibot/site.py =================================================================== --- branches/rewrite/pywikibot/site.py 2013-04-17 17:05:23 UTC (rev 11379) +++ branches/rewrite/pywikibot/site.py 2013-04-18 09:21:17 UTC (rev 11380) @@ -2250,7 +2250,7 @@ @param where: Where to search; value must be "text" or "titles" (many wikis do not support title search) @param namespaces: search only in these namespaces (defaults to 0) - @type namespaces: list of ints + @type namespaces: list of ints, or an empty list to signal all namespaces @param getredirects: if True, include redirects in results @param content: if True, load the current content of each iterated page (default False) @@ -2260,6 +2260,8 @@ raise Error("search: searchstring cannot be empty") if where not in ("text", "titles"): raise Error("search: unrecognized 'where' value: %s" % where) + if namespaces == []: + namespaces = [ns for ns in self.namespaces().keys() if ns >= 0] if not namespaces: pywikibot.warning(u"search: namespaces cannot be empty; using [0].") namespaces = [0]
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-04-17 17:05:23 UTC (rev 11379) +++ trunk/pywikipedia/wikipedia.py 2013-04-18 09:21:17 UTC (rev 11380) @@ -7018,6 +7018,8 @@ params['srlimit'] = number if namespaces: params['srnamespace'] = namespaces + if namespaces == []: + params['srnamespace'] = [ni for ni in (self.getNamespaceIndex(x) for x in self.namespaces()) if ni >= 0]
offset = 0 while offset < number or not number: