mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
Reformat code with black and isort.
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
@@ -11,7 +13,7 @@ from tempfile import TemporaryFile
|
||||
|
||||
|
||||
def write_imitation_archive(file_name, image_id, repo_tags):
|
||||
'''
|
||||
"""
|
||||
Write a tar file meeting these requirements:
|
||||
|
||||
* Has a file manifest.json
|
||||
@@ -24,24 +26,19 @@ def write_imitation_archive(file_name, image_id, repo_tags):
|
||||
:type image_id: str
|
||||
:param repo_tags: list of fake image:tag's
|
||||
:type repo_tags: list
|
||||
'''
|
||||
"""
|
||||
|
||||
manifest = [
|
||||
{
|
||||
'Config': f'{image_id}.json',
|
||||
'RepoTags': repo_tags
|
||||
}
|
||||
]
|
||||
manifest = [{"Config": f"{image_id}.json", "RepoTags": repo_tags}]
|
||||
|
||||
write_imitation_archive_with_manifest(file_name, manifest)
|
||||
|
||||
|
||||
def write_imitation_archive_with_manifest(file_name, manifest):
|
||||
with tarfile.open(file_name, 'w') as tf:
|
||||
with tarfile.open(file_name, "w") as tf:
|
||||
with TemporaryFile() as f:
|
||||
f.write(json.dumps(manifest).encode('utf-8'))
|
||||
f.write(json.dumps(manifest).encode("utf-8"))
|
||||
|
||||
ti = tarfile.TarInfo('manifest.json')
|
||||
ti = tarfile.TarInfo("manifest.json")
|
||||
ti.size = f.tell()
|
||||
|
||||
f.seek(0)
|
||||
@@ -49,19 +46,19 @@ def write_imitation_archive_with_manifest(file_name, manifest):
|
||||
|
||||
|
||||
def write_irrelevant_tar(file_name):
|
||||
'''
|
||||
"""
|
||||
Create a tar file that does not match the spec for "docker image save" / "docker image load" commands.
|
||||
|
||||
:param file_name: Name of tar file to create
|
||||
:type file_name: str
|
||||
'''
|
||||
"""
|
||||
|
||||
tf = tarfile.open(file_name, 'w')
|
||||
tf = tarfile.open(file_name, "w")
|
||||
try:
|
||||
with TemporaryFile() as f:
|
||||
f.write('Hello, world.'.encode('utf-8'))
|
||||
f.write("Hello, world.".encode("utf-8"))
|
||||
|
||||
ti = tarfile.TarInfo('hi.txt')
|
||||
ti = tarfile.TarInfo("hi.txt")
|
||||
ti.size = f.tell()
|
||||
|
||||
f.seek(0)
|
||||
|
||||
Reference in New Issue
Block a user