:py:mod:`dissect.util.feature` ============================== .. py:module:: dissect.util.feature Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.util.feature.Feature Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.util.feature.feature_flags dissect.util.feature.feature_enabled dissect.util.feature.feature Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.util.feature.DISSECT_FEATURES_DEFAULT dissect.util.feature.DISSECT_FEATURES_ENV .. py:class:: Feature Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: LATEST :value: 'latest' .. py:attribute:: ADVANCED :value: 'advanced' .. py:attribute:: BETA :value: 'beta' .. py:data:: DISSECT_FEATURES_DEFAULT :value: 'latest' .. py:data:: DISSECT_FEATURES_ENV :value: 'DISSECT_FEATURES' .. py:exception:: FeatureException Bases: :py:obj:`RuntimeError` Unspecified run-time error. .. py:function:: feature_flags() -> list[Feature] .. py:function:: feature_enabled(feature: Feature) -> bool Use this function for block-level feature flag control. Usage:: def parse_blob(): if feature_enabled(Feature.BETA): self._parse_fast_experimental() else: self._parse_normal() .. py:function:: feature(flag: Feature, alternative: Optional[Callable] = None) -> Callable Feature flag decorator allowing you to guard a function behind a feature flag. Usage:: @feature(Feature.SOME_FLAG, fallback) def my_func( ... ) -> ... Where ``SOME_FLAG`` is the feature you want to check for and ``fallback`` is the alternative function to serve if the feature flag is NOT set.