Exemplo n.º 1
0
def metadata_criterion(value):
    """
    Return a Criterion which matches against metadata.

    :param value: a dictionary, mapping a regular expression of a metadata key
        to a regular expression describing a metadata value.
    :type value: dict mapping unicode to unicode
    """
    def predicate(attribute):
        for k, v in value.items():
            if not re.compile(v).match(attribute.get(k, "")):
                return False
        return True
    return Criterion(name='metadata', predicate=predicate)
Exemplo n.º 2
0
def tenant_id_criterion(value):
    """
    Return a Criterion which matches the given regular expression string
    against the ``"tenant_Id"`` attribute.
    """
    return Criterion(name='tenant_id', predicate=regexp_predicate(value))
Exemplo n.º 3
0
def username_criterion(value):
    """
    Return a Criterion which matches the given regular expression string
    against the ``"username"`` attribute.
    """
    return Criterion(name='username', predicate=regexp_predicate(value))