ansible/test/integration/targets/win_unzip/files/create_zip.py
Jordan Borean 2a9ec8975f
win_unzip - LiteralPath fix (#66972)
* win_unzip - LiteralPath fix

* Fix up Python sanity issues
2020-01-31 12:59:46 +10:00

28 lines
689 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
import tempfile
import zipfile
def main():
filename = b"caf\xc3\xa9.txt"
with tempfile.NamedTemporaryFile() as temp:
with open(temp.name, mode="wb") as fd:
fd.write(filename)
with open(sys.argv[1], mode="wb") as fd:
with zipfile.ZipFile(fd, "w") as zip:
zip.write(temp.name, filename.decode('utf-8'))
if __name__ == '__main__':
main()