Revision: 4222
Author: russblau
Date: 2007-09-10 15:53:00 +0000 (Mon, 10 Sep 2007)
Log Message:
-----------
Find and replace incorrectly capitalized category names
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-09-10 14:45:03 UTC (rev 4221)
+++ trunk/pywikipedia/wikipedia.py 2007-09-10 15:53:00 UTC (rev 4222)
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
"""
Library to get and put pages on a MediaWiki.
@@ -2865,7 +2865,14 @@
site = getSite()
catNamespace = '|'.join(site.category_namespaces())
- categoryR = re.compile(r'\[\[\s*(%s)\s*:%s\]\]' % (catNamespace,
oldcat.titleWithoutNamespace()))
+ title = oldcat.titleWithoutNamespace()
+ if not title:
+ return
+ # title might not be formatted correctly on the wiki
+ if title[0].isalpha() and not site.nocapitalize:
+ title = "[%s%s]" % (title[0].upper(), title[0].lower()) + title[1:]
+ categoryR = re.compile(r'\[\[\s*(%s)\s*:\s*%s\s*\]\]'
+ % (catNamespace, title))
if newcat is None:
text = replaceExcept(oldtext, categoryR, '', ['nowiki',
'comment', 'math', 'pre'])
else:
Show replies by date