0003-output-all-possible-extensions-when-formating-mimety.patch
tests/test_misc.py | ||
---|---|---|
4 | 4 |
import pytest |
5 | 5 |
import os |
6 | 6 |
import pickle |
7 |
import re |
|
7 | 8 | |
8 | 9 |
from quixote import cleanup |
9 | 10 | |
... | ... | |
51 | 52 |
'application/pdf (.pdf)' |
52 | 53 |
assert FileTypesDirectory.format_mimetypes(['application/pdf', 'text/rtf']) == \ |
53 | 54 |
'application/pdf (.pdf), text/rtf' |
54 |
assert FileTypesDirectory.format_mimetypes(['application/pdf', 'application/msword']) == \ |
|
55 |
'application/pdf (.pdf), application/msword (.doc)' |
|
55 |
description = FileTypesDirectory.format_mimetypes(['application/pdf', 'application/msword']) |
|
56 |
matches = re.finditer(r'(?:, *)?(?P<mimetype>[a-z/]+) \((?P<extensions>[^)]*)\)', description) |
|
57 |
s = dict((m.group('mimetype'), set(m.group('extensions').split(', '))) for m in matches) |
|
58 |
assert s == dict([('application/msword', set(['.doc', '.dot', '.wiz'])), |
|
59 |
('application/pdf', set(['.pdf']))]) |
|
56 | 60 |
assert FileTypesDirectory.format_mimetypes(['application/pdf', |
57 | 61 |
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
58 | 62 |
'application/msword']) == \ |
wcs/admin/settings.py | ||
---|---|---|
253 | 253 |
# string got too long already, stop this now and we'll get an |
254 | 254 |
# ellipsis |
255 | 255 |
break |
256 |
ext = mimetypes.guess_extension(mimetype)
|
|
256 |
ext = mimetypes.guess_all_extensions(mimetype)
|
|
257 | 257 |
if ext: |
258 |
l.append('%s (%s)' % (mimetype, ext))
|
|
258 |
l.append('%s (%s)' % (mimetype, ', '.join(ext)))
|
|
259 | 259 |
else: |
260 | 260 |
l.append(mimetype) |
261 | 261 |
else: |
262 |
- |