Revision: 4045
Author: russblau
Date: 2007-08-15 13:19:02 +0000 (Wed, 15 Aug 2007)
Log Message:
-----------
Break long lines, translate bot prompts into English :)
Modified Paths:
--------------
trunk/pywikipedia/capitalize_redirects.py
Modified: trunk/pywikipedia/capitalize_redirects.py
===================================================================
--- trunk/pywikipedia/capitalize_redirects.py 2007-08-15 12:56:24 UTC (rev 4044)
+++ trunk/pywikipedia/capitalize_redirects.py 2007-08-15 13:19:02 UTC (rev 4045)
@@ -5,34 +5,29 @@
Command-line arguments:
- -file Work on all pages listed in a text file.
- Argument can also be given as "-file:filename".
+ -file Work on all pages listed in a text file.
+ Argument can also be given as "-file:filename".
- -cat Work on all pages which are in a specific category.
- Argument can also be given as "-cat:categoryname".
+ -cat Work on all pages which are in a specific category.
+ Argument can also be given as "-cat:categoryname".
- -ref Work on all pages that link to a certain page.
- Argument can also be given as "-ref:referredpagetitle".
+ -ref Work on all pages that link to a certain page.
+ Argument can also be given as "-ref:referredpagetitle".
- -links Work on all pages that are linked from a certain page.
- Argument can also be given as "-link:linkingpagetitle".
+ -links Work on all pages that are linked from a certain page.
+ Argument can also be given as "-link:linkingpagetitle".
- -start Work on all pages on the home wiki, starting at the named page.
+ -start Work on all pages on the home wiki, starting at the named
+ page.
- -page Work on a single page.
+ -page Work on a single page.
-
- -namespace Run over especific namespace.
- Argument can also be given as "-namespace:100".
+ -namespace Run over especific namespace.
+ Argument can also be given as "-namespace:100".
- -always Don't prompt to make changes, just do them.
+ -always Don't prompt to make changes, just do them.
-
-p.e.: "python capitalize_redirects.py -start:B -always"
-
-"""
-
-
+Example: "python capitalize_redirects.py -start:B -always"
'''
#
# (C) Yrithinnd
@@ -58,24 +53,31 @@
page_t = page.title()
# Show the title of the page we're working on.
# Highlight the title in purple.
- wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default}
<<<" % page_t)
+ wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default}
<<<"
+ % page_t)
if not page_t.exists():
- wikipedia.output(u'%s don\'t exist' % page_t.title())
+ wikipedia.output(u'%s doesn\'t exist' % page_t.title())
if not self.acceptall:
- choice = wikipedia.inputChoice(u'Do you want create
redirect?', ['Yes', 'No', 'All'], ['y', 'N',
'a'], 'N')
+ choice = wikipedia.inputChoice(
+ u'Do you want to create a redirect?',
+ ['Yes', 'No', 'All'], ['y',
'N', 'a'], 'N')
if choice in ['a', 'A']:
self.acceptall = True
if self.acceptall or choice in ['y', 'Y']:
try:
- wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg)
% page_t)
+ wikipedia.setAction(
+ wikipedia.translate(wikipedia.getSite(), msg)
+ % page_t)
np.put(u"#REDIRECT [[%s]]" % page_t)
print
except:
- wikipedia.output(u"An error occured. Retrying in 15
seconds...")
+ wikipedia.output(
+ u"An error occurred. Retrying in 15 seconds...")
time.sleep(15)
continue
else:
- wikipedia.output(u'%s already exist, skipping...\n' %
page_t.title())
+ wikipedia.output(u'%s already exists, skipping...\n'
+ % page_t.title())
def main():
gen = None
@@ -97,25 +99,29 @@
source = 'textfile'
elif arg.startswith('-cat'):
if len(arg) == 4:
- categoryname = wikipedia.input(u'Please enter the category
name:')
+ categoryname = wikipedia.input(
+ u'Please enter the category name:')
else:
categoryname = arg[5:]
source = 'category'
elif arg.startswith('-page'):
if len(arg) == 5:
- pageNames.append(wikipedia.input(u'Which page do you want to
chage?'))
+ pageNames.append(wikipedia.input(
+ u'Which page do you want to change?'))
else:
pageNames.append(arg[6:])
source = 'singlepage'
elif arg.startswith('-ref'):
if len(arg) == 4:
- referredPageName = wikipedia.input(u'Links to which page should be
processed?')
+ referredPageName = wikipedia.input(
+ u'Links to which page should be processed?')
else:
referredPageName = arg[5:]
source = 'ref'
elif arg.startswith('-start'):
if len(arg) == 6:
- firstPageTitle = wikipedia.input(u'Which page do you want to
chage?')
+ firstPageTitle = wikipedia.input(
+ u'Which page do you want to change?')
else:
firstPageTitle = arg[7:]
source = 'allpages'
@@ -132,10 +138,12 @@
cat = catlib.Category(wikipedia.getSite(), categoryname)
gen = pagegenerators.CategorizedPageGenerator(cat)
elif source == 'singlepage':
- pages = [wikipedia.Page(wikipedia.getSite(), pageName) for pageName in
pageNames]
+ pages = [wikipedia.Page(wikipedia.getSite(), pageName)
+ for pageName in pageNames]
gen = iter(pages)
elif source == 'allpages':
- namespace = wikipedia.Page(wikipedia.getSite(), firstPageTitle).namespace()
+ namespace = wikipedia.Page(wikipedia.getSite(),
+ firstPageTitle).namespace()
gen = pagegenerators.AllpagesPageGenerator(firstPageTitle, namespace)
elif source == 'ref':
referredPage = wikipedia.Page(wikipedia.getSite(), referredPageName)
Show replies by date