-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add upload and download backup APIs * Add model changes * Fix fixtures * Apply suggestions from code review --------- Co-authored-by: Stefan Agner <[email protected]>
- Loading branch information
Showing
19 changed files
with
393 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ class ResponseType(StrEnum): | |
|
||
NONE = "none" | ||
JSON = "json" | ||
STREAM = "stream" | ||
TEXT = "text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Utilities used internally in library.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Utilities for interacting with aiohttp.""" | ||
|
||
from typing import Self | ||
|
||
from aiohttp import StreamReader | ||
|
||
|
||
class ChunkAsyncStreamIterator: | ||
"""Async iterator for chunked streams. | ||
Based on aiohttp.streams.ChunkTupleAsyncStreamIterator, but yields | ||
bytes instead of tuple[bytes, bool]. | ||
Borrowed from home-assistant/core. | ||
""" | ||
|
||
__slots__ = ("_stream",) | ||
|
||
def __init__(self, stream: StreamReader) -> None: | ||
"""Initialize.""" | ||
self._stream = stream | ||
|
||
def __aiter__(self) -> Self: | ||
"""Iterate.""" | ||
return self | ||
|
||
async def __anext__(self) -> bytes: | ||
"""Yield next chunk.""" | ||
rv = await self._stream.readchunk() | ||
if rv == (b"", False): | ||
raise StopAsyncIteration | ||
return rv[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.