[Pywikipedia-l] SVN: [4912] trunk/pywikipedia/catlib.py

russblau at svn.wikimedia.org russblau at svn.wikimedia.org
Fri Jan 18 15:34:48 UTC 2008


Revision: 4912
Author:   russblau
Date:     2008-01-18 15:34:48 +0000 (Fri, 18 Jan 2008)

Log Message:
-----------
changes to aslink() to conform to Page interface, and eliminate sortkeys from interwiki links to categories.

Modified Paths:
--------------
    trunk/pywikipedia/catlib.py

Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py	2008-01-18 13:08:55 UTC (rev 4911)
+++ trunk/pywikipedia/catlib.py	2008-01-18 15:34:48 UTC (rev 4912)
@@ -67,20 +67,27 @@
         self.articleCache = []
         self.subcatCache = []
 
-    def aslink(self, forceInterwiki = False, noInterwiki = False):
+    def aslink(self, forceInterwiki=False, textlink=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.
+        
         """
-        A string representation in the form of a link. This method is different
-        from Page.aslink() as the sortkey may have to be included.
-        """
         if self.sortKey:
             titleWithSortKey = '%s|%s' % (self.title(), self.sortKey)
         else:
             titleWithSortKey = self.title()
-        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)
+        if not noInterwiki and (forceInterwiki
+                                or self.site() != wikipedia.getSite()):
+            if self.site().family != wikipedia.getSite().family \
+                    and self.site().family.name != self.site().lang:
+                return '[[%s:%s:%s]]' % (self.site().family.name,
+                                         self.site().lang, self.title())
             else:
-                return '[[%s:%s]]' % (self.site().lang, titleWithSortKey)
+                return '[[%s:%s]]' % (self.site().lang, self.title())
+        elif textlink:
+            return '[[:%s]]' % self.title()
         else:
             return '[[%s]]' % titleWithSortKey
 





More information about the Pywikipedia-l mailing list