Exemple #1
0
 def workDone(self, counter):
     """This is called by a worker to tell us that the promised work
        was completed as far as possible. The only argument is an instance
        of a counter class, that has methods minus() and plus() to keep
        counts of the total work todo."""
     # Loop over all the pages that should have been taken care of
     for pl in self.pending:
         # Mark the page as done
         self.done[pl] = pl.code()
         # Register this fact at the todo-counter.
         counter.minus(pl.code())
         # Assume it's not a redirect
         isredirect = 0
         # Now check whether any interwiki links should be added to the
         # todo list.
         if unequal.bigger(self.inpl, pl):
             print "NOTE: %s is bigger than %s, not following references" % (pl, self.inpl)
         else:
             try:
                 iw = pl.interwiki()
             except wikipedia.IsRedirectPage,arg:
                 pl3 = wikipedia.PageLink(pl.code(),arg.args[0])
                 print "NOTE: %s is redirect to %s" % (pl.asasciilink(), pl3.asasciilink())
                 if pl == self.inpl:
                     # This is a redirect page itself. We don't need to
                     # follow the redirection.
                     isredirect = 1
                     # In this case we can also stop all hints!
                     for pl2 in self.todo:
                         counter.minus(pl2.code())
                     self.todo = {}
                     pass
                 elif not globalvar.followredirect:
                     print "NOTE: not following redirects."
                 elif unequal.unequal(self.inpl, pl3):
                     print "NOTE: %s is unequal to %s, not adding it" % (pl3, self.inpl)
                 else:
                     if self.conditionalAdd(pl3, counter):
                         if globalvar.shownew:
                             print "%s: %s gives new redirect %s"% (self.inpl.asasciiselflink(), pl.asasciilink(), pl3.asasciilink())
             except wikipedia.NoPage:
                 print "NOTE: %s does not exist" % pl.asasciilink()
                 #print "DBG> ",pl.urlname()
                 if pl == self.inpl:
                     # This is the home subject page.
                     # In this case we can stop all hints!
                     for pl2 in self.todo:
                         counter.minus(pl2.code())
                     self.todo = {}
                     pass
             except wikipedia.SubpageError:
                 print "NOTE: %s subpage does not exist" % pl.asasciilink()
Exemple #2
0
                 self.todo = {}
                 pass
         except wikipedia.SubpageError:
             print "NOTE: %s subpage does not exist" % pl.asasciilink()
         else:
             if self.inpl == pl:
                 self.untranslated = (len(iw) == 0)
                 if globalvar.untranslatedonly:
                     # Ignore the interwiki links.
                     iw = ()
             if pl.isEmpty():
                 print "NOTE: %s is empty; ignoring it and its interwiki links" % pl.asasciilink()
                 # Ignore the interwiki links
                 iw = ()
             for pl2 in iw:
               if unequal.unequal(self.inpl, pl2):
                   print "NOTE: %s is unequal to %s, not adding it" % (pl2, self.inpl)
               else:   
                   if self.conditionalAdd(pl2, counter):
                       if globalvar.shownew:
                           print "%s: %s gives new interwiki %s"% (self.inpl.asasciiselflink(), pl.asasciilink(), pl2.asasciilink())
                       
 # These pages are no longer 'in progress'
 del self.pending
 # Check whether we need hints and the user offered to give them
 if self.untranslated and not self.hintsasked:
     print "NOTE: %s does not have any interwiki links" % self.inpl.asasciilink()
 if (self.untranslated or globalvar.askhints) and not self.hintsasked and not isredirect:
     # Only once! 
     self.hintsasked = True
     if globalvar.untranslated: