Skip to content

Commit 0fc27eb

Browse files
committed
Move formats dict to init
1 parent 040b038 commit 0fc27eb

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

src/pyzotero/zotero.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -191,39 +191,9 @@ def wrapped_f(self, *args, **kwargs):
191191
and self.content.search(str(self.request.url)).group(0)
192192
or "bib"
193193
)
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-
}
224194
# select format, or assume JSON
225195
content_type_header = self.request.headers["Content-Type"].lower() + ";"
226-
fmt = formats.get(
196+
fmt = self.formats.get(
227197
# strip "; charset=..." segment
228198
content_type_header[0 : content_type_header.index(";")],
229199
"json",
@@ -331,6 +301,36 @@ def __init__(
331301
# determine which processor to use for the parsed content
332302
self.fmt = re.compile(r"(?<=format=)\w+")
333303
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+
}
334334
self.processors = {
335335
"bib": self._bib_processor,
336336
"citation": self._citation_processor,

0 commit comments

Comments
 (0)