[Pywikipedia-l] SVN: [6381] trunk/pywikipedia/interwiki.py

purodha at svn.wikimedia.org purodha at svn.wikimedia.org
Fri Feb 20 03:20:07 UTC 2009


Revision: 6381
Author:   purodha
Date:     2009-02-20 03:20:07 +0000 (Fri, 20 Feb 2009)

Log Message:
-----------
(Bug 1877143) Added possibility for adding a replacement at "namespace mismatch" message.

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

Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py	2009-02-20 02:37:42 UTC (rev 6380)
+++ trunk/pywikipedia/interwiki.py	2009-02-20 03:20:07 UTC (rev 6381)
@@ -691,12 +691,19 @@
                     wikipedia.output(u"NOTE: Ignoring link from page %s in namespace %i to page %s in namespace %i because page %s in the correct namespace has already been found." % (self.originPage.aslink(True), self.originPage.namespace(), linkedPage.aslink(True), linkedPage.namespace(), preferredPage.aslink(True)))
                     return True
                 else:
-                    choice = wikipedia.inputChoice('WARNING: %s is in namespace %i, but %s is in namespace %i. Follow it anyway?' % (self.originPage.aslink(True), self.originPage.namespace(), linkedPage.aslink(True), linkedPage.namespace()), ['Yes', 'No', 'give up'], ['y', 'n', 'g'])
+                    choice = wikipedia.inputChoice('WARNING: %s is in namespace %i, but %s is in namespace %i. Follow it anyway?' % (self.originPage.aslink(True), self.originPage.namespace(), linkedPage.aslink(True), linkedPage.namespace()), ['Yes', 'No', 'Add an alternative', 'give up'], ['y', 'n', 'a', 'g'])
                     if choice != 'y':
                         # Fill up foundIn, so that we will not ask again
                         self.foundIn[linkedPage] = [linkingPage]
                         if choice == 'g':
                             self.makeForcedStop(counter)
+                        elif choice == 'a':
+                            newHint = wikipedia.input(u'Give the alternative for language %s, not using a language code:' % linkedPage.site().language())
+                            if newHint:
+                                alternativePage = wikipedia.Page(linkedPage.site(), newHint)
+                                if alternativePage:
+                                    # add the page that was entered by the user
+                                    self.addIfNew(alternativePage, counter, None)
                         else:
                             wikipedia.output(u"NOTE: ignoring %s and its interwiki links" % linkedPage.aslink(True))
                         return True
@@ -1384,7 +1391,6 @@
             # Keep correct counters
             self.plus(site)
 
-#    def setPageGenerator(self, pageGenerator, number = None):
     def setPageGenerator(self, pageGenerator, number = None, until = None):
         """Add a generator of subjects. Once the list of subjects gets
            too small, this generator is called to produce more Pages"""





More information about the Pywikipedia-l mailing list