"""Carveouts logic.""" from video.constants import stores as stores_constants from video.models.ows import carveouts_python as ows_carveouts_python def is_itunes_carved_out(product_id: int) -> bool: """Check if product has iTunes service level carveouts.""" carveouts_data = ows_carveouts_python.get_carveouts(product_id) def has_itunes_video_carveouts(level: str) -> bool: level_data = carveouts_data.get(level, {}) for each_row in level_data.get("service", []): if each_row.get("service_id") == stores_constants.ITUNES_STORE_ID and ( level == "subaccount" or stores_constants.VIDEO_DISTRIBUTION_TYPE_ID in each_row.get("distribution_types", []) ): return True return False return any( has_itunes_video_carveouts(level) for level in ["account", "subaccount", "product"] )