pyzotero 1.6.6__py3-none-any.whl → 1.6.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- _version.py +2 -2
- pyzotero/zotero.py +57 -38
- {pyzotero-1.6.6.dist-info → pyzotero-1.6.7.dist-info}/METADATA +2 -1
- pyzotero-1.6.7.dist-info/RECORD +10 -0
- pyzotero-1.6.6.dist-info/RECORD +0 -10
- {pyzotero-1.6.6.dist-info → pyzotero-1.6.7.dist-info}/AUTHORS +0 -0
- {pyzotero-1.6.6.dist-info → pyzotero-1.6.7.dist-info}/LICENSE.md +0 -0
- {pyzotero-1.6.6.dist-info → pyzotero-1.6.7.dist-info}/WHEEL +0 -0
- {pyzotero-1.6.6.dist-info → pyzotero-1.6.7.dist-info}/top_level.txt +0 -0
_version.py
CHANGED
pyzotero/zotero.py
CHANGED
|
@@ -40,6 +40,7 @@ import feedparser
|
|
|
40
40
|
import httpx
|
|
41
41
|
import pytz
|
|
42
42
|
from httpx import Request
|
|
43
|
+
from httpx_file import Client as File_Client
|
|
43
44
|
|
|
44
45
|
import pyzotero as pz
|
|
45
46
|
|
|
@@ -190,38 +191,9 @@ def retrieve(func):
|
|
|
190
191
|
and self.content.search(str(self.request.url)).group(0)
|
|
191
192
|
or "bib"
|
|
192
193
|
)
|
|
193
|
-
# JSON by default
|
|
194
|
-
formats = {
|
|
195
|
-
"application/atom+xml": "atom",
|
|
196
|
-
"application/x-bibtex": "bibtex",
|
|
197
|
-
"application/json": "json",
|
|
198
|
-
"text/html": "snapshot",
|
|
199
|
-
"text/plain": "plain",
|
|
200
|
-
"application/pdf; charset=utf-8": "pdf",
|
|
201
|
-
"application/pdf": "pdf",
|
|
202
|
-
"application/msword": "doc",
|
|
203
|
-
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
|
|
204
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
205
|
-
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
|
|
206
|
-
"application/zip": "zip",
|
|
207
|
-
"application/epub+zip": "zip",
|
|
208
|
-
"audio/mpeg": "mp3",
|
|
209
|
-
"video/mp4": "mp4",
|
|
210
|
-
"audio/x-wav": "wav",
|
|
211
|
-
"video/x-msvideo": "avi",
|
|
212
|
-
"application/octet-stream": "octet",
|
|
213
|
-
"application/x-tex": "tex",
|
|
214
|
-
"application/x-texinfo": "texinfo",
|
|
215
|
-
"image/jpeg": "jpeg",
|
|
216
|
-
"image/png": "png",
|
|
217
|
-
"image/gif": "gif",
|
|
218
|
-
"image/tiff": "tiff",
|
|
219
|
-
"application/postscript": "postscript",
|
|
220
|
-
"application/rtf": "rtf",
|
|
221
|
-
}
|
|
222
194
|
# select format, or assume JSON
|
|
223
195
|
content_type_header = self.request.headers["Content-Type"].lower() + ";"
|
|
224
|
-
fmt = formats.get(
|
|
196
|
+
fmt = self.formats.get(
|
|
225
197
|
# strip "; charset=..." segment
|
|
226
198
|
content_type_header[0 : content_type_header.index(";")],
|
|
227
199
|
"json",
|
|
@@ -321,12 +293,44 @@ class Zotero:
|
|
|
321
293
|
self.tag_data = False
|
|
322
294
|
self.request = None
|
|
323
295
|
self.snapshot = False
|
|
324
|
-
self.client = httpx.Client(
|
|
296
|
+
self.client = httpx.Client(
|
|
297
|
+
headers=self.default_headers(), follow_redirects=True
|
|
298
|
+
)
|
|
325
299
|
# these aren't valid item fields, so never send them to the server
|
|
326
300
|
self.temp_keys = set(["key", "etag", "group_id", "updated"])
|
|
327
301
|
# determine which processor to use for the parsed content
|
|
328
302
|
self.fmt = re.compile(r"(?<=format=)\w+")
|
|
329
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
|
+
}
|
|
330
334
|
self.processors = {
|
|
331
335
|
"bib": self._bib_processor,
|
|
332
336
|
"citation": self._citation_processor,
|
|
@@ -479,13 +483,28 @@ class Zotero:
|
|
|
479
483
|
# Unfortunately, httpx doesn't like to merge query paramaters in the url string and passed params
|
|
480
484
|
# so we strip the url params, combining them with our existing url_params
|
|
481
485
|
final_url, final_params = merge_params(full_url, merged_params)
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
# file URI errors are raised immediately so we have to try here
|
|
487
|
+
try:
|
|
488
|
+
self.request = self.client.get(
|
|
489
|
+
url=final_url,
|
|
490
|
+
params=final_params,
|
|
491
|
+
headers=self.default_headers(),
|
|
492
|
+
timeout=timeout,
|
|
493
|
+
)
|
|
494
|
+
self.request.encoding = "utf-8"
|
|
495
|
+
except httpx.UnsupportedProtocol:
|
|
496
|
+
# File URI handler logic
|
|
497
|
+
fc = File_Client()
|
|
498
|
+
request = fc.get(
|
|
499
|
+
url=final_url,
|
|
500
|
+
params=final_params,
|
|
501
|
+
headers=self.default_headers(),
|
|
502
|
+
timeout=timeout,
|
|
503
|
+
follow_redirects=True,
|
|
504
|
+
)
|
|
505
|
+
self.request = request
|
|
506
|
+
# since we'll be writing bytes, we need to set this to a type that will trigger the bytes processor
|
|
507
|
+
self.request.headers["Content-Type"] = "text/plain"
|
|
489
508
|
try:
|
|
490
509
|
self.request.raise_for_status()
|
|
491
510
|
except httpx.HTTPError as exc:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: pyzotero
|
|
3
|
-
Version: 1.6.
|
|
3
|
+
Version: 1.6.7
|
|
4
4
|
Summary: Python wrapper for the Zotero API
|
|
5
5
|
Author-email: Stephan Hügel <urschrei@gmail.com>
|
|
6
6
|
License: # Blue Oak Model License
|
|
@@ -63,6 +63,7 @@ Requires-Dist: feedparser>=6.0.11
|
|
|
63
63
|
Requires-Dist: pytz
|
|
64
64
|
Requires-Dist: bibtexparser
|
|
65
65
|
Requires-Dist: httpx>=0.28.1
|
|
66
|
+
Requires-Dist: httpx-file>=0.2.0
|
|
66
67
|
Provides-Extra: test
|
|
67
68
|
Requires-Dist: pytest>=7.4.2; extra == "test"
|
|
68
69
|
Requires-Dist: httpretty; extra == "test"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
_version.py,sha256=UBH9kvxesdE0svvcKwHfK8rz5bJUzNXPBHo7APqVEfk,411
|
|
2
|
+
pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
|
|
3
|
+
pyzotero/zotero.py,sha256=alCXV2WAagw6EL8nAJ4y9iZ3FFIE3-wJeCMYRbh1XTU,77343
|
|
4
|
+
pyzotero/zotero_errors.py,sha256=UPhAmf2K05cnoeIl2wjufWQedepg7vBKb-ShU0TdlL4,2582
|
|
5
|
+
pyzotero-1.6.7.dist-info/AUTHORS,sha256=ZMicxg7lRScOYbxzMPznlzMbmrFIUIHwg-NvljEMbRQ,110
|
|
6
|
+
pyzotero-1.6.7.dist-info/LICENSE.md,sha256=bhy1CPMj1zWffD9YifFmSeBzPylsrhb1qP8OCEx5Etw,1550
|
|
7
|
+
pyzotero-1.6.7.dist-info/METADATA,sha256=dR-omf9ajswDWyICEkqL_FCs_Y08c2G-TLO3zYAUkHE,7323
|
|
8
|
+
pyzotero-1.6.7.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
+
pyzotero-1.6.7.dist-info/top_level.txt,sha256=BOPNkPk5VtNDCy_li7Xftx6k0zG8STGxh-KgckcxLEw,18
|
|
10
|
+
pyzotero-1.6.7.dist-info/RECORD,,
|
pyzotero-1.6.6.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
_version.py,sha256=Nz1l8vGPOAOAlxWDepNu28nfH9fOKk0GnGSnVyZJsFE,411
|
|
2
|
-
pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
|
|
3
|
-
pyzotero/zotero.py,sha256=9mwSEa3Z97Bdni9p_yMqeKBEYQFUvRdwFJAIaf0gg5A,76539
|
|
4
|
-
pyzotero/zotero_errors.py,sha256=UPhAmf2K05cnoeIl2wjufWQedepg7vBKb-ShU0TdlL4,2582
|
|
5
|
-
pyzotero-1.6.6.dist-info/AUTHORS,sha256=ZMicxg7lRScOYbxzMPznlzMbmrFIUIHwg-NvljEMbRQ,110
|
|
6
|
-
pyzotero-1.6.6.dist-info/LICENSE.md,sha256=bhy1CPMj1zWffD9YifFmSeBzPylsrhb1qP8OCEx5Etw,1550
|
|
7
|
-
pyzotero-1.6.6.dist-info/METADATA,sha256=fw5aXyuKKiBOUD74CbxLzmDDZcqw-E9XBV-HNecB0W8,7290
|
|
8
|
-
pyzotero-1.6.6.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
9
|
-
pyzotero-1.6.6.dist-info/top_level.txt,sha256=BOPNkPk5VtNDCy_li7Xftx6k0zG8STGxh-KgckcxLEw,18
|
|
10
|
-
pyzotero-1.6.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|