Index: trunk/tools/fancy-uploader/fancy-uploader.py |
— | — | @@ -23,9 +23,31 @@ |
24 | 24 | def __init__(self): |
25 | 25 | pass |
26 | 26 | |
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 | + ''' |
29 | 35 | |
| 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 | + |
30 | 52 | def convert_dict_to_wikitext(self, template, dict): |
31 | 53 | # TODO curly brace escaping |
32 | 54 | return '{{%s|%s}}' % (template, '|'.join('%s=%s' for i in dict.iteritems())) |