[Pywikipedia-l] SVN: [4874] trunk/pywikipedia
rotem at svn.wikimedia.org
rotem at svn.wikimedia.org
Sun Jan 13 18:15:26 UTC 2008
Revision: 4874
Author: rotem
Date: 2008-01-13 18:15:26 +0000 (Sun, 13 Jan 2008)
Log Message:
-----------
(bug 1863432) Make sure that category links don't contain an interwiki prefix, even if the 'default wiki' is different (this is important for cosmetic_changes with interwiki.py).
Modified Paths:
--------------
trunk/pywikipedia/catlib.py
trunk/pywikipedia/cosmetic_changes.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py 2008-01-13 17:52:50 UTC (rev 4873)
+++ trunk/pywikipedia/catlib.py 2008-01-13 18:15:26 UTC (rev 4874)
@@ -67,7 +67,7 @@
self.articleCache = []
self.subcatCache = []
- def aslink(self, forceInterwiki = False):
+ def aslink(self, forceInterwiki = False, noInterwiki = False):
"""
A string representation in the form of a link. This method is different
from Page.aslink() as the sortkey may have to be included.
@@ -76,7 +76,7 @@
titleWithSortKey = '%s|%s' % (self.title(), self.sortKey)
else:
titleWithSortKey = self.title()
- if forceInterwiki or self.site() != wikipedia.getSite():
+ if not noInterwiki and (forceInterwiki or self.site() != wikipedia.getSite()):
if self.site().family != wikipedia.getSite().family:
return '[[%s:%s:%s]]' % (self.site().family.name, self.site().lang, titleWithSortKey)
else:
Modified: trunk/pywikipedia/cosmetic_changes.py
===================================================================
--- trunk/pywikipedia/cosmetic_changes.py 2008-01-13 17:52:50 UTC (rev 4873)
+++ trunk/pywikipedia/cosmetic_changes.py 2008-01-13 18:15:26 UTC (rev 4874)
@@ -131,10 +131,10 @@
def standardizeCategories(self, text):
"""
- Makes sure that interwiki links are put to the correct position, but
+ Makes sure that categories are put to the correct position, but
does not sort them.
"""
- # The PyWikipediaBot is no longer allowed to touch categories on the German Wikipedia. See de.wikipedia.org/wiki/Wikipedia_Diskussion:Personendaten#Position
+ # The PyWikipediaBot is no longer allowed to touch categories on the German Wikipedia. See http://de.wikipedia.org/wiki/Hilfe_Diskussion:Personendaten/Archiv/bis_2006#Position_der_Personendaten_am_.22Artikelende.22
if self.site != wikipedia.Site('de', 'wikipedia'):
categories = wikipedia.getCategoryLinks(text, site = self.site)
text = wikipedia.replaceCategoryLinks(text, categories, site = self.site)
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-13 17:52:50 UTC (rev 4873)
+++ trunk/pywikipedia/wikipedia.py 2008-01-13 18:15:26 UTC (rev 4874)
@@ -490,7 +490,7 @@
"""Return a more complete string representation."""
return "%s{%s}" % (self.__class__.__name__, str(self))
- def aslink(self, forceInterwiki=False, textlink=False):
+ def aslink(self, forceInterwiki=False, textlink=False, noInterwiki=False):
"""Return a string representation in the form of a wikilink.
If forceInterwiki is True, return an interwiki link even if it
@@ -502,7 +502,7 @@
a : character). (Not needed if forceInterwiki is True.)
"""
- if forceInterwiki or self.site() != getSite():
+ if not noInterwiki and (forceInterwiki or self.site() != getSite()):
if self.site().family != getSite().family:
return u'[[%s:%s:%s]]' % (self.site().family.name, self.site().lang, self.title(savetitle=True))
else:
@@ -3240,13 +3240,12 @@
'categories' should be a list of Category objects.
The string is formatted for inclusion in insite.
-
"""
if not categories:
return ''
if insite is None:
insite = getSite()
- catLinks = [category.aslink() for category in categories]
+ catLinks = [category.aslink(noInterwiki = True) for category in categories]
if insite.category_on_one_line():
sep = ' '
else:
More information about the Pywikipedia-l
mailing list