r80255 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80254‎ | r80255 | r80256 >
Date:12:23, 14 January 2011
Author:multichill
Status:deferred
Tags:
Comment:
Title functions to start with
Modified paths:
  • /trunk/tools/fancy-uploader/fancy-uploader.py (modified) (history)

Diff [purge]

Index: trunk/tools/fancy-uploader/fancy-uploader.py
@@ -23,9 +23,31 @@
2424 def __init__(self):
2525 pass
2626
27 - def construct_title(self):
28 - pass
 27+ def construct_title(self, metadata, maxlength=120):
 28+ '''
 29+ Need the following fields in the metadata dictionary:
 30+ * title
 31+ * project
 32+ * id
 33+ * extension
 34+ '''
2935
 36+ if len(metadata['title']) > maxlength:
 37+ base_title = metadata['title'][0 : maxlength]
 38+ else:
 39+ base_title = metadata['title']
 40+
 41+ title = u'%s - %s - %s.%s' % (base_title, metadata['project'], metadata['id'], metadata['extension'])
 42+
 43+ return cleanup_title(title)
 44+
 45+ def cleanup_title(self, title):
 46+ '''
 47+ Remove all funky chars that might cause problems
 48+ '''
 49+ return title
 50+
 51+
3052 def convert_dict_to_wikitext(self, template, dict):
3153 # TODO curly brace escaping
3254 return '{{%s|%s}}' % (template, '|'.join('%s=%s' for i in dict.iteritems()))

Status & tagging log