def build_policy(config=None, update=None, replace=None):

    if config is None:
        config = from_settings()

    # Update rules from settings.
    if update is not None:
        for key, value in update.items():
            if not isinstance(value, (list, tuple)):
                value = (value,)
            if config[key] is not None:
                config[key] += value
            else:
                config[key] = value

    # Replace rules from settings.
    if replace is not None:
        for key, value in replace.items():
            if value is not None and not isinstance(value, (list, tuple)):
                value = [value]
            config[key] = value

    report_uri = config.pop('report-uri', None)
    policy = ['%s %s' % (k, ' '.join(v)) for k, v in
              sorted(config.items()) if v is not None]
    if report_uri:
        policy.append('report-uri %s' % report_uri)
    return '; '.join(policy)
Data IMC2 -> Evennia.
dataset/ETHPy150Open mozilla/django-csp/csp/utils.py/build_policy--crossover with--dataset/ETHPy150Open evennia/evennia/evennia/server/portal/imc2.py/IMC2Bot.data_in