"""Feature flags on backend.""" from flask import g from pythonfeatures import pythonfeatures from pythonfeatures.constants import split as split_constants BLOCK_MORE_EXPLICIT_WORDS_IN_DPB = 'block_more_explicit_words_in_dpb' def is_feature_flag_enabled(flag_name): """Check if users requested feature flag is enabled.""" g.ows.log.info( f'Calling pythonfeatures for "{flag_name}" flag ' f'with context type "{g.request_context.context_type}"') message = pythonfeatures.get_single_feature( flag_name, g.request_context ).message g.ows.log.info( f'The pythonfeatures response message is "{message}" ' f'is_feature_flag_enabled returns ' f'"{message == split_constants.FEATURE_ENABLED}"') return message == split_constants.FEATURE_ENABLED