"""Features-related functions.""" from typing import Any, Mapping from pythonfeatures import pythonfeatures ABACUS_FLOWTHROUGH_AUTOMATION = 'abacus_flowthrough_automation' def is_abacus_flowthrough_automation_enabled( attributes: Mapping[str, Any] | None, ) -> bool: """Check if abacus_flowthrough_automation is enabled.""" return _is_feature_enabled(ABACUS_FLOWTHROUGH_AUTOMATION, attributes) def _is_feature_enabled(feature: str, attributes: Mapping[str, Any] | None) -> bool: """Check if a feature is enabled. Args: feature (str): Feature to check attributes: parameter to filter features based on split rules eg. {'identity_id': 'h7c2f7b1-e22e-4151-959f-a65767cbc473'} Returns: bool """ feature_response = pythonfeatures.get_single_feature_by_attributes( feature, attributes ) message = ( feature_response.message if feature_response.status == 200 else 'fetch_failed' ) return message == 'enabled'