Refactor tagging: create functions, better logs and names, textwrap.dedent (#2239)

This commit is contained in:
Ayaz Salikhov
2025-02-23 20:41:04 +00:00
committed by GitHub
parent 6c47a89558
commit 123d215128
8 changed files with 126 additions and 89 deletions

View File

@@ -0,0 +1,12 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tagging.hierarchy.images_hierarchy import ALL_IMAGES
from tagging.manifests.manifest_interface import ManifestInterface
def get_manifests(image: str | None) -> list[ManifestInterface]:
if image is None:
return []
image_description = ALL_IMAGES[image]
parent_manifests = get_manifests(image_description.parent_image)
return parent_manifests + image_description.manifests

View File

@@ -0,0 +1,12 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tagging.hierarchy.images_hierarchy import ALL_IMAGES
from tagging.taggers.tagger_interface import TaggerInterface
def get_taggers(image: str | None) -> list[TaggerInterface]:
if image is None:
return []
image_description = ALL_IMAGES[image]
parent_taggers = get_taggers(image_description.parent_image)
return parent_taggers + image_description.taggers

View File

@@ -1,21 +0,0 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
from tagging.hierarchy.images_hierarchy import ALL_IMAGES
from tagging.manifests.manifest_interface import ManifestInterface
from tagging.taggers.tagger_interface import TaggerInterface
def get_taggers_and_manifests(
image: str | None,
) -> tuple[list[TaggerInterface], list[ManifestInterface]]:
if image is None:
return [], []
image_description = ALL_IMAGES[image]
parent_taggers, parent_manifests = get_taggers_and_manifests(
image_description.parent_image
)
return (
parent_taggers + image_description.taggers,
parent_manifests + image_description.manifests,
)