'This is only for IdPs or AAs, and it\'s about limiting what
is returned to the SP.
In the configuration file, restrictions on which values that
can be returned are specified with the help of regular expressions.
This function goes through and pre-compiles the regular expressions.
:param restrictions:
:return: The assertion with the string specification replaced with
a compiled regular expression.'

def compile(self, restrictions):

    self._restrictions = restrictions.copy()
    for (who, spec) in self._restrictions.items():
        if (spec is None):
            continue
        try:
            items = spec['entity_categories']
        except KeyError:
            pass
        else:
            ecs = []
            for cat in items:
                _mod = importlib.import_module(('saml2.entity_category.%s' % cat))
                _ec = {}
                for (key, items) in _mod.RELEASE.items():
                    _ec[key] = [k.lower() for k in items]
                ecs.append(_ec)
            spec['entity_categories'] = ecs
        try:
            restr = spec['attribute_restrictions']
        except KeyError:
            continue
        if (restr is None):
            continue
        _are = {}
        for (key, values) in restr.items():
            if (not values):
                _are[key.lower()] = None
                continue
            _are[key.lower()] = [re.compile(value) for value in values]
        spec['attribute_restrictions'] = _are
    logger.debug(('policy    restrictions:    %s' % self._restrictions))
    return self._restrictions
