User:QuasiBot/iaconjdata.py

Hello, you have come here looking for the meaning of the word User:QuasiBot/iaconjdata.py. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:QuasiBot/iaconjdata.py, but we will also tell you about its etymology, its characteristics and you will know how to say User:QuasiBot/iaconjdata.py in singular and plural. Everything you need to know about the word User:QuasiBot/iaconjdata.py you have here. The definition of the word User:QuasiBot/iaconjdata.py will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:QuasiBot/iaconjdata.py, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
# 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

Comments

  • The repetition could be abstracted out (as has been done with eoconjdata.py).
  • Is the overlang part necessary? (It doesn't seem to be.)