pyzotero 1.5.9__py3-none-any.whl → 1.5.15__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 ADDED
@@ -0,0 +1,8 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple
6
+
7
+ __version__ = version = '1.5.15' # type: str
8
+ __version_tuple__ = version_tuple = (1, 5, 15) # type: Tuple[int | str, ...]
pyzotero/__init__.py CHANGED
@@ -0,0 +1,7 @@
1
+ import importlib.metadata
2
+
3
+ try:
4
+ # __package__ allows for the case where __name__ is "__main__"
5
+ __version__ = importlib.metadata.version(__package__ or __name__)
6
+ except importlib.metadata.PackageNotFoundError:
7
+ __version__ = "0.0.0"
pyzotero/zotero.py CHANGED
@@ -29,11 +29,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29
29
  THE SOFTWARE.
30
30
 
31
31
  """
32
- from . import version as pzv
33
32
 
34
33
  __author__ = "Stephan Hügel"
35
34
  __api_version__ = "3"
36
- __version__ = pzv.__version__
37
35
 
38
36
  import requests
39
37
  from requests import Request
@@ -58,6 +56,7 @@ from urllib.parse import urlparse, urlunparse, parse_qsl
58
56
  from urllib.parse import quote
59
57
 
60
58
  from . import zotero_errors as ze
59
+ import pyzotero as pz
61
60
 
62
61
 
63
62
  # Avoid hanging the application if there's no server response
@@ -145,8 +144,8 @@ def backoff_check(func):
145
144
  resp = func(self, *args, **kwargs)
146
145
  try:
147
146
  resp.raise_for_status()
148
- except requests.exceptions.HTTPError:
149
- error_handler(self, resp)
147
+ except requests.exceptions.HTTPError as exc:
148
+ error_handler(self, resp, exc)
150
149
  self.request = resp
151
150
  backoff = resp.headers.get("backoff") or resp.headers.get("retry-after")
152
151
  if backoff:
@@ -358,7 +357,7 @@ class Zotero:
358
357
  It's always OK to include these headers
359
358
  """
360
359
  _headers = {
361
- "User-Agent": "Pyzotero/%s" % __version__,
360
+ "User-Agent": "Pyzotero/%s" % pz.__version__,
362
361
  "Zotero-API-Version": "%s" % __api_version__,
363
362
  }
364
363
  if self.api_key:
@@ -408,8 +407,8 @@ class Zotero:
408
407
  self.request.encoding = "utf-8"
409
408
  try:
410
409
  self.request.raise_for_status()
411
- except requests.exceptions.HTTPError:
412
- error_handler(self, self.request)
410
+ except requests.exceptions.HTTPError as exc:
411
+ error_handler(self, self.request, exc)
413
412
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
414
413
  "retry-after"
415
414
  )
@@ -476,8 +475,8 @@ class Zotero:
476
475
  req = requests.get(query, headers=headers)
477
476
  try:
478
477
  req.raise_for_status()
479
- except requests.exceptions.HTTPError:
480
- error_handler(self, req)
478
+ except requests.exceptions.HTTPError as exc:
479
+ error_handler(self, req, exc)
481
480
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
482
481
  "retry-after"
483
482
  )
@@ -625,8 +624,8 @@ class Zotero:
625
624
  resp = requests.get(build_url(self.endpoint, query_string), headers=headers)
626
625
  try:
627
626
  resp.raise_for_status()
628
- except requests.exceptions.HTTPError:
629
- error_handler(self, resp)
627
+ except requests.exceptions.HTTPError as exc:
628
+ error_handler(self, resp, exc)
630
629
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
631
630
  "retry-after"
632
631
  )
@@ -1023,8 +1022,8 @@ class Zotero:
1023
1022
  self.request = req
1024
1023
  try:
1025
1024
  req.raise_for_status()
1026
- except requests.exceptions.HTTPError:
1027
- error_handler(self, req)
1025
+ except requests.exceptions.HTTPError as exc:
1026
+ error_handler(self, req, exc)
1028
1027
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
1029
1028
  "retry-after"
1030
1029
  )
@@ -1051,8 +1050,8 @@ class Zotero:
1051
1050
  self.request = req
1052
1051
  try:
1053
1052
  req.raise_for_status()
1054
- except requests.exceptions.HTTPError:
1055
- error_handler(self, req)
1053
+ except requests.exceptions.HTTPError as exc:
1054
+ error_handler(self, req, exc)
1056
1055
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
1057
1056
  "retry-after"
1058
1057
  )
@@ -1227,8 +1226,8 @@ class Zotero:
1227
1226
  self.request = req
1228
1227
  try:
1229
1228
  req.raise_for_status()
1230
- except requests.exceptions.HTTPError:
1231
- error_handler(self, req)
1229
+ except requests.exceptions.HTTPError as exc:
1230
+ error_handler(self, req, exc)
1232
1231
  resp = req.json()
1233
1232
  backoff = self.request.headers.get("backoff") or self.request.headers.get(
1234
1233
  "retry-after"
@@ -1259,8 +1258,8 @@ class Zotero:
1259
1258
  self.request = presp
1260
1259
  try:
1261
1260
  presp.raise_for_status()
1262
- except requests.exceptions.HTTPError:
1263
- error_handler(self, presp)
1261
+ except requests.exceptions.HTTPError as exc:
1262
+ error_handler(self, presp, exc)
1264
1263
  backoff = presp.headers.get("backoff") or presp.headers.get(
1265
1264
  "retry-after"
1266
1265
  )
@@ -1303,8 +1302,8 @@ class Zotero:
1303
1302
  self.request = req
1304
1303
  try:
1305
1304
  req.raise_for_status()
1306
- except requests.exceptions.HTTPError:
1307
- error_handler(self, req)
1305
+ except requests.exceptions.HTTPError as exc:
1306
+ error_handler(self, req, exc)
1308
1307
  backoff = req.headers.get("backoff") or req.headers.get("retry-after")
1309
1308
  if backoff:
1310
1309
  self._set_backoff(backoff)
@@ -1417,8 +1416,8 @@ class Zotero:
1417
1416
  self.request = req
1418
1417
  try:
1419
1418
  req.raise_for_status()
1420
- except requests.exceptions.HTTPError:
1421
- error_handler(self, req)
1419
+ except requests.exceptions.HTTPError as exc:
1420
+ error_handler(self, req, exc)
1422
1421
  backoff = req.headers.get("backoff") or req.headers.get("retry-after")
1423
1422
  if backoff:
1424
1423
  self._set_backoff(backoff)
@@ -1449,8 +1448,8 @@ class Zotero:
1449
1448
  self.request = req
1450
1449
  try:
1451
1450
  req.raise_for_status()
1452
- except requests.exceptions.HTTPError:
1453
- error_handler(self, req)
1451
+ except requests.exceptions.HTTPError as exc:
1452
+ error_handler(self, req, exc)
1454
1453
  backoff = req.headers.get("backoff") or req.headers.get("retry-after")
1455
1454
  if backoff:
1456
1455
  self._set_backoff(backoff)
@@ -1602,7 +1601,7 @@ class Zotero:
1602
1601
  return requests.delete(url=url, params=params, headers=headers)
1603
1602
 
1604
1603
 
1605
- def error_handler(zot, req):
1604
+ def error_handler(zot, req, exc=None):
1606
1605
  """Error handler for HTTP requests"""
1607
1606
  error_codes = {
1608
1607
  400: ze.UnsupportedParams,
@@ -1638,14 +1637,21 @@ def error_handler(zot, req):
1638
1637
  else:
1639
1638
  zot._set_backoff(delay)
1640
1639
  else:
1641
- raise error_codes.get(req.status_code)(err_msg(req))
1640
+ if not exc:
1641
+ raise error_codes.get(req.status_code)(err_msg(req))
1642
+ else:
1643
+ raise error_codes.get(req.status_code)(err_msg(req)) from exc
1642
1644
  else:
1643
- raise ze.HTTPError(err_msg(req))
1645
+ if not exc:
1646
+ raise ze.HTTPError(err_msg(req))
1647
+ else:
1648
+ raise ze.HTTPError(err_msg(req)) from exc
1644
1649
 
1645
1650
 
1646
1651
  class SavedSearch:
1647
1652
  """Saved search functionality
1648
- See https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/data/searchConditions.js"""
1653
+ See https://github.com/zotero/zotero/blob/master/chrome/content/zotero/xpcom/data/searchConditions.js
1654
+ """
1649
1655
 
1650
1656
  def __init__(self, zinstance):
1651
1657
  super(SavedSearch, self).__init__()
@@ -1889,8 +1895,8 @@ class Zupload:
1889
1895
  )
1890
1896
  try:
1891
1897
  req.raise_for_status()
1892
- except requests.exceptions.HTTPError:
1893
- error_handler(self.zinstance, req)
1898
+ except requests.exceptions.HTTPError as exc:
1899
+ error_handler(self.zinstance, req, exc)
1894
1900
  backoff = req.headers.get("backoff") or req.headers.get("retry-after")
1895
1901
  if backoff:
1896
1902
  self.zinstance._set_backoff(backoff)
@@ -1939,8 +1945,8 @@ class Zupload:
1939
1945
  )
1940
1946
  try:
1941
1947
  auth_req.raise_for_status()
1942
- except requests.exceptions.HTTPError:
1943
- error_handler(self.zinstance, auth_req)
1948
+ except requests.exceptions.HTTPError as exc:
1949
+ error_handler(self.zinstance, auth_req, exc)
1944
1950
  backoff = auth_req.headers.get("backoff") or auth_req.headers.get("retry-after")
1945
1951
  if backoff:
1946
1952
  self.zinstance._set_backoff(backoff)
@@ -1967,12 +1973,12 @@ class Zupload:
1967
1973
  files=upload_pairs,
1968
1974
  headers={"User-Agent": "Pyzotero/%s" % __version__},
1969
1975
  )
1970
- except (requests.exceptions.ConnectionError):
1976
+ except requests.exceptions.ConnectionError:
1971
1977
  raise ze.UploadError("ConnectionError")
1972
1978
  try:
1973
1979
  upload.raise_for_status()
1974
- except requests.exceptions.HTTPError:
1975
- error_handler(self.zinstance, upload)
1980
+ except requests.exceptions.HTTPError as exc:
1981
+ error_handler(self.zinstance, upload, exc)
1976
1982
  backoff = upload.headers.get("backoff") or upload.headers.get("retry-after")
1977
1983
  if backoff:
1978
1984
  self.zinstance._set_backoff(backoff)
@@ -2004,8 +2010,8 @@ class Zupload:
2004
2010
  )
2005
2011
  try:
2006
2012
  upload_reg.raise_for_status()
2007
- except requests.exceptions.HTTPError:
2008
- error_handler(self.zinstance, upload_reg)
2013
+ except requests.exceptions.HTTPError as exc:
2014
+ error_handler(self.zinstance, upload_reg, exc)
2009
2015
  backoff = upload_reg.headers.get("backoff") or upload_reg.headers.get(
2010
2016
  "retry-after"
2011
2017
  )
@@ -0,0 +1,2 @@
1
+ # This is the official list of Pyzotero authors for copyright purposes.
2
+ Stephan Hügel (<urschrei@gmail.com>)
@@ -1,37 +1,56 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyzotero
3
- Version: 1.5.9
3
+ Version: 1.5.15
4
4
  Summary: Python wrapper for the Zotero API
5
- Home-page: https://github.com/urschrei/pyzotero
6
- Author: Stephan Hügel
7
- Author-email: urschrei@gmail.com
8
- License: MIT
9
- Project-URL: Source, https://github.com/urschrei/pyzotero
5
+ Author-email: Stephan Hügel <urschrei@gmail.com>
6
+ License: The MIT License (MIT)
7
+
8
+ Copyright (c) 2015 Stephan Hügel
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in
18
+ all copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26
+ THE SOFTWARE.
27
+
28
+ Project-URL: Repository, https://github.com/urschrei/pyzotero
10
29
  Project-URL: Tracker, https://github.com/urschrei/pyzotero/issues
11
- Keywords: zotero
12
- Platform: UNKNOWN
30
+ Keywords: Zotero,DH
13
31
  Classifier: Programming Language :: Python
14
- Classifier: Programming Language :: Python :: 3.7
15
32
  Classifier: Programming Language :: Python :: 3.8
16
33
  Classifier: Programming Language :: Python :: 3.9
17
34
  Classifier: Programming Language :: Python :: 3.10
35
+ Classifier: Programming Language :: Python :: 3.11
18
36
  Classifier: Development Status :: 5 - Production/Stable
19
37
  Classifier: Intended Audience :: Developers
38
+ Classifier: Intended Audience :: Science/Research
20
39
  Classifier: Intended Audience :: Education
21
40
  Classifier: License :: OSI Approved :: MIT License
22
41
  Classifier: Operating System :: OS Independent
23
42
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
- Requires-Python: >=3.7
25
- Description-Content-Type: text/markdown; charset=UTF-8
26
- License-File: license.txt
27
- Requires-Dist: bibtexparser
28
- Requires-Dist: feedparser (>=6)
43
+ Requires-Python: >=3.8
44
+ Description-Content-Type: text/markdown
45
+ License-File: AUTHORS
46
+ Requires-Dist: feedparser >=6
29
47
  Requires-Dist: pytz
30
- Requires-Dist: requests (>=2.21.0)
31
- Provides-Extra: all
32
- Requires-Dist: pytest (>=6.2.2) ; extra == 'all'
48
+ Requires-Dist: requests >=2.21.0
49
+ Requires-Dist: bibtexparser
33
50
  Provides-Extra: test
34
- Requires-Dist: pytest (>=6.2.2) ; extra == 'test'
51
+ Requires-Dist: pytest >=7.4.2 ; extra == 'test'
52
+ Requires-Dist: httpretty ; extra == 'test'
53
+ Requires-Dist: python-dateutil ; extra == 'test'
35
54
 
36
55
  [![Supported Python versions](https://img.shields.io/pypi/pyversions/Pyzotero.svg?style=flat)](https://pypi.python.org/pypi/Pyzotero/) [![Docs](https://readthedocs.org/projects/pyzotero/badge/?version=latest)](http://pyzotero.readthedocs.org/en/latest/?badge=latest) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](license.txt) [![PyPI Version](https://img.shields.io/pypi/v/Pyzotero.svg)](https://pypi.python.org/pypi/Pyzotero) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/pyzotero/badges/version.svg)](https://anaconda.org/conda-forge/pyzotero) [![Downloads](https://pepy.tech/badge/pyzotero)](https://pepy.tech/project/pyzotero)
37
56
 
@@ -121,5 +140,3 @@ Pyzotero is licensed under the [MIT license][8]. See [license.txt](license.txt)
121
140
  [10]: http://www.pip-installer.org/en/latest/index.html
122
141
  † This isn't strictly true: you only need an API key for personal libraries and non-public group libraries.
123
142
 
124
-
125
-
@@ -0,0 +1,9 @@
1
+ _version.py,sha256=BffUs0zTnKVjgtY67ZB9bc6OL0FyBI7zUfWrc3U4Th4,276
2
+ pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
3
+ pyzotero/zotero.py,sha256=NBHf4eXDSnnIgu-9qcW2AV9BLs85VnspvP5luiyq6zo,75215
4
+ pyzotero/zotero_errors.py,sha256=XzjUxKDQUMpRDBEQGTJ-wna0-bVoKIKK7AEDfKgzdfE,3664
5
+ pyzotero-1.5.15.dist-info/AUTHORS,sha256=ZMicxg7lRScOYbxzMPznlzMbmrFIUIHwg-NvljEMbRQ,110
6
+ pyzotero-1.5.15.dist-info/METADATA,sha256=LF0Fw6OLzZsxhOgsTfuYadFJ9f61lt_CCPaG809za3c,6570
7
+ pyzotero-1.5.15.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
8
+ pyzotero-1.5.15.dist-info/top_level.txt,sha256=BOPNkPk5VtNDCy_li7Xftx6k0zG8STGxh-KgckcxLEw,18
9
+ pyzotero-1.5.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.37.1)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1 +1,2 @@
1
+ _version
1
2
  pyzotero
pyzotero/version.py DELETED
@@ -1 +0,0 @@
1
- __version__ = "1.5.9"
@@ -1,9 +0,0 @@
1
- pyzotero/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pyzotero/version.py,sha256=RHMW_abK7T5iTrsk1-qw4vMlruQeDezoKz9wbLkDSWk,22
3
- pyzotero/zotero.py,sha256=GcEof9c3Oab1ozszHlXttYR4va4F1h8GXtU5Jxgv3Gw,74840
4
- pyzotero/zotero_errors.py,sha256=XzjUxKDQUMpRDBEQGTJ-wna0-bVoKIKK7AEDfKgzdfE,3664
5
- pyzotero-1.5.9.dist-info/METADATA,sha256=sdRs37rB-G4QnMTWiixvI7bb8DtOnsK9mh-w-0-hATs,5341
6
- pyzotero-1.5.9.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
7
- pyzotero-1.5.9.dist-info/license.txt,sha256=GkRsY7w5O74wcQX_wTlgXReyzsg9gGAhchpri3Na0wQ,1081
8
- pyzotero-1.5.9.dist-info/top_level.txt,sha256=uRY96N9ioKvXlbEGhzxxOAJnU8dm7KPE-156WiWf9R8,9
9
- pyzotero-1.5.9.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Stephan Hügel
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.