# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-## Copyright 2023-2024 Canonical Ltd.## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU Lesser General Public# License version 3 as published by the Free Software Foundation.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# Lesser General Public License for more details.## You should have received a copy of the GNU Lesser General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>."""Global features to be configured by the application."""importcontextlibimportdataclassesimportloggingfromcraft_parts.errorsimportFeatureErrorfromcraft_parts.utilsimportSingletonlogger=logging.getLogger()
[docs]@dataclasses.dataclass(frozen=True)classFeatures(metaclass=Singleton):"""Configurable craft-parts features. :cvar enable_overlay: Enables the overlay step. :cvar enable_partitions: Enables the usage of partitions. """enable_overlay:bool=Falseenable_partitions:bool=Falsedef__post_init__(self)->None:"""Validate feature set. :raises FeatureError: If mutually exclusive features are enabled. """ifself.enable_overlayandself.enable_partitions:raiseFeatureError(message="Cannot enable overlay and partition features.",details="Overlay and partition features are mutually exclusive.",)
[docs]@classmethoddefreset(cls)->None:"""Delete stored class instance."""logger.warning("deleting current features configuration")withcontextlib.suppress(KeyError):delcls._instances[cls]