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:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11378
Revision: 11378
Author: amir
Date: 2013-04-17 15:48:52 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
removing parenthesis as a not-at-the-end-mark per bug #3610818
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/textlib.py
Modified: trunk/pywikipedia/pywikibot/textlib.py
===================================================================
--- trunk/pywikipedia/pywikibot/textlib.py 2013-04-17 14:38:34 UTC (rev 11377)
+++ trunk/pywikipedia/pywikibot/textlib.py 2013-04-17 15:48:52 UTC (rev 11378)
@@ -837,7 +837,7 @@
# Note: While allowing dots inside URLs, MediaWiki will regard
# dots at the end of the URL as not part of that URL.
# The same applies to comma, colon and some other characters.
- notAtEnd = '\]\s\.:;,<>"\|\)'
+ notAtEnd = '\]\s\.:;,<>"\|'
# So characters inside the URL can be anything except whitespace,
# closing squared brackets, quotation marks, greater than and less
# than, and the last character also can't be parenthesis or another
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11377
Revision: 11377
Author: drtrigon
Date: 2013-04-17 14:38:34 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
bug fix; for cleanup with unicode data ('?\195?\164'), follow-up to r11214 (and all before that)
Modified Paths:
--------------
trunk/pywikipedia/sum_disc.py
Modified: trunk/pywikipedia/sum_disc.py
===================================================================
--- trunk/pywikipedia/sum_disc.py 2013-04-17 09:40:00 UTC (rev 11376)
+++ trunk/pywikipedia/sum_disc.py 2013-04-17 14:38:34 UTC (rev 11377)
@@ -36,10 +36,6 @@
will cause no problem for the bot, because the entries are also written to the
history.
-The following parameters are supported:
-
-¶ms;
-
All other parameters will be ignored.
Syntax example:
@@ -1116,7 +1112,7 @@
for line in text.splitlines():
try:
#date = time.strptime(u'abc', u'; %d. %B %Y')
- date = time.strptime(line, str(self._param['parse_msg'][u'start']))
+ date = time.strptime(line.encode('utf-8'), str(self._param['parse_msg'][u'start']))
#date = time.strptime(str(line), str(self._param['parse_msg'][u'start']))
date = datetime.datetime.fromtimestamp(time.mktime(date))
diff = (today - date).days
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11373
Revision: 11373
Author: multichill
Date: 2013-04-16 18:54:08 +0000 (Tue, 16 Apr 2013)
Log Message:
-----------
Added crude dupe checking so we're not causing a big mess.
Modified Paths:
--------------
branches/rewrite/scripts/claimit.py
Modified: branches/rewrite/scripts/claimit.py
===================================================================
--- branches/rewrite/scripts/claimit.py 2013-04-16 18:22:45 UTC (rev 11372)
+++ branches/rewrite/scripts/claimit.py 2013-04-16 18:54:08 UTC (rev 11373)
@@ -30,10 +30,14 @@
return False
for claim in claims:
- pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget().getID()))
- item.addClaim(claim)
- #TODO FIXME: We should add a source for each claim that is added
- #TODO FIXME: We need to check that we aren't adding a duplicate
+ if claim.getID() in item.get().get('claims'):
+ pywikibot.output(u'A claim for %s already exists. Skipping' % (claim.getID(),))
+ #TODO FIXME: This is a very crude way of dupe checking
+ else:
+ pywikibot.output('Adding %s --> %s' % (claim.getID(), claim.getTarget().getID()))
+ item.addClaim(claim)
+ #TODO FIXME: We should add a source for each claim that is added
+ #TODO FIXME: We need to check that we aren't adding a duplicate
def main():
@@ -52,7 +56,6 @@
claim.setTarget(pywikibot.ItemPage(repo, commandline_claims[i+1]))
claims.append(claim)
-
generator = gen.getCombinedGenerator()
if generator: