pyzotero 1.6.2__py3-none-any.whl → 1.6.4__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 CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.6.2'
16
- __version_tuple__ = version_tuple = (1, 6, 2)
15
+ __version__ = version = '1.6.4'
16
+ __version_tuple__ = version_tuple = (1, 6, 4)
pyzotero/zotero.py CHANGED
@@ -62,6 +62,23 @@ def build_url(base_url, path, args_dict=None):
62
62
  return urlunparse(url_parts)
63
63
 
64
64
 
65
+ def merge_params(url, params):
66
+ """This function strips query parameters, extracting them into a dict, then merging it with
67
+ the "params" dict, returning the truncated url and merged query params dict"""
68
+ parsed = urlparse(url)
69
+ # Extract query parameters from URL
70
+ incoming = parse_qs(parsed.query)
71
+ incoming = {k: v[0] for k, v in incoming.items()}
72
+
73
+ # Create new params dict by merging
74
+ merged = {**incoming, **params}
75
+
76
+ # Get base URL by zeroing out the query component
77
+ base_url = urlunparse(parsed._replace(query=""))
78
+
79
+ return base_url, merged
80
+
81
+
65
82
  def token():
66
83
  """Return a unique 32-char write-token"""
67
84
  return str(uuid.uuid4().hex)
@@ -458,7 +475,16 @@ class Zotero:
458
475
  if not self.url_params:
459
476
  self.url_params = {}
460
477
  merged_params = params | self.url_params
461
- self.request = self.client.get(url=full_url, params=merged_params)
478
+ # our incoming url might be from the "links" dict, in which case it will contain url parameters.
479
+ # Unfortunately, httpx doesn't like to merge query paramaters in the url string and passed params
480
+ # so we strip the url params, combining them with our existing url_params
481
+ final_url, final_params = merge_params(full_url, merged_params)
482
+ self.request = self.client.get(
483
+ url=final_url,
484
+ params=final_params,
485
+ headers=self.default_headers(),
486
+ timeout=timeout,
487
+ )
462
488
  self.request.encoding = "utf-8"
463
489
  try:
464
490
  self.request.raise_for_status()
@@ -660,7 +686,7 @@ class Zotero:
660
686
  ),
661
687
  ),
662
688
  headers=headers,
663
- content=json.dumps(payload),
689
+ data=json.dumps(payload),
664
690
  )
665
691
 
666
692
  def new_fulltext(self, since):
@@ -894,7 +920,6 @@ class Zotero:
894
920
  """Return the result of the call to the URL in the 'Next' link"""
895
921
  if n := self.links.get("next"):
896
922
  newurl = self._striplocal(n)
897
- print(newurl)
898
923
  return newurl
899
924
  return
900
925
 
@@ -1022,7 +1047,7 @@ class Zotero:
1022
1047
  linked_file
1023
1048
  linked_url
1024
1049
  """
1025
- return self.item_template("attachment&linkMode=" + attachment_type)
1050
+ return self.item_template("attachment", linkmode=attachment_type)
1026
1051
 
1027
1052
  def _attachment(self, payload, parentid=None):
1028
1053
  """
@@ -1072,7 +1097,7 @@ class Zotero:
1072
1097
  "/{t}/{u}/searches".format(t=self.library_type, u=self.library_id),
1073
1098
  ),
1074
1099
  headers=headers,
1075
- content=json.dumps(payload),
1100
+ data=json.dumps(payload),
1076
1101
  )
1077
1102
  self.request = req
1078
1103
  try:
@@ -1274,7 +1299,7 @@ class Zotero:
1274
1299
  self.endpoint,
1275
1300
  "/{t}/{u}/items".format(t=self.library_type, u=self.library_id),
1276
1301
  ),
1277
- content=to_send,
1302
+ data=to_send,
1278
1303
  headers=dict(headers),
1279
1304
  )
1280
1305
  self.request = req
@@ -1305,7 +1330,7 @@ class Zotero:
1305
1330
  t=self.library_type, u=self.library_id, v=value
1306
1331
  ),
1307
1332
  ),
1308
- content=payload,
1333
+ data=payload,
1309
1334
  headers=dict(uheaders),
1310
1335
  )
1311
1336
  self.request = presp
@@ -1349,7 +1374,7 @@ class Zotero:
1349
1374
  "/{t}/{u}/collections".format(t=self.library_type, u=self.library_id),
1350
1375
  ),
1351
1376
  headers=headers,
1352
- content=json.dumps(payload),
1377
+ data=json.dumps(payload),
1353
1378
  )
1354
1379
  self.request = req
1355
1380
  try:
@@ -1382,7 +1407,7 @@ class Zotero:
1382
1407
  ),
1383
1408
  ),
1384
1409
  headers=headers,
1385
- content=json.dumps(payload),
1410
+ data=json.dumps(payload),
1386
1411
  )
1387
1412
 
1388
1413
  def attachment_simple(self, files, parentid=None):
@@ -1440,7 +1465,7 @@ class Zotero:
1440
1465
  ),
1441
1466
  ),
1442
1467
  headers=headers,
1443
- content=json.dumps(to_send),
1468
+ data=json.dumps(to_send),
1444
1469
  )
1445
1470
 
1446
1471
  def update_items(self, payload):
@@ -1458,7 +1483,7 @@ class Zotero:
1458
1483
  self.endpoint,
1459
1484
  "/{t}/{u}/items/".format(t=self.library_type, u=self.library_id),
1460
1485
  ),
1461
- content=json.dumps(chunk),
1486
+ data=json.dumps(chunk),
1462
1487
  )
1463
1488
  self.request = req
1464
1489
  try:
@@ -1487,7 +1512,7 @@ class Zotero:
1487
1512
  t=self.library_type, u=self.library_id
1488
1513
  ),
1489
1514
  ),
1490
- content=json.dumps(chunk),
1515
+ data=json.dumps(chunk),
1491
1516
  )
1492
1517
  self.request = req
1493
1518
  try:
@@ -1518,7 +1543,7 @@ class Zotero:
1518
1543
  t=self.library_type, u=self.library_id, i=ident
1519
1544
  ),
1520
1545
  ),
1521
- content=json.dumps({"collections": modified_collections}),
1546
+ data=json.dumps({"collections": modified_collections}),
1522
1547
  headers=headers,
1523
1548
  )
1524
1549
 
@@ -1543,7 +1568,7 @@ class Zotero:
1543
1568
  t=self.library_type, u=self.library_id, i=ident
1544
1569
  ),
1545
1570
  ),
1546
- content=json.dumps({"collections": modified_collections}),
1571
+ data=json.dumps({"collections": modified_collections}),
1547
1572
  headers=headers,
1548
1573
  )
1549
1574
 
@@ -1907,14 +1932,14 @@ class Zupload:
1907
1932
  child["parentItem"] = self.parentid
1908
1933
  to_send = json.dumps(self.payload)
1909
1934
  self.zinstance._check_backoff()
1910
- req = self.client.post(
1935
+ req = self.zinstance.client.post(
1911
1936
  url=build_url(
1912
1937
  self.zinstance.endpoint,
1913
1938
  liblevel.format(
1914
1939
  t=self.zinstance.library_type, u=self.zinstance.library_id
1915
1940
  ),
1916
1941
  ),
1917
- content=to_send,
1942
+ data=to_send,
1918
1943
  headers=headers,
1919
1944
  )
1920
1945
  try:
@@ -1963,7 +1988,7 @@ class Zupload:
1963
1988
  i=reg_key,
1964
1989
  ),
1965
1990
  ),
1966
- content=data,
1991
+ data=data,
1967
1992
  headers=auth_headers,
1968
1993
  )
1969
1994
  try:
@@ -2027,7 +2052,7 @@ class Zupload:
2027
2052
  i=reg_key,
2028
2053
  ),
2029
2054
  ),
2030
- content=reg_data,
2055
+ data=reg_data,
2031
2056
  headers=dict(reg_headers),
2032
2057
  )
2033
2058
  try:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyzotero
3
- Version: 1.6.2
3
+ Version: 1.6.4
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
@@ -43,11 +43,11 @@ Project-URL: Repository, https://github.com/urschrei/pyzotero
43
43
  Project-URL: Tracker, https://github.com/urschrei/pyzotero/issues
44
44
  Keywords: Zotero,DH
45
45
  Classifier: Programming Language :: Python
46
- Classifier: Programming Language :: Python :: 3.8
47
46
  Classifier: Programming Language :: Python :: 3.9
48
47
  Classifier: Programming Language :: Python :: 3.10
49
48
  Classifier: Programming Language :: Python :: 3.11
50
49
  Classifier: Programming Language :: Python :: 3.12
50
+ Classifier: Programming Language :: Python :: 3.13
51
51
  Classifier: Development Status :: 5 - Production/Stable
52
52
  Classifier: Intended Audience :: Developers
53
53
  Classifier: Intended Audience :: Science/Research
@@ -55,7 +55,7 @@ Classifier: Intended Audience :: Education
55
55
  Classifier: License :: OSI Approved :: Blue Oak Model License (BlueOak-1.0.0)
56
56
  Classifier: Operating System :: OS Independent
57
57
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
58
- Requires-Python: >=3.8
58
+ Requires-Python: >=3.9
59
59
  Description-Content-Type: text/markdown
60
60
  License-File: LICENSE.md
61
61
  License-File: AUTHORS
@@ -0,0 +1,10 @@
1
+ _version.py,sha256=nUUf9xc-xNn7sMTK7c2rpMt1p2OZlNNmLiVGIkTETu8,411
2
+ pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
3
+ pyzotero/zotero.py,sha256=bPWHCgUbom96ijwM-ImEMtN91A6YajlmZHyx4I8GYPU,76374
4
+ pyzotero/zotero_errors.py,sha256=UPhAmf2K05cnoeIl2wjufWQedepg7vBKb-ShU0TdlL4,2582
5
+ pyzotero-1.6.4.dist-info/AUTHORS,sha256=ZMicxg7lRScOYbxzMPznlzMbmrFIUIHwg-NvljEMbRQ,110
6
+ pyzotero-1.6.4.dist-info/LICENSE.md,sha256=bhy1CPMj1zWffD9YifFmSeBzPylsrhb1qP8OCEx5Etw,1550
7
+ pyzotero-1.6.4.dist-info/METADATA,sha256=Lft4hiPbO-zeImbXKm38aBGcxo2DnU6ue36j5UAwpN4,7290
8
+ pyzotero-1.6.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
9
+ pyzotero-1.6.4.dist-info/top_level.txt,sha256=BOPNkPk5VtNDCy_li7Xftx6k0zG8STGxh-KgckcxLEw,18
10
+ pyzotero-1.6.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (75.7.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- _version.py,sha256=ay9A4GSmtr3NioHirRgXvWfXtjwRjzXIO_WPuFobCoI,411
2
- pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
3
- pyzotero/zotero.py,sha256=jnfqgwbn2nMxUnUNG98dm--AlE6CaLyJCuOizXOvJz4,75376
4
- pyzotero/zotero_errors.py,sha256=UPhAmf2K05cnoeIl2wjufWQedepg7vBKb-ShU0TdlL4,2582
5
- pyzotero-1.6.2.dist-info/AUTHORS,sha256=ZMicxg7lRScOYbxzMPznlzMbmrFIUIHwg-NvljEMbRQ,110
6
- pyzotero-1.6.2.dist-info/LICENSE.md,sha256=bhy1CPMj1zWffD9YifFmSeBzPylsrhb1qP8OCEx5Etw,1550
7
- pyzotero-1.6.2.dist-info/METADATA,sha256=aFEP8H1c0A7W75pQO_qBh6HNNcqDmnlRZ47llubffwc,7289
8
- pyzotero-1.6.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
9
- pyzotero-1.6.2.dist-info/top_level.txt,sha256=BOPNkPk5VtNDCy_li7Xftx6k0zG8STGxh-KgckcxLEw,18
10
- pyzotero-1.6.2.dist-info/RECORD,,