def write_zip()

in azext_edge/edge/providers/support_bundle.py [0:0]


def write_zip(bundle: dict, file_path: str):
    with ZipFile(file=file_path, mode="w", compression=ZIP_DEFLATED) as myzip:
        todo: List[dict] = []
        for ops_service in bundle:
            for element in bundle[ops_service]:
                if isinstance(bundle[ops_service][element], list):
                    todo.extend(bundle[ops_service][element])
                else:
                    todo.append(bundle[ops_service][element])

        added_path = {}
        for t in todo:
            if t:
                data = t.get("data")
                zinfo = t.get("zinfo")
                if data and zinfo not in added_path:
                    if isinstance(data, dict):
                        data = yaml.safe_dump(t["data"], indent=2)
                    myzip.writestr(zinfo_or_arcname=zinfo, data=data)
                    added_path[zinfo] = True