http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9343
Revision: 9343
Author: multichill
Date: 2011-07-09 12:11:54 +0000 (Sat, 09 Jul 2011)
Log Message:
-----------
Start with moving Commons messages to Translatewiki.
Still have to import the existing messages.
Added Paths:
-----------
branches/rewrite/scripts/i18n/commons.py
Copied: branches/rewrite/scripts/i18n/commons.py (from rev 9342, branches/rewrite/scripts/i18n/editarticle.py)
===================================================================
--- branches/rewrite/scripts/i18n/commons.py (rev 0)
+++ branches/rewrite/scripts/i18n/commons.py 2011-07-09 12:11:54 UTC (rev 9343)
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+msg = {
+ 'en': {
+ 'commons-file-moved' : u'[[:File:%s|File]] moved to [[:commons:File:%s|commons]].',
+ 'commons-file-now-available' : u'File is now available on Wikimedia Commons.',
+ 'commons-nowcommons-template' : 'en': u'{{subst:ncd|%s}}',
+ },
+ 'qqq': {
+ 'commons-file-now-available': u'Edit summary when the bot has moved a file to Commons and adds the NowCommons template.',
+ 'commons-file-moved': u'Edit summary when the bot replaces usage of an image available under a different name.',
+ 'commons-nowcommons-template' : 'en': u'The template to be added by the bot when a file is available at Commons. %s is the filename at Commons.',
+ },
+}
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9341
Revision: 9341
Author: filnik
Date: 2011-07-09 11:53:18 +0000 (Sat, 09 Jul 2011)
Log Message:
-----------
Bugfix: if a noinclude is in the end, the bot will loop forever. Moving the template nld from below to upper part
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2011-07-09 10:43:00 UTC (rev 9340)
+++ trunk/pywikipedia/checkimages.py 2011-07-09 11:53:18 UTC (rev 9341)
@@ -103,18 +103,18 @@
# That's what you want that will be added. (i.e. the {{no source}} with the
# right day/month/year )
n_txt = {
- 'commons':u'\n{{subst:nld}}',
- 'ar' :u'\n{{subst:لم}}',
+ 'commons':u'{{subst:nld}}',
+ 'ar' :u'{{subst:لم}}',
'de' :u'{{Benutzer:ABF/D|~~~~}} {{Dateiüberprüfung/benachrichtigt (Kategorie)|{{subst:LOCALYEAR}}|{{subst:LOCALMONTH}}|{{subst:LOCALDAY}}}} {{Dateiüberprüfung/benachrichtigt (Text)|Lizenz|||||}} --This was added by ~~~~-- ',
- 'en' :u'\n{{subst:nld}}',
+ 'en' :u'{{subst:nld}}',
'fa' :u'{{جا:حق تکثیر تصویر نامعلوم}}',
- 'fr' :u'\n{{subst:lid}}',
- 'ga' :u'\n{{subst:Ceadúnas de dhíth}}',
- 'hu' :u'\n{{nincslicenc|~~~~~}}',
- 'it' :u'\n{{subst:unverdata}}',
+ 'fr' :u'{{subst:lid}}',
+ 'ga' :u'{{subst:Ceadúnas de dhíth}}',
+ 'hu' :u'{{nincslicenc|~~~~~}}',
+ 'it' :u'{{subst:unverdata}}',
'ja' :u'{{subst:Nld}}',
- 'ko' :u'\n{{subst:nld}}',
- 'ta' :u'\n{{subst:nld}}',
+ 'ko' :u'{{subst:nld}}',
+ 'ta' :u'{{subst:nld}}',
'zh' :u'{{subst:No license/auto}}',
}
@@ -717,7 +717,7 @@
# You can use this function also to find only the user that
# has upload the image (FixME: Rewrite a bit this part)
if put:
- reportPageObject.put(reportPageText + self.newtext,
+ reportPageObject.put(self.newtext + "\n" + reportPageText,
comment=self.commImage)
# paginetta it's the image page object.
try:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9334
Revision: 9334
Author: multichill
Date: 2011-07-02 17:04:46 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
Add autonomous option.
Modified Paths:
--------------
trunk/pywikipedia/imagecopy_self.py
Modified: trunk/pywikipedia/imagecopy_self.py
===================================================================
--- trunk/pywikipedia/imagecopy_self.py 2011-07-02 16:53:38 UTC (rev 9333)
+++ trunk/pywikipedia/imagecopy_self.py 2011-07-02 17:04:46 UTC (rev 9334)
@@ -504,6 +504,7 @@
def __init__ ( self, prefetchQueue, uploadQueue):
self.prefetchQueue = prefetchQueue
self.uploadQueue = uploadQueue
+ self.autonomous = False
threading.Thread.__init__ ( self )
def run(self):
@@ -516,27 +517,41 @@
self.uploadQueue.put(None)
pywikibot.output(u'User worked on all images.')
return True
-
+
+ def setAutonomous(self):
+ '''
+ Don't do any user interaction.
+ '''
+ self.autonomous = True
+ return
+
def processImage(self, fields):
'''
Work on a single image
'''
- while True:
- # Do the Tkdialog to accept/reject and change te name
- fields=Tkdialog(fields).getnewmetadata()
-
- if fields.get('skip'):
- pywikibot.output(u'Skipping %s : User pressed skip.' % fields.get('imagepage').title())
+ if self.autonomous:
+ # Check if the image already exists. Do nothing if the name is already taken.
+ CommonsPage=pywikibot.Page(pywikibot.getSite('commons', 'commons'), u'File:' + fields.get('filename'))
+ if CommonsPage.exists():
return False
+ else:
+ while True:
+ # Do the Tkdialog to accept/reject and change te name
+ fields=Tkdialog(fields).getnewmetadata()
- # Check if the image already exists
- CommonsPage=pywikibot.Page(pywikibot.getSite('commons', 'commons'), u'File:' + fields.get('filename'))
- if not CommonsPage.exists():
- break
- else:
- pywikibot.output('Image already exists, pick another name or skip this image')
- # We dont overwrite images, pick another name, go to the start of the loop
+ if fields.get('skip'):
+ pywikibot.output(u'Skipping %s : User pressed skip.' % fields.get('imagepage').title())
+ return False
+ # Check if the image already exists
+ CommonsPage=pywikibot.Page(pywikibot.getSite('commons', 'commons'), u'File:' + fields.get('filename'))
+ if not CommonsPage.exists():
+ break
+ else:
+ pywikibot.output('Image already exists, pick another name or skip this image')
+ # We dont overwrite images, pick another name, go to the start of the loop
+
+ # Put the fields in the queue to be uploaded
self.uploadQueue.put(fields)
@@ -873,7 +888,7 @@
pywikibot.output(u'WARNING: Use at your own risk!')
generator = None;
- always = False
+ autonomous = False
checkTemplate = True
# Load a lot of default generators
@@ -882,6 +897,8 @@
for arg in pywikibot.handleArgs():
if arg == '-nochecktemplate':
checkTemplate = False
+ elif arg == '-autonomous':
+ autonomous = True
else:
genFactory.handleArg(arg)
@@ -906,7 +923,12 @@
userInteractionThread.daemon=False
uploaderThread.daemon=False
+ if autonomous:
+ pywikibot.output(u'Bot is running in autonomous mode. There will be no user interaction.')
+ userInteractionThread.setAutonomous()
+
if not checkTemplate:
+ pywikibot.output(u'No check template will be added to the uploaded files.')
uploaderThread.nochecktemplate()
fetchDone = imageFetcherThread.start()