def zipit(dirname, zfname):
    """
    Create a zipfile on zfname, containing the contents of dirname'
    """
    dirname = _coerceToFilesystemEncoding('', dirname)
    zfname = _coerceToFilesystemEncoding('', zfname)

    with zipfile.ZipFile(zfname, "w") as zf:
        for root, ignored, files, in os.walk(dirname):
            for fname in files:
                fspath = os.path.join(root, fname)
                arcpath = os.path.join(root, fname)[len(dirname)+1:]
                zf.write(fspath, arcpath)

    Create a zipfile on zfname, containing the contents of dirname'
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_zippath.py