Архайæг:IronBot/Year Code
The code IronBot used to create years at os-wiki ивын
Must have a template for the years-table. See Template:Азтæ.
!Delete the leading spaces in every line!
# -*- coding: utf-8 -*-
import sys, re, math, formatter import wikipedia, config, catlib
def int_to_roman(input): if type(input) != type(1): raise TypeError, "expected integer, got %s" % type(input) if not 0 < input < 4000: raise ValueError, "Argument must be between 1 and 3999" ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1) nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I') result = "" for i in range(len(ints)): count = int(input / ints[i]) result += nums[i] * count input -= ints[i] * count return result
mysite = wikipedia.getSite()
for i in range(1932, 2010): print i dcd = int(math.floor(i/10)*10) cnt = int(math.floor((i-1)/100)+1) pl = wikipedia.PageLink(mysite, str(i)) #s = pl.get() if (not pl.exists()): s = u"{{Азтæ|"+str(i-4)+u"|"+str(i-3)+u"|"+str(i-2)+u"|"+str(i-1)+u"|"+str(i)+u"|"+str(i+1)+u"|"+str(i+2)+u"|"+str(i+3)+u"|"+str(i+4)+u"|"+str(dcd-30)+u"|"+str(dcd-20)+u"|"+str(dcd-10)+u"|"+str(dcd)+u"|"+str(dcd+10)+u"|"+str(dcd+20)+u"|"+str(dcd+30)+u"|"+int_to_roman(cnt-1)+u" æнус|"+int_to_roman(cnt)+u" æнус|"+int_to_roman(cnt+1)+u" æнус}}\n\ \n\ ==Цаутæ==\n\ * \n\ ==Райгуырдысты==\n\ * \n\ ==Амардысты==\n\ * \n\ {{year-stub}}\n\ \n\ [[Category:"+str(i)+u"]]\n\ \n\ [[bg:"+str(i)+u"]]\n\ [[en:"+str(i)+u"]]\n\ [[eo:"+str(i)+u"]]\n\ [[fr:"+str(i)+u"]]\n\ [[ru:"+str(i)+u"]]\n\ [[zh:"+str(i)+u"年]]"; pl.put(s, 'Robot: add year') yct = catlib.CatLink(wikipedia.getSite(), str(i)) if (not yct.exists()): syct = u'[[Category:'+int_to_roman(cnt)+u" æнус]]\n\ [[ru:Category:"+str(i)+u"]]"; yct.put(syct, u'Robot: Create year category')