http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9302
Revision: 9302
Author: xqt
Date: 2011-06-21 13:32:21 +0000 (Tue, 21 Jun 2011)
Log Message:
-----------
Update from trunk, translations for fa-wiki
Modified Paths:
--------------
branches/rewrite/scripts/template.py
Modified: branches/rewrite/scripts/template.py
===================================================================
--- branches/rewrite/scripts/template.py 2011-06-21 13:31:15 UTC (rev 9301)
+++ branches/rewrite/scripts/template.py 2011-06-21 13:32:21 UTC (rev 9302)
@@ -13,25 +13,27 @@
-remove Remove every occurence of the template from every article
--subst Resolves the template by putting its text directly into the article.
- This is done by changing {{...}} or {{msg:...}} into {{subst:...}}
+-subst Resolves the template by putting its text directly into the
+ article. This is done by changing {{...}} or {{msg:...}} into
+ {{subst:...}}
--xml retrieve information from a local dump (http://download.wikimedia.org).
- if this argument isn\'t given, info will be loaded from the maintenance
- page of the live wiki.
+-xml retrieve information from a local dump
+ (http://download.wikimedia.org). If this argument isn\'t given,
+ info will be loaded from the maintenance page of the live wiki.
argument can also be given as "-xml:filename.xml".
-namespace: Only process templates in the given namespace number (may be used
multiple times).
--summary: Lets you pick a custom edit summary. Use quotes if edit summary contains
- spaces.
+-summary: Lets you pick a custom edit summary. Use quotes if edit summary
+ contains spaces.
-always Don't bother asking to confirm any of the changes, Just Do It.
--category: Appends the given category to every page that is edited. This is useful when
- a category is being broken out from a template parameter or when templates are
- being upmerged but more information must be preserved.
+-category: Appends the given category to every page that is edited. This is
+ useful when a category is being broken out from a template
+ parameter or when templates are being upmerged but more information
+ must be preserved.
other: First argument is the old template name, second one is the new
name.
@@ -49,25 +51,26 @@
Move the page [[Template:Cities in Washington]] manually afterwards.
-If you have a template called [[Template:test]] and want to substitute it only on pages
-in the User: and User talk: namespaces, do:
+If you have a template called [[Template:test]] and want to substitute it only
+on pages in the User: and User talk: namespaces, do:
python template.py test -namespace:2 -namespace:3
-Note that, on the English Wikipedia, User: is namespace 2 and User talk: is namespace 3.
-This may differ on other projects so make sure to find out the appropriate namespace numbers.
+Note that, on the English Wikipedia, User: is namespace 2 and User talk: is
+namespace 3. This may differ on other projects so make sure to find out the
+appropriate namespace numbers.
-This next example substitutes the template lived with a supplied edit summary. It only
-performs substitutions in main article namespace and doesn't prompt to start replacing.
-Note that -putthrottle: is a global pywikipedia parameter.
+This next example substitutes the template lived with a supplied edit summary.
+It only performs substitutions in main article namespace and doesn't prompt to
+start replacing. Note that -putthrottle: is a global pywikipedia parameter.
python template.py -putthrottle:30 -namespace:0 lived -always
-summary:"ROBOT: Substituting {{lived}}, see [[WP:SUBST]]."
-This next example removes the templates {{cfr}}, {{cfru}}, and {{cfr-speedy}} from five
-category pages as given:
+This next example removes the templates {{cfr}}, {{cfru}}, and {{cfr-speedy}}
+from five category pages as given:
python template.py cfr cfru cfr-speedy -remove -always
-page:"Category:Mountain monuments and memorials" -page:"Category:Indian family names"
@@ -76,7 +79,8 @@
-summary:"Removing Cfd templates from category pages that survived."
-This next example substitutes templates test1, test2, and space test on all pages:
+This next example substitutes templates test1, test2, and space test on all
+pages:
python template.py test1 test2 "space test" -subst -always
@@ -89,11 +93,12 @@
#
__version__='$Id$'
#
+import re, sys, string
import pywikibot
from pywikibot import config, pagegenerators, catlib
from scripts import replace
-import re, sys, string
+
class XmlDumpTemplatePageGenerator:
"""
Generator which will yield Pages to pages that might contain the chosen
@@ -149,7 +154,7 @@
'de':u'Bot: Ändere Vorlage: %s',
'en':u'Robot: Changing template: %s',
'es':u'Robot: Cambiada la plantilla: %s',
- 'fa':u'ربات:تعییر تلگو: %s',
+ 'fa':u'ربات:تغییر الگو: %s',
'fi':u'Botti korvasi mallineen: %s',
'fr':u'Robot : Change modèle: %s',
'he':u'בוט: משנה תבנית: %s',
@@ -252,7 +257,7 @@
'de':u'Bot: Umgehe Vorlage: %s',
'en':u'Robot: Substituting template: %s',
'es':u'Robot: Sustituyendo la plantilla: %s',
- 'fa':u'ربات:استفاده از دستور جا: برای الگو: %s',
+ 'fa':u'ربات: جایگزینی الگو: %s',
'fi':u'Botti substasi mallineen: %s',
'fr':u'Robot : Remplace modèle : %s',
'he':u'בוט: מכליל תבנית בקוד הדף: %s',
@@ -275,7 +280,7 @@
'de':u'Bot: Umgehe Vorlagen: %s',
'en':u'Robot: Substituting templates: %s',
'es':u'Robot: Sustituyendo las plantillas: %s',
- 'fa':u'ربات:استفاده از دستور جا: برای الگوهای : %s',
+ 'fa':u'ربات: جایگزینی الگوها: %s',
'fi':u'Botti substasi mallineet: %s',
'fr':u'Robot : Remplace modèles : %s',
'he':u'בוט: מכליל תבניות בקוד הדף: %s',
@@ -401,6 +406,8 @@
remove = True
elif arg == '-subst':
subst = True
+ elif arg == ('-always'):
+ acceptAll = True
elif arg.startswith('-xml'):
if len(arg) == 4:
xmlfilename = pywikibot.input(u'Please enter the XML dump\'s filename: ')
@@ -415,8 +422,6 @@
addedCat = arg[len('-category:'):]
elif arg.startswith('-summary:'):
editSummary = arg[len('-summary:'):]
- elif arg.startswith('-always'):
- acceptAll = True
else:
if not genFactory.handleArg(arg):
templateNames.append(
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9301
Revision: 9301
Author: xqt
Date: 2011-06-21 13:31:15 +0000 (Tue, 21 Jun 2011)
Log Message:
-----------
Limit help text to 80 col. Some updates from rewrite.
Modified Paths:
--------------
trunk/pywikipedia/template.py
Modified: trunk/pywikipedia/template.py
===================================================================
--- trunk/pywikipedia/template.py 2011-06-18 23:51:32 UTC (rev 9300)
+++ trunk/pywikipedia/template.py 2011-06-21 13:31:15 UTC (rev 9301)
@@ -13,12 +13,13 @@
-remove Remove every occurence of the template from every article
--subst Resolves the template by putting its text directly into the article.
- This is done by changing {{...}} or {{msg:...}} into {{subst:...}}
+-subst Resolves the template by putting its text directly into the
+ article. This is done by changing {{...}} or {{msg:...}} into
+ {{subst:...}}
--xml retrieve information from a local dump (http://download.wikimedia.org).
- if this argument isn\'t given, info will be loaded from the maintenance
- page of the live wiki.
+-xml retrieve information from a local dump
+ (http://download.wikimedia.org). If this argument isn\'t given,
+ info will be loaded from the maintenance page of the live wiki.
argument can also be given as "-xml:filename.xml".
-namespace: Only process templates in the given namespace number (may be used
@@ -34,14 +35,15 @@
If this parameter is missed, all edits are checked but this is
restricted to the last 100 edits.
--summary: Lets you pick a custom edit summary. Use quotes if edit summary contains
- spaces.
+-summary: Lets you pick a custom edit summary. Use quotes if edit summary
+ contains spaces.
-always Don't bother asking to confirm any of the changes, Just Do It.
--category: Appends the given category to every page that is edited. This is useful when
- a category is being broken out from a template parameter or when templates are
- being upmerged but more information must be preserved.
+-category: Appends the given category to every page that is edited. This is
+ useful when a category is being broken out from a template
+ parameter or when templates are being upmerged but more information
+ must be preserved.
other: First argument is the old template name, second one is the new
name.
@@ -59,25 +61,26 @@
Move the page [[Template:Cities in Washington]] manually afterwards.
-If you have a template called [[Template:test]] and want to substitute it only on pages
-in the User: and User talk: namespaces, do:
+If you have a template called [[Template:test]] and want to substitute it only
+on pages in the User: and User talk: namespaces, do:
python template.py test -namespace:2 -namespace:3
-Note that, on the English Wikipedia, User: is namespace 2 and User talk: is namespace 3.
-This may differ on other projects so make sure to find out the appropriate namespace numbers.
+Note that, on the English Wikipedia, User: is namespace 2 and User talk: is
+namespace 3. This may differ on other projects so make sure to find out the
+appropriate namespace numbers.
-This next example substitutes the template lived with a supplied edit summary. It only
-performs substitutions in main article namespace and doesn't prompt to start replacing.
-Note that -putthrottle: is a global pywikipedia parameter.
+This next example substitutes the template lived with a supplied edit summary.
+It only performs substitutions in main article namespace and doesn't prompt to
+start replacing. Note that -putthrottle: is a global pywikipedia parameter.
python template.py -putthrottle:30 -namespace:0 lived -always
-summary:"ROBOT: Substituting {{lived}}, see [[WP:SUBST]]."
-This next example removes the templates {{cfr}}, {{cfru}}, and {{cfr-speedy}} from five
-category pages as given:
+This next example removes the templates {{cfr}}, {{cfru}}, and {{cfr-speedy}}
+from five category pages as given:
python template.py cfr cfru cfr-speedy -remove -always
-page:"Category:Mountain monuments and memorials" -page:"Category:Indian family names"
@@ -86,7 +89,8 @@
-summary:"Removing Cfd templates from category pages that survived."
-This next example substitutes templates test1, test2, and space test on all pages:
+This next example substitutes templates test1, test2, and space test on all
+pages:
python template.py test1 test2 "space test" -subst -always
@@ -99,10 +103,10 @@
#
__version__='$Id$'
#
+import re, sys, string
import wikipedia as pywikibot
-import config
-import replace, pagegenerators
-import re, sys, string, catlib
+import config, pagegenerators, catlib
+import replace
def UserEditFilterGenerator(generator, username, timestamp=None, skip=False):
"""
@@ -330,8 +334,8 @@
'zh':u'機器人: 更換模板 %s',
}
- def __init__(self, generator, templates, subst = False, remove = False, editSummary = '',
- acceptAll = False, addedCat = None):
+ def __init__(self, generator, templates, subst = False, remove = False,
+ editSummary = '', acceptAll = False, addedCat = None):
"""
Arguments:
* generator - A page generator.
@@ -408,7 +412,7 @@
replaceBot = replace.ReplaceRobot(self.generator, replacements, exceptions, acceptall = self.acceptAll, addedCat=self.addedCat, editSummary=self.editSummary)
replaceBot.run()
-def main():
+def main(*args):
templateNames = []
templates = {}
subst = False
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9298
Revision: 9298
Author: xqt
Date: 2011-06-14 10:37:46 +0000 (Tue, 14 Jun 2011)
Log Message:
-----------
stripped trailing white space, some cosmetics
Modified Paths:
--------------
trunk/pywikipedia/create_categories.py
Modified: trunk/pywikipedia/create_categories.py
===================================================================
--- trunk/pywikipedia/create_categories.py 2011-06-14 10:27:11 UTC (rev 9297)
+++ trunk/pywikipedia/create_categories.py 2011-06-14 10:37:46 UTC (rev 9298)
@@ -2,11 +2,12 @@
"""
Program to batch create categories.
-The program expects a generator containing a list of page titles to be used as base.
+The program expects a generator containing a list of page titles to be used as
+base.
The following command line parameters are supported:
--alway (not implemented yet) Don't ask, just do the edit.
+-always (not implemented yet) Don't ask, just do the edit.
-overwrite (not implemented yet).
@@ -61,8 +62,8 @@
else:
#FIXME: Add overwrite option
pywikibot.output(u'%s already exists, skipping' % (newpage.title(),))
-
+
def main(args):
'''
Main loop. Get a generator and options.
@@ -71,7 +72,7 @@
parent = u''
basename = u''
always = False
-
+
genFactory = pagegenerators.GeneratorFactory()
for arg in pywikibot.handleArgs():
@@ -90,7 +91,7 @@
createCategory(page, parent, basename)
else:
pywikibot.output(u'No pages to work on')
-
+
pywikibot.output(u'All done')
if __name__ == "__main__":