"""Features utilities.""" from pythonfeatures import pythonfeatures def _check_feature_enabled_by_attribute(feature, attr_key, attr_val): """Check if a feature is enabled. Args: feature (str): Feature to check attr_key (str): The attribute name to check attr_val (str): The attribute value Returns: bool """ feature_response = pythonfeatures.get_single_feature_by_attributes( feature, {attr_key: attr_val} ) message = feature_response.message if feature_response.status == 200 else "fetch_failed" enabled = message == "enabled" print(f"feature: {feature}, attr_key: {attr_key}, attr_val: {attr_val}, enabled: {enabled}") return enabled def is_feature_enabled_for_account(feature, account_id): """Check if a feature is enabled for account.""" return _check_feature_enabled_by_attribute(feature, "vendor_id", account_id)