|
| 1 | +""" |
| 2 | +Typehints |
| 3 | +========= |
| 4 | +@ Dash File Cache: components |
| 5 | +
|
| 6 | +Author |
| 7 | +------ |
| 8 | +Yuchen Jin (cainmagi) |
| 9 | +cainmagi@gmail.com |
| 10 | +
|
| 11 | +License |
| 12 | +------- |
| 13 | +MIT License |
| 14 | +
|
| 15 | +Description |
| 16 | +----------- |
| 17 | +Extra typehints used for annotating the component properties. |
| 18 | +""" |
| 19 | + |
| 20 | +from typing_extensions import Literal, TypedDict |
| 21 | + |
| 22 | + |
| 23 | +__all__ = ("DownloaderURL", "DownloaderStatus") |
| 24 | + |
| 25 | + |
| 26 | +class DownloaderURL(TypedDict): |
| 27 | + """The component property `Downloader(url=...)`. |
| 28 | +
|
| 29 | + The URL used to access the data to be downloaded. |
| 30 | +
|
| 31 | + Each time when this value is set, a download event will be triggered. After |
| 32 | + triggering the download event, this value will be reset by a blank string. |
| 33 | + """ |
| 34 | + |
| 35 | + url: str |
| 36 | + """The URL used to access the data to be downloaded.""" |
| 37 | + |
| 38 | + file_name_fallback: str |
| 39 | + """A maunally configured file name. If this file name is configured, it will |
| 40 | + be used when the file name cannot be parsed in the headers. This configuration |
| 41 | + is useful when the URL is from a cross-origin site.""" |
| 42 | + |
| 43 | + |
| 44 | +class DownloaderStatus(TypedDict): |
| 45 | + """The component property `Downloader(status=...)`. |
| 46 | +
|
| 47 | + The status code when a downloading event is finalized. |
| 48 | +
|
| 49 | + If multiple downloading events are triggered by the same downloader, the later |
| 50 | + event will overwrite the status from the former events. |
| 51 | + """ |
| 52 | + |
| 53 | + type: Literal[ |
| 54 | + "success", "error-connect", "error-config", "error-io", "error-unknown" |
| 55 | + ] |
| 56 | + """The status code of the event. If the event is successful, this value should. |
| 57 | + be "success" once the downloading event is finalized. |
| 58 | + """ |
| 59 | + |
| 60 | + http_code: int |
| 61 | + """The HTTP code from the response. If the event is successful, this value should |
| 62 | + be in the range of 200-299..""" |
0 commit comments