"""Feature flags logic.""" import re from flask import g from pythonfeatures import pythonfeatures from pythonfeatures.constants import split as split_constants def _check_feature_flag(feature_flag): """Check if a feature flag is enabled.""" return ( pythonfeatures.get_single_feature(feature_flag, g.request_context).message == split_constants.FEATURE_ENABLED ) def get_mobile_features(): """Get all mobile feature flags.""" features = pythonfeatures.get_all_features(g.request_context) mobile_features = { k: v for k, v in features.message.items() if re.search("^mobile_.*$", k) is not None } return mobile_features