Download approved top 1M lists.

def process_whitelists():
    """Download approved top 1M lists."""
    import csv
    import grequests
    import os
    import StringIO
    import zipfile
    mapping = {
        'http://s3.amazonaws.com/alexa-static/top-1m.csv.zip': {
            'name': 'alexa.txt'
        }, 'http://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip': {
            'name': 'cisco.txt'
        }
    }
    rs = (grequests.get(u) for u in mapping.keys())
    responses = grequests.map(rs)
    for r in responses:
        data = zipfile.ZipFile(StringIO.StringIO(r.content)).read('top-1m.csv')
        stream = StringIO.StringIO(data)
        reader = csv.reader(stream, delimiter=',', quoting=csv.QUOTE_MINIMAL)
        items = [row[1].strip() for row in reader]
        stream.close()

        config_path = os.path.expanduser('~/.config/blockade')
        file_path = os.path.join(config_path, mapping[r.url]['name'])
        handle = open(file_path, 'w')
        for item in items:
            if item.count('.') == 0:
                continue
            handle.write(item + "\n")
        handle.close()
    return True