# Conjdata module
from general import *
from string import *
site = getSite(language, family)
config.put_throttle = 1
put_throttle.setDelay()
list_ar = ;
list_er = ;
list_ir = ;
def upload(list, stem):
mypage = 'User:QuasiBot/log'
page = Page(site, mypage)
text = page.get()
newtext = text
logmessage1 = u"<br>{{subst:User:QuasiBot/TimeStamp}}"
logmessage2 = u": upload({0}, {1})"
logmessage2 = logmessage2.format(list, stem, re.UNICODE)
logmessage1 += logmessage2
newtext += u"\n%s" % logmessage1
showDiff(text, newtext)
choice = inputChoice(u'Do you want to accept these changes?', , , 'N')
if choice == 'n':
return False
#page.put(newtext, 'Bot: adding log entry.')
preload = '{{subst:ia-verb-entry-form|' + stem + '|{0}}}'
insertiontext = '{{subst:ia-verb-entry-form|' + stem + '|{0}}}'
# autosummary = 'preloading ' + preload + ' with Python/pywikibot'
autominor = True
pageexists =
for ending in list:
mypreload = '{' + preload.format(ending) + '}'
myinsertiontext = '{' + insertiontext.format(ending) + '}'
title_ending = ending
if ending == 'ite':
title_ending = 'ite'
mypage = stem + title_ending
page = Page(site, mypage)
try:
print('Page title is: '+mypage)
pagetext = page.get()
print('--------------')
print('\nPage content is:\n\n'+pagetext)
# pageexists.append(mypage)
newpagetext = ''
overlang = ''
# search for over-language
if find(pagetext, '==Corsican==') > -1:
overlang = '\n'
cond = (mypage == 'a' and title_ending == 'a') or (mypage == 'ava') or (mypage == 'ara')
cond = cond or (mypage == 'ante') or (mypage == 'ate') or (mypage == 'e' and title_ending == 'e')
cond = cond or (mypage == 'eva') or (mypage == 'era') or (mypage == 'ente')
cond = cond or (mypage == 'ite') or (mypage == 'i') or (mypage == 'iva')
cond = cond or (mypage == 'ira') or (mypage == 'iente')
dont_edit = 0
if (cond):
if find(pagetext, '==Interlingua==') > -1:
print "There is an Interlingua entry already!"
dont_edit = 1
pageexists.append(mypage)
elif find(pagetext, '==Italian==') > -1:
newpagetext = replace(pagetext, '==Italian==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Italian==')
elif find(pagetext, '==Latin==') > -1:
newpagetext = replace(pagetext, '==Latin==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Latin==')
elif find(pagetext, '==Romanian==') > -1:
newpagetext = replace(pagetext, '==Romanian==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Romanian==')
elif find(pagetext, '==Spanish==') > -1:
newpagetext = replace(pagetext, '==Spanish==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Spanish==')
elif find(pagetext, '==Swedish==') > -1:
newpagetext = replace(pagetext, '==Swedish==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Swedish==')
elif find(pagetext, '==Portuguese==') > -1:
newpagetext = replace(pagetext, '==Portuguese==', overlang+'{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n----\n\n==Portuguese==')
else:
print "WARNING: No under-language found!"
# search for under-interwiki links here
if find(pagetext, '[[ru:') > -1:
newpagetext = replace(pagetext, '[[ru:', '----\n\n{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}\n\n[[ru:')
else:
# if interwiki links not found
print "WARNING: No under-interwiki links found!"
newpagetext = pagetext + '\n\n----\n\n{{subst:ia-verb-entry-form|'+stem+'|'+ending+'}}'
if (dont_edit == 0):
print('\n\nNEWPAGETEXT:\n')
print(newpagetext)
wikipedia.showDiff(pagetext, newpagetext)
choice = wikipedia.inputChoice(' OK?', , , 'n')
if ((newpagetext != pagetext) and (choice == 'y')):
myautosummary = 'stamping ' + myinsertiontext + ' with Python/pywikibot'
page.put(newpagetext, comment=myautosummary, minorEdit=autominor)
else:
pageexists.append(mypage)
print "Page", mypage, "already exists."
except NoPage:
myautosummary = 'preloading ' + mypreload + ' with Python/pywikibot'
page.put(mypreload, comment=myautosummary, minorEdit=autominor)
mypage = 'User:QuasiBot/log'
page = Page(site, mypage)
text = page.get()
newtext = text
logmessage = ": " + str(pageexists)
newtext += u"\n%s" % logmessage
showDiff(text, newtext)
choice = inputChoice(u'Do you want to accept these changes?', , , 'N')
if choice == 'N':
return False
#page.put(newtext, 'Bot: adding log entry.')
return pageexists