r80260 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80259‎ | r80260 | r80261 >
Date:12:52, 14 January 2011
Author:btongminh
Status:deferred
Tags:
Comment:
Fixes to make it work: Actually substitute the data; Fix function calls; Always ignore warnings for now
Modified paths:
  • /trunk/tools/fancy-uploader/fancy-uploader.py (modified) (history)

Diff [purge]

Index: trunk/tools/fancy-uploader/fancy-uploader.py
@@ -39,7 +39,7 @@
4040
4141 title = u'%s - %s - %s.%s' % (base_title, metadata['project'], metadata['id'], metadata['extension'])
4242
43 - return cleanup_title(title)
 43+ return self.cleanup_title(title)
4444
4545 def cleanup_title(self, title):
4646 '''
@@ -50,23 +50,24 @@
5151
5252 def convert_dict_to_wikitext(self, template, dict):
5353 # TODO curly brace escaping
54 - return '{{subst:%s|%s|subst=subst:}}' % (template, '|'.join('%s=%s' for i in dict.iteritems()))
 54+ return '{{subst:%s|%s|subst=subst:}}' % (template, '|'.join('%s=%s' % i for i in dict.iteritems()))
5555
5656 def upload(self, username, password, file, filename, wikitext):
57 - site = mwclient.Site('commons.wikimedia.org')
 57+ site = mwclient.Site('test.wikipedia.org')
5858 site.login(username, password)
59 - return site.upload(file, filename, wikitext)
 59+ return site.upload(file, filename, wikitext, ignore = True)
6060
6161 def run(self, data, filename):
62 - title = self.construct_title()
 62+ title = self.construct_title(data['metadata'])
6363 wikitext = self.convert_dict_to_wikitext(data['body_template'],
6464 data['metadata'])
6565 result = self.upload(data['username'], data['password'],
6666 open(filename, 'rb'), title, wikitext)
 67+ return result
6768
6869 if __name__ == '__main__':
6970 uploader = FancyUploader()
7071 data = json.load(open(sys.argv[1], 'rb'))
7172 result = uploader.run(data, sys.argv[2])
72 - json.dump(sys.stdout, result)
 73+ json.dump(result, sys.stdout)
7374

Status & tagging log