def get_required_setting(setting, value_re, invalid_msg):
    """
    Return a constant from ``django.conf.settings``.  The `setting`
    argument is the constant name, the `value_re` argument is a regular
    expression used to validate the setting value and the `invalid_msg`
    argument is used as exception message if the value is not valid.
    """
    try:
        value = getattr(settings, setting)
    except __HOLE__:
        raise AnalyticalException("%s setting: not found" % setting)
    if value is None:
        raise AnalyticalException("%s setting is set to None" % setting)
    value = str(value)
    if not value_re.search(value):
        raise AnalyticalException("%s setting: %s: '%s'"
                                  % (setting, invalid_msg, value))
    return value
dataset/ETHPy150Open jcassee/django-analytical/analytical/utils.py/get_required_setting