def download_data_file(href):
    destination_path = data_file_destination_path(href)
    try:
        url = url_for_href(href)
        response = urllib2.urlopen(url)
        if response.code == 200:
            destination_dir = os.path.dirname(destination_path)
            if not os.path.exists(destination_dir):
                os.makedirs(destination_dir)
            with file(destination_path, 'w') as destination_file:
                destination_file.write(response.read())
        else:
            raise Exception("Unexpected response code %s for data file: %s"
                            % (str(response.code), destination_path))
    except __HOLE__:
        os.remove(destination_path)
        raise
dataset/ETHPy150Open sunlightlabs/clearspending/timeliness/crawler.py/download_data_file