@@ -191,39 +191,9 @@ def wrapped_f(self, *args, **kwargs):
191
191
and self .content .search (str (self .request .url )).group (0 )
192
192
or "bib"
193
193
)
194
- # JSON by default
195
- formats = {
196
- "application/atom+xml" : "atom" ,
197
- "application/x-bibtex" : "bibtex" ,
198
- "application/json" : "json" ,
199
- "text/html" : "snapshot" ,
200
- "text/plain" : "plain" ,
201
- "text/markdown" : "plain" ,
202
- "application/pdf; charset=utf-8" : "pdf" ,
203
- "application/pdf" : "pdf" ,
204
- "application/msword" : "doc" ,
205
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "xlsx" ,
206
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "docx" ,
207
- "application/vnd.openxmlformats-officedocument.presentationml.presentation" : "pptx" ,
208
- "application/zip" : "zip" ,
209
- "application/epub+zip" : "zip" ,
210
- "audio/mpeg" : "mp3" ,
211
- "video/mp4" : "mp4" ,
212
- "audio/x-wav" : "wav" ,
213
- "video/x-msvideo" : "avi" ,
214
- "application/octet-stream" : "octet" ,
215
- "application/x-tex" : "tex" ,
216
- "application/x-texinfo" : "texinfo" ,
217
- "image/jpeg" : "jpeg" ,
218
- "image/png" : "png" ,
219
- "image/gif" : "gif" ,
220
- "image/tiff" : "tiff" ,
221
- "application/postscript" : "postscript" ,
222
- "application/rtf" : "rtf" ,
223
- }
224
194
# select format, or assume JSON
225
195
content_type_header = self .request .headers ["Content-Type" ].lower () + ";"
226
- fmt = formats .get (
196
+ fmt = self . formats .get (
227
197
# strip "; charset=..." segment
228
198
content_type_header [0 : content_type_header .index (";" )],
229
199
"json" ,
@@ -331,6 +301,36 @@ def __init__(
331
301
# determine which processor to use for the parsed content
332
302
self .fmt = re .compile (r"(?<=format=)\w+" )
333
303
self .content = re .compile (r"(?<=content=)\w+" )
304
+ # JSON by default
305
+ self .formats = {
306
+ "application/atom+xml" : "atom" ,
307
+ "application/x-bibtex" : "bibtex" ,
308
+ "application/json" : "json" ,
309
+ "text/html" : "snapshot" ,
310
+ "text/plain" : "plain" ,
311
+ "text/markdown" : "plain" ,
312
+ "application/pdf; charset=utf-8" : "pdf" ,
313
+ "application/pdf" : "pdf" ,
314
+ "application/msword" : "doc" ,
315
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" : "xlsx" ,
316
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document" : "docx" ,
317
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation" : "pptx" ,
318
+ "application/zip" : "zip" ,
319
+ "application/epub+zip" : "zip" ,
320
+ "audio/mpeg" : "mp3" ,
321
+ "video/mp4" : "mp4" ,
322
+ "audio/x-wav" : "wav" ,
323
+ "video/x-msvideo" : "avi" ,
324
+ "application/octet-stream" : "octet" ,
325
+ "application/x-tex" : "tex" ,
326
+ "application/x-texinfo" : "texinfo" ,
327
+ "image/jpeg" : "jpeg" ,
328
+ "image/png" : "png" ,
329
+ "image/gif" : "gif" ,
330
+ "image/tiff" : "tiff" ,
331
+ "application/postscript" : "postscript" ,
332
+ "application/rtf" : "rtf" ,
333
+ }
334
334
self .processors = {
335
335
"bib" : self ._bib_processor ,
336
336
"citation" : self ._citation_processor ,
0 commit comments