Reformat code with black and isort.

This commit is contained in:
Felix Fontein
2025-10-06 18:34:59 +02:00
parent f45232635c
commit d65d37e9e9
132 changed files with 17581 additions and 14729 deletions
@@ -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)