Χρήστης:Flyax/Αμμοδοχείο
δοκιμή για νέο τ
επεξεργασία* {{τ|en|word}}: {{τ|en|word}} * {{τ|en1|word}}: {{τ|en1|word}} * {{τ|grc|καλός}}: {{τ|grc|καλός}} (δεν υπάρχει ΒΛ grc) * {{τ|en|very good|link=good|iw=good}}: {{τ|en|very good|link=good|iw=good}} * {{τ||bon}}: {{τ||bon}} (επιστρέφει μήνυμα λάθους) * {{τ|fr|}}: {{τ|fr|}} (δεν επιστρέφει τίποτα) * {{τ|ru|хороший|tr=xoróšij}}: {{τ|ru|хороший|tr=xoróšij}} * {{τ|ro|noentry|link=entry|noentry=1}}: {{τ|ro|noentry|link=entry|noentry=1}}
python
επεξεργασία
- !/usr/bin/python
- -*- coding: utf-8 -*-
import wikipedia import sys, re, codecs
- reload(sys)
- sys.setdefaultencoding('utf-8')
page_tag = re.compile('(.*)') meros_tag = re.compile('\{\{\-([^\|]*)\|fr\}\}') etym_tag = re.compile(u'\{\{ετυμ ([a-z]*)\|FR\}\}')
- cate1_tag = re.compile(u'\[\[Κατηγορία:([^\]]*)\]\](.*)')
categ_tag = re.compile(u'\[\[Κατηγορία:(.*)γαλλικά(\)*)\]\](.*)') set_string = re.compile('set')
debug_bul = True
def mainloop(line):
global debug_bul t1 = page_tag.search(line) #t1=u"absorptivité" # t = t1.group(1) print(t) kleida = t.translate(trtable) page = wikipedia.Page(wikipedia.getSite(), t) arxiko = page.get(get_redirect=True) # Αντικαταστάσειςp2 = meros_tag.sub(r'Πρότυπο:-\1',arxiko) p2 = etym_tag.sub(u'{{ετυμ \g<1>|FR|'+kleida+'}}',p2) keimeno = categ_tag.sub(u'[[Κατηγορία:\g<1>γαλλικά\g<2>|'+kleida+']]',p2)# Εδώ θα μπει ο κώδικας για την αποθήκευση if keimeno != page.get(): # Show the title of the page we're working on. # Highlight the title in purple. wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) ## show what was changed wikipedia.showDiff(page.get(), keimeno) #choice= 'y' if debug_bul: choice = wikipedia.inputChoice(u'Do you want to accept these changes?', ['yes', 'No', 'all'], ['y', 'N', 'a'], 'N') if choice == 'a':choice = 'y'
debug_bul = False elif choice != 'y': choice='n' wikipedia.output(u"\03{lightpurple}%s\03{default} : Δεν αποθηκεύτηκαν οι αλλαγές" % page.title()) if choice == 'y': try:# Save the page
page.put(keimeno) except wikipedia.EditConflict: wikipedia.output(u'Skipping %s because of edit conflict' % (page.title())) except wikipedia.SpamfilterError, error: wikipedia.output(u'Cannot change %s because of spam blacklist entry %s' % (page.title(), error.url))else: wikipedia.output(u"\03{lightpurple}%s\03{default} : Καμία αλλαγή δεν απαιτείται" % page.title())def main():
wikipedia.setLogfileStatus(True, 'log-cle-fr.txt') global trtable debug_bul = True# πίνακες αντιστοίχισης mtg_apo = u'à â ç é è ê ë î ï ô œ ù û ü' mtg_se = u'a a c e e e e i i o oe u u u' trkeys = mtg_apo.split(u' ') for i in range(len(trkeys)):trkeys[i] = ord(trkeys[i])
trvals = mtg_se.split(u' ') trtable = dict(zip(trkeys,trvals))wikipedia.setAction(u'Εισαγωγή κλείδας ταξινόμησης')# Εδώ ορίζεται η λέξη στην οποία θα γίνουν οι αλλαγές fin = codecs.open('kle-list', 'r', 'utf-8') eof=0 while not eof: line = fin.readline() #line = unicode(line, 'utf-8') if line == "": eof = 1 else:mainloop(line)
fin.close()if __name__ == "__main__":
try: main() finally: wikipedia.stopme()<\pre>