http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9227
Revision: 9227
Author: xqt
Date: 2011-05-09 19:10:46 +0000 (Mon, 09 May 2011)
Log Message:
-----------
py 2.4 has no keyword arguments for __import__(). Fix for bug #3199823
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/i18n.py
Modified: trunk/pywikipedia/pywikibot/i18n.py
===================================================================
--- trunk/pywikipedia/pywikibot/i18n.py 2011-05-09 18:42:05 UTC (rev 9226)
+++ trunk/pywikipedia/pywikibot/i18n.py 2011-05-09 19:10:46 UTC (rev 9227)
@@ -223,7 +223,7 @@
import table.
"""
package = twtitle.split("-")[0]
- transdict = getattr(__import__("i18n", fromlist=[package]), package).msg
+ transdict = getattr(__import__("i18n", {}, {}, [package]), package).msg
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
@@ -263,7 +263,7 @@
import table.
"""
package = twtitle.split("-")[0]
- transdict = getattr(__import__("i18n", fromlist=[package]), package).msg
+ transdict = getattr(__import__("i18n", {}, {}, [package]), package).msg
# If a site is given instead of a code, use its language
if hasattr(code, 'lang'):
code = code.lang
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9225
Revision: 9225
Author: cydeweys
Date: 2011-05-09 18:40:55 +0000 (Mon, 09 May 2011)
Log Message:
-----------
An improvement that removes the entire line (rather than just the text of a line) when a category is being removed and the line has nothing other than whitespace on it. This prevents category removals from leaving gaps in category listings.
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/textlib.py
Modified: trunk/pywikipedia/pywikibot/textlib.py
===================================================================
--- trunk/pywikipedia/pywikibot/textlib.py 2011-05-08 15:38:45 UTC (rev 9224)
+++ trunk/pywikipedia/pywikibot/textlib.py 2011-05-09 18:40:55 UTC (rev 9225)
@@ -617,8 +617,17 @@
title = title.replace(r"\ ", "[ _]+").replace(r"\_", "[ _]+")
categoryR = re.compile(r'\[\[\s*(%s)\s*:\s*%s\s*((?:\|[^]]+)?\]\])'
% (catNamespace, title), re.I)
+ categoryRN = re.compile(r'^[^\S\n]*\[\[\s*(%s)\s*:\s*%s\s*((?:\|[^]]+)?\]\])[^\S\n]*\n'
+ % (catNamespace, title), re.I | re.M)
if newcat is None:
- text = replaceExcept(oldtext, categoryR, '',
+ """ First go through and try the more restrictive regex that removes
+ an entire line, if the category is the only thing on that line (this
+ prevents blank lines left over in category lists following a removal.)
+ """
+
+ text = replaceExcept(oldtext, categoryRN, '',
+ ['nowiki', 'comment', 'math', 'pre', 'source'])
+ text = replaceExcept(text, categoryR, '',
['nowiki', 'comment', 'math', 'pre', 'source'])
else:
text = replaceExcept(oldtext, categoryR,