Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_unzip/files/create_zip.py

raw
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2019, Ansible Project
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 from __future__ import (absolute_import, division, print_function)
8 __metaclass__ = type
9
10 import sys
11 import tempfile
12 import zipfile
13
14
15 def main():
16 filename = b"caf\xc3\xa9.txt"
17
18 with tempfile.NamedTemporaryFile() as temp:
19 with open(temp.name, mode="wb") as fd:
20 fd.write(filename)
21
22 with open(sys.argv[1], mode="wb") as fd:
23 with zipfile.ZipFile(fd, "w") as zip:
24 zip.write(temp.name, filename.decode('utf-8'))
25
26
27 if __name__ == '__main__':
28 main()