

def _render_and_upload_maps(s3, good_sources, s3_prefix, dirname):
    ' Render set maps, upload them to S3 and return their URLs.\n    '
    urls = dict()
    areas = ((render.WORLD, 'world'), (render.USA, 'usa'), (render.EUROPE, 'europe'))
    url_kwargs = dict(expires_in=0, query_auth=False, force_http=False)
    key_kwargs = dict(policy='public-read', headers={
        'Content-Type': 'image/png',
    })
    for (area, area_name) in areas:
        png_basename = 'render-{}.png'.format(area_name)
        png_filename = join(dirname, png_basename)
        render.render(dirname, good_sources, 960, 2, png_filename, area)
        with open(png_filename, 'rb') as file:
            render_path = 'render-{}.png'.format(area_name)
            render_key = s3.new_key(join(s3_prefix, png_basename))
            render_key.set_contents_from_string(file.read(), **key_kwargs)
        urls[area_name] = render_key.generate_url(**url_kwargs)
    return (urls['world'], urls['usa'], urls['europe'])

dataset/ETHPy150Open openaddresses/machine/openaddr/ci/__init__.py _render_and_upload_maps/original