def process_sources(): with download_sources() as info: fd, suite = info with tmpfile(): f = gzip.open(fd, 'r') try: yield (f, suite) finally: pass f.close()
def download_sources(): with tmpfile() as fd: f = urllib2.urlopen(get_sources_uri()) open(fd, 'w').write(f.read()) yield (fd, _get_context())