http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9943
Revision: 9943 Author: xqt Date: 2012-02-28 16:22:29 +0000 (Tue, 28 Feb 2012) Log Message: ----------- update L10N from trunk
Modified Paths: -------------- branches/rewrite/scripts/clean_sandbox.py
Modified: branches/rewrite/scripts/clean_sandbox.py =================================================================== --- branches/rewrite/scripts/clean_sandbox.py 2012-02-28 15:47:37 UTC (rev 9942) +++ branches/rewrite/scripts/clean_sandbox.py 2012-02-28 16:22:29 UTC (rev 9943) @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -This bot cleans a sandbox by replacing the current contents with predefined -text. +This bot cleans a sandbox by replacing the current contents with +predefined text.
This script understands the following command-line arguments:
@@ -34,13 +34,15 @@ from pywikibot import i18n
content = { + 'commons': u'{{Sandbox}}\n<!-- Please edit only below this line. -->', 'als':u'{{subst:/Vorlage}}', - 'ar': u'{{من فضلك اترك هذا السطر ولا تعدله (عنوان ساحة التجربة)}}\n<!-- مرحبا! خذ راحتك في تجربة مهارتك في التنسيق والتحرير أسفل هذا السطر. هذه الصفحة لتجارب التعديل ، سيتم تفريغ هذه الصفحة كل 6 ساعات. -->', + 'ar': u'{{عنوان الملعب}}\n<!-- مرحبا! خذ راحتك في تجربة مهارتك في التنسيق والتحرير أسفل هذا السطر. هذه الصفحة لتجارب التعديل ، سيتم تفريغ هذه الصفحة كل 12 ساعة. -->', + 'az': u'<!--- LÜTFƏN, BU SƏTRƏ TOXUNMAYIN --->\n{{Qaralama dəftəri}}\n<!-- AŞAĞIDAKI XƏTTİN ALTINDAN YAZA BİLƏRSİNİZ --->', 'bar':u'{{Bitte erst NACH dieser Zeile schreiben! (Begrüßungskasten)}}\r\n', 'cs': u'{{subst:/uhrabat}}', 'da': u'{{subst:Sandkasse tekst}}', 'de': u'{{Bitte erst NACH dieser Zeile schreiben! (Begrüßungskasten)}}\r\n', - 'en': u'{{Please leave this line alone (sandbox heading)}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every 12 hours. -->', + 'en': u'{{Sandbox heading}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every 12 hours. -->', 'fa': u'{{subst:User:Amirobot/sandbox}}', 'fi': u'{{subst:Hiekka}}', 'he': u'{{ארגז חול}}\n<!-- נא לערוך מתחת לשורה זו בלבד, תודה. -->', @@ -51,29 +53,33 @@ 'ksh':u'{{subst:/Schablon}}', 'nds':u'{{subst:/Vörlaag}}', 'nl': u'{{subst:Wikipedia:Zandbak/schoon zand}}', + 'nn': u'{{sandkasse}}\n<!-- Ver snill og IKKJE FJERN DENNE LINA OG LINA OVER ({{sandkasse}}) Nedanføre kan du derimot ha det artig og prøve deg fram! Lykke til! :-) -->', 'no': u'{{Sandkasse}}\n<!-- VENNLIGST EKSPERIMENTER NEDENFOR DENNE SKJULTE TEKSTLINJEN! SANDKASSEMALEN {{Sandkasse}} SKAL IKKE FJERNES! -->}}', - 'nn': u'{{sandkasse}}\n<!-- Ver snill og IKKJE FJERN DENNE LINA OG LINA OVER ({{sandkasse}}) Nedanføre kan du derimot ha det artig og prøve deg fram! Lykke til! :-) -->', 'pl': u'{{Prosimy - NIE ZMIENIAJ, NIE KASUJ, NIE PRZENOŚ tej linijki - pisz niżej}}', 'pt': u'<!--não apague esta linha-->{{página de testes}}<!--não apagar-->\r\n', - 'commons': u'{{Sandbox}}\n<!-- Please edit only below this line. -->', 'ru': u'{{/Пишите ниже}}\n<!-- Не удаляйте, пожалуйста, эту строку, тестируйте ниже -->', + 'simple': u'{{Please leave this line alone (sandbox heading)}}\n<!-- Hello! Feel free to try your formatting and editing skills below this line. As this page is for editing experiments, this page will automatically be cleaned every 2 hours. -->', + 'sco': u'Feel free tae test here', 'sr': u'{{песак}}\n<!-- Молимо, испробавајте испод ове линије. Хвала. -->', 'sv': u'{{subst:Sandlådan}}', 'th': u'{{กระบะทราย}}\n<!-- กรุณาอย่าแก้ไขบรรทัดนี้ ขอบคุณครับ/ค่ะ -- Please leave this line as they are. Thank you! -->', + 'tr': u'{{/Bu satırı değiştirmeden bırakın}}', 'zh': u'{{subst:User:Sz-iwbot/sandbox}}\r\n', }
sandboxTitle = { + 'commons': u'Project:Sandbox', 'als':u'Project:Sandchaschte', - 'ar': u'Project:ساحة التجربة', + 'ar': u'Project:ملعب', + 'az': u'Vikipediya:Qaralama dəftəri', 'bar':u'Project:Spielwiese', 'cs': u'Project:Pískoviště', 'da': u'Project:Sandkassen', 'de': u'Project:Spielwiese', 'en': u'Project:Sandbox', - 'fa': u'Project:صفحه تمرین', + 'fa': [u'Project:صفحه تمرین', u'Project:آشنایی'], + 'fi': u'Project:Hiekkalaatikko', 'fr': u'Project:Bac à sable', - 'fi': u'Project:Hiekkalaatikko', 'he': u'Project:ארגז חול', 'id': u'Project:Bak pasir', 'it': u'Project:Pagina delle prove', @@ -85,14 +91,17 @@ 'no': u'Project:Sandkasse', 'pl': u'Project:Brudnopis', 'pt': u'Project:Página de testes', - 'commons': u'Project:Sandbox', 'ru': u'Project:Песочница', + 'simple': u'Project:Sandbox', + 'sco': u'Project:Saundpit', 'sr': u'Project:Песак', 'sv': u'Project:Sandlådan', 'th': u'Project:ทดลองเขียน', + 'tr': u'Vikipedi:Deneme tahtası', 'zh': u'Project:沙盒', }
+ class SandboxBot(pywikibot.Bot): availableOptions = { 'hours': 1, @@ -119,27 +128,30 @@
def run(self): + mySite = self.site while True: wait = False now = time.strftime("%d %b %Y %H:%M:%S (UTC)", time.gmtime()) - localSandboxTitle = pywikibot.translate(self.site, sandboxTitle) + localSandboxTitle = pywikibot.translate(mySite, sandboxTitle) if type(localSandboxTitle) is list: titles = localSandboxTitle else: titles = [localSandboxTitle,] for title in titles: - sandboxPage = pywikibot.Page(self.site, title) + sandboxPage = pywikibot.Page(mySite, title) + pywikibot.output(u'Preparing to process sandbox page %s' % sandboxPage.title(asLink=True)) try: text = sandboxPage.get() - translatedContent = pywikibot.translate(self.site, content) - translatedMsg = i18n.twtranslate(self.site, + translatedContent = pywikibot.translate(mySite, content) + translatedMsg = i18n.twtranslate(mySite, 'clean_sandbox-cleaned') subst = 'subst:' in translatedContent + pos = text.find(translatedContent.strip()) if text.strip() == translatedContent.strip(): pywikibot.output(u'The sandbox is still clean, no change necessary.') - elif subst and sandboxPage.userName() == self.site.user(): + elif subst and sandboxPage.userName() == mySite.user(): pywikibot.output(u'The sandbox might be clean, no change necessary.') - elif text.find(translatedContent.strip()) <> 0 and not subst: + elif pos <> 0 and not subst: sandboxPage.put(translatedContent, translatedMsg) pywikibot.showDiff(text, translatedContent) pywikibot.output(u'Standard content was changed, sandbox cleaned.') @@ -151,6 +163,7 @@ if delta <= datetime.timedelta(0): sandboxPage.put(translatedContent, translatedMsg) pywikibot.showDiff(text, translatedContent) + pywikibot.output(u'Standard content was changed, sandbox cleaned.') else: #wait for the rest pywikibot.output(u'Sandbox edited %.1f minutes ago...' % \ (edit_delta.seconds / 60.0))
pywikipedia-svn@lists.wikimedia.org