def get_templ()

in geneve/solver/type_keyword.py [0:0]


def get_templ(field, constraints):
    templ = Strings()
    templ.min_star_len = 1
    templ.max_star_len = 12

    for k, v, *_ in constraints:
        if k in ("==", "wildcard"):
            if not isinstance(v, (list, tuple)):
                v = [v]
            new_value = templ & v
            if not new_value:
                v = "', '".join(sorted(v))
                raise ConflictError(f"not in {templ}: ('{v}')", field)
            templ = new_value
        elif k in ("!=", "not wildcard"):
            if not isinstance(v, (list, tuple)):
                v = [v]
            new_value = templ - v
            if not new_value:
                v = "', '".join(sorted(v))
                raise ConflictError(f"excluded by {templ}: ('{v}')", field)
            templ = new_value

    return templ