Styleguide/Scripts: Difference between revisions

Content deleted Content added
Cbarr (talk | contribs)
Created page with "=="Form-countryspecific-*" creating script== <syntaxhighlight lang="python"> import wikipedia wiki = wikipedia site = wiki.getSite('en', 'wikidonate') basetitle = 'Template..."
 
Cbarr (talk | contribs)
No edit summary
Line 1:
==Introduction==
=="Form-countryspecific-*" creating script==
<syntaxhighlight lang="python">
Line 704 ⟶ 705:
wikipedia.stopme()
 
</syntaxhighlight>
 
=="Form-countryspecific-*" Mining script==
<syntaxhighlight lang="python">
import wikipedia
import datetime
wiki = wikipedia
site = wiki.getSite('en', 'wikidonate')
 
basetitle = 'Template:2012FR/Form-countryspecific-control'
editsummary = 'Updating localized landing page via python script.'
overwrite = True # overwrite a page if it already exists? True/False (must be capitalised)
paymentProcessing={
'':['GC'],
'/USD':['GC'],
'/EUR':['GC'],
'/XX':['GC'],
'/AE':['GC'],
'/AN':['GC'],
'/AR':['GC'],
'/PG':['GC'],
'/KI':['GC'],
'/NR':['GC'],
'/VU':['GC'],
'/AU':['GC'],
'/BD':['GC'],
'/BG':['GC'],
'/BH':['GC'],
'/BM':['GC'],
'/BO':['GC'],
'/BR':['GC'],
'/BZ':['GC'],
'/CA':['GC'],
'/LI':['GC'],
'/CH':['GC'],
'/CL':['GC'],
'/CN':['GC'],
'/CO':['GC'],
'/CR':['GC'],
'/CZ':['GC'],
'/DK':['GC'],
'/DO':['GC'],
'/DZ':['GC'],
'/EG':['GC'],
'/MW':['GC'],
'/SD':['GC'],
'/GB':['GC'],
'/GT':['GC'],
'/HK':['GC'],
'/HN':['GC'],
'/HR':['GC'],
'/HU':['GC'],
'/ID':['GC'],
'/IL':['GC'],
'/NP':['GC'],
'/IN':['GC'],
'/JM':['GC'],
'/JO':['GC'],
'/JP':['GC'],
'/KE':['GC'],
'/KR':['GC'],
'/KW':['GC'],
'/KZ':['GC'],
'/LB':['GC'],
'/LK':['GC'],
'/LT':['GC'],
'/LV':['GC'],
'/MA':['GC'],
'/MK':['GC'],
'/MO':['GC'],
'/MU':['GC'],
'/MX':['GC'],
'/MY':['GC'],
'/NI':['GC'],
'/NO':['GC'],
'/NZ':['GC'],
'/OM':['GC'],
'/PA':['GC'],
'/PE':['GC'],
'/PH':['GC'],
'/PK':['GC'],
'/PL':['GC'],
'/PY':['GC'],
'/QA':['GC'],
'/RO':['GC'],
'/TM':['GC'],
'/UZ':['GC'],
'/RU':['GC'],
'/SA':['GC'],
'/SE':['GC'],
'/SG':['GC'],
'/SV':['GC'],
'/TH':['GC'],
'/TN':['GC'],
'/TR':['GC'],
'/TT':['GC'],
'/TW':['GC'],
'/UA':['GC'],
'/UY':['GC'],
'/VN':['GC'],
'/DM':['GC'],
'/ZA':['GC'],
'/PR':['GC'],
'/AF':['GC'],
'/AS':['GC'],
'/AO':['GC'],
'/AG':['GC'],
'/BS':['GC'],
'/BB':['GC'],
'/BW':['GC'],
'/BN':['GC'],
'/BI':['GC'],
'/KH':['GC'],
'/KM':['GC'],
'/CG':['GC'],
'/CK':['GC'],
'/DJ':['GC'],
'/TP':['GC'],
'/ER':['GC'],
'/ET':['GC'],
'/FJ':['GC'],
'/GM':['GC'],
'/GE':['GC'],
'/GD':['GC'],
'/GQ':['GC'],
'/GU':['GC'],
'/GW':['GC'],
'/IS':['GC'],
'/IQ':['GC'],
'/KP':['GC'],
'/LR':['GC'],
'/MV':['GC'],
'/MH':['GC'],
'/MR':['GC'],
'/FM':['GC'],
'/MD':['GC'],
'/MZ':['GC'],
'/NA':['GC'],
'/NG':['GC'],
'/MP':['GC'],
'/PW':['GC'],
'/PS':['GC'],
'/KN':['GC'],
'/LC':['GC'],
'/SB':['GC'],
'/VC':['GC'],
'/TZ':['GC'],
'/TO':['GC'],
'/VE':['GC'],
'/VI':['GC'],
'/YE':['GC'],
'/ZM':['GC'],
'/ZW':['GC'],
'/US':['GC'],
'/EC':['GC'],
'/RS':['GC'],
'/AL':['GC'],
'/AD':['GC'],
'/CY':['GC'],
'/LU':['GC'],
'/MT':['GC'],
'/GF':['GC'],
'/AM':['GC'],
'/AW':['GC'],
'/AZ':['GC'],
'/BY':['GC'],
'/BJ':['GC'],
'/BA':['GC'],
'/BF':['GC'],
'/CM':['GC'],
'/CV':['GC'],
'/CF':['GC'],
'/TD':['GC'],
'/CI':['GC'],
'/FO':['GC'],
'/GA':['GC'],
'/GL':['GC'],
'/LY':['GC'],
'/MG':['GC'],
'/ML':['GC'],
'/MC':['GC'],
'/ME':['GC'],
'/NE':['GC'],
'/RE':['GC'],
'/SM':['GC'],
'/SN':['GC'],
'/SC':['GC'],
'/SR':['GC'],
'/TG':['GC'],
'/VA':['GC'],
'/DE':['GC'],
'/FR':['GC'],
'/NL':['GC'],
'/AT':['GC'],
'/IT':['GC'],
'/ES':['GC'],
'/BE':['GC'],
'/FI':['GC'],
'/IE':['GC'],
'/GR':['GC'],
'/PT':['GC'],
'/SK':['GC'],
'/SI':['GC'],
'/EE':['GC']
}
 
def main():
now = datetime.datetime.now()
fout = open("control-" + now.strftime("%Y-%m-%d@%H:%M:%S") + ".txt", "w")
 
values = ''
for country, amounts in paymentProcessing.iteritems():
oldpage = wiki.Page(site, basetitle + country)
oldcontent = oldpage.get()
lines = oldcontent.split('\n')
 
j=0
values = values + '\'' + country + '\':['
for i, x in enumerate(lines):
if lines[i].find('| donate-amount-') != -1:
values = values + (lines[i].strip('| donate-amount-'))[4:] + ','
j=j+1
values = values + '],\n'
values = values.replace(',]',']')
values = values[:-2]
fout.write(values)
 
if __name__ == '__main__':
try:
main()
finally:
wikipedia.stopme()
</syntaxhighlight>