Status of a resumable download.
| 257 | |
| 258 | |
| 259 | class MediaDownloadProgress(object): |
| 260 | """Status of a resumable download.""" |
| 261 | |
| 262 | def __init__(self, resumable_progress, total_size): |
| 263 | """Constructor. |
| 264 | |
| 265 | Args: |
| 266 | resumable_progress: int, bytes received so far. |
| 267 | total_size: int, total bytes in complete download. |
| 268 | """ |
| 269 | self.resumable_progress = resumable_progress |
| 270 | self.total_size = total_size |
| 271 | |
| 272 | def progress(self): |
| 273 | """Percent of download completed, as a float. |
| 274 | |
| 275 | Returns: |
| 276 | the percentage complete as a float, returning 0.0 if the total size of |
| 277 | the download is unknown. |
| 278 | """ |
| 279 | if self.total_size is not None and self.total_size != 0: |
| 280 | return float(self.resumable_progress) / float(self.total_size) |
| 281 | else: |
| 282 | return 0.0 |
| 283 | |
| 284 | |
| 285 | class MediaUpload(object): |
no outgoing calls
no test coverage detected
searching dependent graphs…