Skip to content

Commit 876f19a

Browse files
committed
Fix dump method TypeError when path argument is provided
The dump method was failing with a TypeError when the path argument was provided because it attempted to use += to concatenate a string to a Path object. Fixed by ensuring pth is always a Path object and using proper Path concatenation: pth.parent / (pth.name + ".zip")
1 parent 8a61267 commit 876f19a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pyzotero/zotero.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,12 @@ def dump(self, itemkey, filename=None, path=None):
796796
"""Dump a file attachment to disk, with optional filename and path"""
797797
if not filename:
798798
filename = self.item(itemkey)["data"]["filename"]
799-
pth = Path(path) / filename if path else filename
799+
pth = Path(path) / filename if path else Path(filename)
800800
file = self.file(itemkey)
801801
if self.snapshot:
802802
self.snapshot = False
803-
pth += ".zip"
804-
with Path(pth).open("wb") as f:
803+
pth = pth.parent / (pth.name + ".zip")
804+
with pth.open("wb") as f:
805805
f.write(file)
806806

807807
@retrieve

0 commit comments

Comments
 (0)