diff --git a/craft_parts/__init__.py b/craft_parts/__init__.py index cd402e27..3f52026c 100644 --- a/craft_parts/__init__.py +++ b/craft_parts/__init__.py @@ -26,7 +26,13 @@ from .features import Features from .infos import PartInfo, ProjectInfo, StepInfo from .lifecycle_manager import LifecycleManager -from .parts import Part, part_has_overlay, validate_part +from .parts import ( + Part, + part_has_chisel_as_build_snap, + part_has_slices, + part_has_overlay, + validate_part, +) from .steps import Step __all__ = [ @@ -46,4 +52,6 @@ "expand_environment", "validate_part", "part_has_overlay", + "part_has_slices", + "part_has_chisel_as_build_snap", ] diff --git a/craft_parts/parts.py b/craft_parts/parts.py index 7c689bf4..87725b81 100644 --- a/craft_parts/parts.py +++ b/craft_parts/parts.py @@ -684,6 +684,26 @@ def part_has_overlay(data: dict[str, Any]) -> bool: return spec.has_overlay +def part_has_slices(data: dict[str, Any]) -> bool: + """Whether the part described by ``data`` contains slices. + + :param data: The part data to query. + """ + spec = _get_part_spec(data) + + return spec.has_slices + + +def part_has_chisel_as_build_snap(data: dict[str, Any]) -> bool: + """Whether the part described by ``data`` has chisel in build-snaps. + + :param data: The part data to query. + """ + spec = _get_part_spec(data) + + return spec.has_chisel_as_build_snap + + def _get_part_spec(data: dict[str, Any]) -> PartSpec: if not isinstance(data, dict): raise TypeError("value must be a dictionary")