[Pywikipedia-l] SVN: [4858] trunk/pywikipedia/wikipedia.py
rotem at svn.wikimedia.org
rotem at svn.wikimedia.org
Sat Jan 12 16:05:56 UTC 2008
Revision: 4858
Author: rotem
Date: 2008-01-12 16:05:55 +0000 (Sat, 12 Jan 2008)
Log Message:
-----------
(feature request 1867327) Adding support for [a]all option on deletion and protection (per site), and several fixes.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-12 15:39:27 UTC (rev 4857)
+++ trunk/pywikipedia/wikipedia.py 2008-01-12 16:05:55 UTC (rev 4858)
@@ -1940,8 +1940,11 @@
reason = input(u'Please enter a reason for the deletion:')
reason = reason.encode(self.site().encoding())
answer = 'y'
- if prompt:
- answer = inputChoice(u'Do you want to delete %s?' % self.aslink(forceInterwiki = True), ['Yes', 'No'], ['y', 'N'], 'N')
+ 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')
+ if answer in ['a', 'A']:
+ answer = 'y'
+ self.site()._noDeletePrompt = True
if answer in ['y', 'Y']:
host = self.site().hostname()
address = self.site().delete_address(self.urlname())
@@ -2079,7 +2082,6 @@
"""
if throttle:
put_throttle()
- output(u'Undeleting...')
address = self.site().undelete_address()
self.site().forceLogin(sysop = True)
@@ -2099,7 +2101,9 @@
self._deletedRevs = None
#TODO: Check for errors below (have we succeeded? etc):
- return self.site().postForm(address,formdata,sysop=True)
+ result = self.site().postForm(address,formdata,sysop=True)
+ output(u'Page %s undeleted' % self.aslink())
+ return result
def protect(self, edit='sysop', move='sysop', create='sysop', unprotect=False,
reason=None, prompt=True, throttle=True):
@@ -2119,11 +2123,14 @@
if throttle:
put_throttle()
if reason == None:
- reason = input(u'Please enter a reason for the (un)protection:')
+ reason = input(u'Please enter a reason for the change of the protection level:')
reason = reason.encode(self.site().encoding())
answer = 'y'
- if prompt:
- answer = inputChoice(u'Do you want to (un)protect %s?' % self.aslink(forceInterwiki = True), ['Yes', 'No'], ['y', 'N'], 'N')
+ if prompt and not hasattr(self.site(), '_noProtectPrompt'):
+ answer = inputChoice(u'Do you want to change the protection level of %s?' % self.aslink(forceInterwiki = True), ['Yes', 'No', 'All'], ['Y', 'N', 'A'], 'N')
+ if answer in ['a', 'A']:
+ answer = 'y'
+ self.site()._noProtectPrompt = True
if answer in ['y', 'Y']:
host = self.site().hostname()
@@ -2154,11 +2161,11 @@
data, response = self.site().postForm(address, predata, sysop = True)
if not response:
- output(u'Changed protection level of page %s.' % self)
+ output(u'Changed protection level of page %s.' % self.aslink())
return True
else:
#Normally, we expect a 302 with no data, so this means an error
- output(u'Failed to change protection level of page %s:' % self)
+ output(u'Failed to change protection level of page %s:' % self.aslink())
output(data)
return False
More information about the Pywikipedia-l
mailing list