def main():
    base_remote_path = "http://idds.census2011.gov.hk/Fact_sheets/CA/"

    if not os.path.exists(base_path):
        logger.info("{} does not exist, creating it".format(base_path))
        os.mkdir(base_path)

    if not os.path.isdir(base_path):
        raise RuntimeError("{} is not a folder".format(base_path))

    files_to_download = []
    skipped = []
    # A list of tuples, first element is remote url, second element is local file

    for code in ALL_AREA_CODES:
        filename = code + ".xlsx"
        url = base_remote_path + filename
        local_file_path = os.path.join(base_path, filename)
        if os.path.exists(local_file_path):
            skipped.append(local_file_path)
        else:
            files_to_download.append((url, local_file_path))

    logger.info('Downloading {} files, {} already exist (skipped)'.format(len(files_to_download), len(skipped)))
    if len(files_to_download) > 0:
        pool = multiprocessing.Pool()
        pool.map(download_file, files_to_download)

    # Check that all the files were downloaded
    files_in_folder = set(os.listdir(base_path))

    assert ALL_FILES.issubset(files_in_folder), "Some files are missing {}".format(ALL_FILES.difference(files_in_folder))
    logger.info("{} files downloaded".format(len(ALL_FILES)))
dataset/ETHPy150Open gazetteerhk/census_explorer/scripts/download_constituency_area_data.py/main/original