Revision: 4556
Author: leogregianin
Date: 2007-11-15 13:33:42 +0000 (Thu, 15 Nov 2007)
Log Message:
-----------
using -top if you want moving {{Link FA|lang}} to top of interwiki.
DEFAULT: placing {{Link FA|lang}} right next to corresponding interwiki.
Fixed bug 1588728 {{link FA|xx}} are beeing moved away from the interwiki
Modified Paths:
--------------
trunk/pywikipedia/featured.py
Modified: trunk/pywikipedia/featured.py
===================================================================
--- trunk/pywikipedia/featured.py 2007-11-15 11:31:02 UTC (rev 4555)
+++ trunk/pywikipedia/featured.py 2007-11-15 13:33:42 UTC (rev 4556)
@@ -14,8 +14,11 @@
* -after:zzzz : process pages after and including page zzzz
-usage: featured.py [-interactive] [-nocache] [-after:zzzz] [-fromlang:xx,yy,zz|-fromall]
+* -top : using -top if you want moving {{Link FA|lang}} to top of interwiki.
+ DEFAULT: placing {{Link FA|lang}} right next to corresponding interwiki.
+usage: featured.py [-interactive] [-nocache] [-top] [-after:zzzz] [-fromlang:xx,yy,zz|-fromall]
+
"""
__version__ = '$Id$'
@@ -229,7 +232,7 @@
wikipedia.output(u"back interwiki ref target is "+backpage.title())
return None
-def featuredWithInterwiki(fromsite, tosite):
+def featuredWithInterwiki(fromsite, tosite, template_on_top):
if not fromsite.lang in cache:
cache[fromsite.lang]={}
if not tosite.lang in cache[fromsite.lang]:
@@ -277,14 +280,16 @@
continue
comment = wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg) % (fromsite.lang, a.title()))
- # TODO: create commandline for this
+ ### Moving {{Link FA|xx}} to top of interwikis ###
+ if template_on_top == True:
+ text=wikipedia.replaceCategoryLinks(text+(u"{{%s|%s}}"%(findtemplate, fromsite.lang)), atrans.categories())
+
### Placing {{Link FA|xx}} right next to corresponding interwiki ###
- text=(text[:m.end()]
- + (u" {{%s|%s}}" % (findtemplate, fromsite.lang))
- + text[m.end():])
- ### Moving {{Link FA|xx}} to top of interwikis ###
- # text=wikipedia.replaceCategoryLinks(text+(u"{{%s|%s}}"%(findtemplate, fromsite.lang)), atrans.categories())
-
+ else:
+ text=(text[:m.end()]
+ + (u" {{%s|%s}}" % (findtemplate, fromsite.lang))
+ + text[m.end():])
+
try:
atrans.put(text, comment)
except wikipedia.LockedPage:
@@ -295,7 +300,7 @@
wikipedia.output(u"Page not saved")
if __name__=="__main__":
-
+ template_on_top = False
fromlang=[]
for arg in wikipedia.handleArgs():
if arg == '-interactive':
@@ -316,7 +321,9 @@
fromlang=featured_name.keys()
elif arg.startswith('-after:'):
afterpage=arg[7:]
-
+ elif arg == '-top':
+ template_on_top = True
+
if not fromlang:
wikipedia.showHelp('featured')
sys.exit(1)
@@ -326,7 +333,7 @@
for ll in fromlang:
fromsite=wikipedia.Site(ll)
if not fromsite==wikipedia.getSite():
- featuredWithInterwiki(fromsite, wikipedia.getSite())
+ featuredWithInterwiki(fromsite, wikipedia.getSite(), template_on_top)
finally:
wikipedia.stopme()
if not nocache: