moneyapi / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

get_media does not implement __enter__, MediaBaseIoDownload does not implement __iter__ #257

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
## Steps ##
1. downloader MediaIoBaseDownload(writer, 
storage.objects().get_media()).next_chunk()
2. progress, done = downloader.next_chunk()

## Expected ##
The standard buffer pattern in python is as follows:

with open(path) as fp:
 for buf in fp:
   print buf

This works with open(), gfile.GFile(), requests.get(URL, stream=True), 
urllib2.urlopen.

I would expect this to be something like:

with storage.objects().get_media() as fp:
 for buf in fp:
   # print fp.progress, fp.done
   buffer.write(buf)

Specifically I think the following would be fantastic:
 get_media returns an object with __enter__ and __exit__ values that create Downloader classes, which implement __iter__ for chunksize 

## Version ##

linux, pip install google-api-python-client

Original issue reported on code.google.com by fe...@google.com on 8 Apr 2013 at 5:38

GoogleCodeExporter commented 8 years ago

Original comment by jcgregorio@google.com on 5 Aug 2013 at 1:58