[Pywikipedia-l] SVN: [4867] trunk/pywikipedia

rotem at svn.wikimedia.org rotem at svn.wikimedia.org
Sun Jan 13 16:57:32 UTC 2008


Revision: 4867
Author:   rotem
Date:     2008-01-13 16:57:32 +0000 (Sun, 13 Jan 2008)

Log Message:
-----------
(patch 1867322) If the user is not allowed to delete pages, optionally mark them for deletion instead. Implement this in CategoryMoveRobot (in category.py). The patch was slightly changed.

Modified Paths:
--------------
    trunk/pywikipedia/category.py
    trunk/pywikipedia/wikipedia.py

Modified: trunk/pywikipedia/category.py
===================================================================
--- trunk/pywikipedia/category.py	2008-01-13 16:41:52 UTC (rev 4866)
+++ trunk/pywikipedia/category.py	2008-01-13 16:57:32 UTC (rev 4867)
@@ -145,29 +145,29 @@
     }
 
 deletion_reason_move = {
-    'ar':u'روبوت: التصنيف نقل إلى [[تصنيف:%s|%s]]',
-    'da':u'Robot: Kategori flyttet til [[Category:%s|%s]]',
-    'de':u'Bot: Kategorie wurde nach [[Category:%s|%s]] verschoben',
-    'en':u'Robot: Category was moved to [[Category:%s|%s]]',
-    'fr':u'Robot : catégorie déplacée sur [[Category:%s|%s]]',
-    'he':u'בוט: הקטגוריה הועברה לשם [[קטגוריה:%s|%s]]',
-    'ia':u'Robot: Categoria transferite a [[Category:%s|%s]]',
-    'id':u'Bot: Kategori dipindahkan ke [[Category:%s|%s]]',
-    'it':u'Bot: La categoria è stata sostituita da [[Categoria:%s|%s]]',
-    'ja':u'ロボットによる: カテゴリ [[Category:%s]]へ移動',
-    'lt':u'robotas: Kategorija pervadinta į [[Category:%s|%s]]',
-    'kk':u'Бот: Санат [[Санат:%s|%s]] дегенге жылжытылды',
-    'ko': u'로봇: 분류가 [[분류:%s|%s]]로 옮겨짐',
-    'ksh':u'Bot: Saachjropp noh [[Category:%s|%s]] jeschovve',
-    'nds':u'Kat-Bot: Kategorie na [[Category:%s|%s]] schaven',
-    'nds-nl':u'Bot: kattegerie is herneumd naor [[Kattegerie:%s|%s]]',
-    'nl':u'Bot: Categorie is hernoemd naar [[Category:%s|%s]]',
-    'no':u'Robot: Kategorien ble flyttet til [[Category:%s|%s]]',
-    'pt':u'Bot: Categoria [[Category:%s|%s]] foi movida',
-    'pl':u'Robot przenosi kategorię do [[Category:%s|%s]]',
-    'sr':u'Бот: Категорија премештена у [[Category:%s|%s]]',
-    'sv':u'Robot: Kategori flyttades till [[Category:%s|%s]]',
-    'zh':u'機器人:正在移動目錄至 [[Category:%s]]',
+    'ar':u'روبوت: التصنيف نقل إلى [[:تصنيف:%s|%s]]',
+    'da':u'Robot: Kategori flyttet til [[:Category:%s|%s]]',
+    'de':u'Bot: Kategorie wurde nach [[:Category:%s|%s]] verschoben',
+    'en':u'Robot: Category was moved to [[:Category:%s|%s]]',
+    'fr':u'Robot : catégorie déplacée sur [[:Category:%s|%s]]',
+    'he':u'בוט: הקטגוריה הועברה לשם [[:קטגוריה:%s|%s]]',
+    'ia':u'Robot: Categoria transferite a [[:Category:%s|%s]]',
+    'id':u'Bot: Kategori dipindahkan ke [[:Category:%s|%s]]',
+    'it':u'Bot: La categoria è stata sostituita da [[:Categoria:%s|%s]]',
+    'ja':u'ロボットによる: カテゴリ [[:Category:%s]]へ移動',
+    'lt':u'robotas: Kategorija pervadinta į [[:Category:%s|%s]]',
+    'kk':u'Бот: Санат [[:Санат:%s|%s]] дегенге жылжытылды',
+    'ko': u'로봇: 분류가 [[:분류:%s|%s]]로 옮겨짐',
+    'ksh':u'Bot: Saachjropp noh [[:Category:%s|%s]] jeschovve',
+    'nds':u'Kat-Bot: Kategorie na [[:Category:%s|%s]] schaven',
+    'nds-nl':u'Bot: kattegerie is herneumd naor [[:Kattegerie:%s|%s]]',
+    'nl':u'Bot: Categorie is hernoemd naar [[:Category:%s|%s]]',
+    'no':u'Robot: Kategorien ble flyttet til [[:Category:%s|%s]]',
+    'pt':u'Bot: Categoria [[:Category:%s|%s]] foi movida',
+    'pl':u'Robot przenosi kategorię do [[:Category:%s|%s]]',
+    'sr':u'Бот: Категорија премештена у [[:Category:%s|%s]]',
+    'sv':u'Robot: Kategori flyttades till [[:Category:%s|%s]]',
+    'zh':u'機器人:正在移動目錄至 [[:Category:%s]]',
     }
 
 cfd_templates = {
@@ -405,9 +405,9 @@
             if self.oldCat.isEmpty():
                 reason = wikipedia.translate(wikipedia.getSite(), deletion_reason_move) % (self.newCatTitle, self.newCatTitle)
                 confirm = not self.batchMode
-                self.oldCat.delete(reason, confirm)
+                self.oldCat.delete(reason, confirm, mark = True)
                 if oldMovedTalk is not None:
-                    oldMovedTalk.delete(reason, confirm)
+                    oldMovedTalk.delete(reason, confirm, mark = True)
             else:
                 wikipedia.output('Couldn\'t delete %s - not empty.' % self.oldCat.title())
 

Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py	2008-01-13 16:41:52 UTC (rev 4866)
+++ trunk/pywikipedia/wikipedia.py	2008-01-13 16:57:32 UTC (rev 4867)
@@ -1926,19 +1926,20 @@
                 output(data)
                 return False
 
-    def delete(self, reason=None, prompt=True, throttle=True):
+    def delete(self, reason=None, prompt=True, throttle=True, mark=False):
         """Deletes the page from the wiki.
 
         Requires administrator status. If reason is None, asks for a
         reason. If prompt is True, asks the user if he wants to delete the
         page.
-        
+
+        If the user does not have admin rights and mark is True,
+        the page is marked for deletion instead.
         """
         if throttle:
             put_throttle()
         if reason == None:
             reason = input(u'Please enter a reason for the deletion:')
-        reason = reason.encode(self.site().encoding())
         answer = 'y'
         if prompt and not hasattr(self.site(), '_noDeletePrompt'):
             answer = inputChoice(u'Do you want to delete %s?' % self.aslink(forceInterwiki = True), ['Yes', 'No', 'All'], ['Y', 'N', 'A'], 'N')
@@ -1954,7 +1955,12 @@
             except NoUsername, error:
                 # user hasn't entered an admin username.
                 output(str(error))
+                if markfordeletion and self.exists():
+                    text = self.get(get_redirect = True)
+                    output(u'Marking the page for deletion instead:')
+                    self.put(u'{{delete}}\n%s\n----\n\n%s' % (reason, text), comment = reason)
                 return
+            reason = reason.encode(self.site().encoding())
             token = self.site().getToken(self, sysop = True)
             predata = {
                 'wpReason': reason,





More information about the Pywikipedia-l mailing list