

def build_policy(config=None, update=None, replace=None):
    'Builds the policy as a string from the settings.'
    if (config is None):
        config = 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
    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(value.items()) if (v is not None)]
    if report_uri:
        policy.append(('report-uri %s' % report_uri))
    return '; '.join(policy)

dataset/ETHPy150Open mozilla/django-csp/csp/utils.py build_policy/VarMisuse@227/270 `config`->`value`