python-dropbox-api 0.1.2__py3-none-any.whl → 0.1.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.
@@ -38,15 +38,24 @@ def parse_property_groups(property_groups: list[dict]) -> list[PropertyGroup]:
38
38
 
39
39
  async def handle_common_errors(response: ClientResponse) -> None:
40
40
  """Handle common errors."""
41
- response_json = await response.json()
41
+ if response.ok:
42
+ return
42
43
 
43
- error_summary = response_json.get("error_summary")
44
+ try:
45
+ response_json = await response.json(content_type=None)
44
46
 
45
- if error_summary is not None:
46
- if error_summary.startswith("invalid_access_token/"):
47
- raise DropboxAuthException("Unauthorized")
48
- if error_summary.startswith("path/not_found/"):
49
- raise DropboxFileOrFolderNotFoundException("File or folder not found")
47
+ error_summary = response_json.get("error_summary") if isinstance(response_json, dict) else None
48
+
49
+ if error_summary is not None:
50
+ if error_summary.startswith("invalid_access_token/"):
51
+ raise DropboxAuthException("Unauthorized")
52
+ if error_summary.startswith("path/not_found/"):
53
+ raise DropboxFileOrFolderNotFoundException("File or folder not found")
54
+ except (DropboxAuthException, DropboxFileOrFolderNotFoundException):
55
+ raise
56
+ except json.JSONDecodeError:
57
+ text = await response.text()
58
+ raise DropboxUnknownException(f"{response.status}: {text}")
50
59
 
51
60
  response.raise_for_status()
52
61
 
@@ -299,6 +308,11 @@ class DropboxAPIClient:
299
308
  )
300
309
  offset += len(buffer)
301
310
 
311
+ # Empty file (or a stream that yielded no bytes): no session was ever
312
+ # started, so open one with no data before finishing.
313
+ if session_id is None:
314
+ session_id = await self._start_upload_session(content_api_url, b"")
315
+
302
316
  # Finish upload session
303
317
  await self._finish_upload_session(
304
318
  content_api_url, session_id, offset, path, property_groups
@@ -429,7 +443,7 @@ class DropboxAPIClient:
429
443
  chunk_size = 1024 * 1024 # 1MB
430
444
 
431
445
  async with self._websession.post(url, headers=headers) as response:
432
- response.raise_for_status()
446
+ await handle_common_errors(response)
433
447
  async for chunk in response.content.iter_chunked(chunk_size):
434
448
  if chunk:
435
449
  yield chunk
@@ -465,6 +479,18 @@ class DropboxAPIClient:
465
479
  url, headers=headers, json=payload
466
480
  ) as response:
467
481
  await handle_common_errors(response)
482
+
483
+ response_json = await response.json()
484
+
485
+ # create_folder_v2 wraps the folder metadata under "metadata".
486
+ metadata = response_json["metadata"]
487
+
488
+ return FileOrFolderInfo(
489
+ is_folder=True,
490
+ name=metadata["name"],
491
+ size=None,
492
+ property_groups=None,
493
+ )
468
494
  except (DropboxAuthException, DropboxFileOrFolderNotFoundException):
469
495
  raise
470
496
  except Exception as err:
@@ -1,8 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-dropbox-api
3
- Version: 0.1.2
4
- Summary:
3
+ Version: 0.1.4
4
+ Summary: This is a lightweight wrapper for the Dropbox API intended for use in Home Assistant.
5
5
  License-Expression: MIT
6
+ License-File: LICENSE
6
7
  Author: Brandon Rothweiler
7
8
  Author-email: 2292715+bdr99@users.noreply.github.com
8
9
  Requires-Python: >=3.13
@@ -0,0 +1,10 @@
1
+ python_dropbox_api/__init__.py,sha256=8NVlyqQZvA0Mgds5Pb80irBac5mGPJFwW4MEeMFPOvU,575
2
+ python_dropbox_api/auth.py,sha256=qrPop5F2_UGDmEtNOwhuYwgoHyaQ_wCjeP0B7tMNx38,448
3
+ python_dropbox_api/client.py,sha256=vbLmhwbq2yznZtoS5ErOw5qUOnv_51rCM3hUKXcje6k,23484
4
+ python_dropbox_api/exceptions.py,sha256=HZ8Cf1ET6uqMmMIOXmtRqgLaz59GdYm8fBKLPBnXt-M,706
5
+ python_dropbox_api/models.py,sha256=yhkfVMKPsMJxMzLA0KhSUPt_uoJkrvVjeskKffTKt-M,1604
6
+ python_dropbox_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ python_dropbox_api-0.1.4.dist-info/METADATA,sha256=Kl5T4KAcjUIUMQbSX1hAep_QBS4YBtyogqPGsiYm0-w,647
8
+ python_dropbox_api-0.1.4.dist-info/WHEEL,sha256=eY7nduwzv-ldUxpzbRlxwvC693Hg6PX8bWDjEHjZ_dk,88
9
+ python_dropbox_api-0.1.4.dist-info/licenses/LICENSE,sha256=KEwQxPRqHS1CBUYJkUYSb-dkreLlur_kqtOdilr7SC4,1075
10
+ python_dropbox_api-0.1.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.1
2
+ Generator: poetry-core 2.4.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brandon Rothweiler
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -1,9 +0,0 @@
1
- python_dropbox_api/__init__.py,sha256=8NVlyqQZvA0Mgds5Pb80irBac5mGPJFwW4MEeMFPOvU,575
2
- python_dropbox_api/auth.py,sha256=qrPop5F2_UGDmEtNOwhuYwgoHyaQ_wCjeP0B7tMNx38,448
3
- python_dropbox_api/client.py,sha256=J3_ZBamgEesGIy7fPn6qUXbPBMix-0KbqkEcrDWS914,22463
4
- python_dropbox_api/exceptions.py,sha256=HZ8Cf1ET6uqMmMIOXmtRqgLaz59GdYm8fBKLPBnXt-M,706
5
- python_dropbox_api/models.py,sha256=yhkfVMKPsMJxMzLA0KhSUPt_uoJkrvVjeskKffTKt-M,1604
6
- python_dropbox_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- python_dropbox_api-0.1.2.dist-info/METADATA,sha256=_LTqJMgH-uJGlqwypCutqjNfHC42PmCmZaWHZOVdz8Q,540
8
- python_dropbox_api-0.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
- python_dropbox_api-0.1.2.dist-info/RECORD,,