Pyzotero: a Python client for the Zotero API pyzotero.readthedocs.io
zotero

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")

authored by urschrei.bsky.social and committed by urschrei.bsky.social 876f19af 8a612675

Changed files
+3 -3
src
pyzotero
+3 -3
src/pyzotero/zotero.py
··· 796 796 """Dump a file attachment to disk, with optional filename and path""" 797 797 if not filename: 798 798 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) 800 800 file = self.file(itemkey) 801 801 if self.snapshot: 802 802 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: 805 805 f.write(file) 806 806 807 807 @retrieve