Add a folder and everything inside to zip archive.

    Example::

        |---paper
            |--- algorithm.pdf
            |--- images
                |--- 1.jpg

        zip_a_folder("paper", "paper.zip")

        paper.zip
            |---paper
                |--- algorithm.pdf
                |--- images
                    |--- 1.jpg

    **中文文档**

    将整个文件夹添加到压缩包, 包括根目录本身。

def zip_a_folder(src, dst):
    """Add a folder and everything inside to zip archive.

    Example::

        |---paper
            |--- algorithm.pdf
            |--- images
                |--- 1.jpg

        zip_a_folder("paper", "paper.zip")

        paper.zip
            |---paper
                |--- algorithm.pdf
                |--- images
                    |--- 1.jpg

    **中文文档**

    将整个文件夹添加到压缩包, 包括根目录本身。
    """
    src, dst = os.path.abspath(src), os.path.abspath(dst)
    cwd = os.getcwd()
    todo = list()

    dirname, basename = os.path.split(src)
    os.chdir(dirname)
    for dirname, _, fnamelist in os.walk(basename):
        for fname in fnamelist:
            newname = os.path.join(dirname, fname)
            todo.append(newname)

    with ZipFile(dst, "w") as f:
        for newname in todo:
            f.write(newname)

    os.chdir(cwd)