def get_grantable_permissions(session, restricted_ownership_permissions):
    owners_by_arg_by_perm = get_owners_by_grantable_permission(session)
    args_by_perm = defaultdict(list)
    for permission, owners_by_arg in owners_by_arg_by_perm.items():
        for argument in owners_by_arg:
            args_by_perm[permission].append(argument)

    def _reduce_args(perm_name, args):
        non_wildcard_args = map(lambda a: a != "*", args)
        if (restricted_ownership_permissions and perm_name in restricted_ownership_permissions and
                any(non_wildcard_args)):
            # at least one none wildcard arg so we only return those and we care
            return sorted({a for a in args if a != "*"})
        elif all(non_wildcard_args):
            return sorted(set(args))
        else:
            # it's all wildcard so return that one
            return ["*"]
    return {p: _reduce_args(p, a) for p, a in args_by_perm.items()}
Return a location resolver.  The *order* argument, if given,
dataset/ETHPy150Open dropbox/grouper/grouper/permissions.py/get_grantable_permissions--crossover with--dataset/ETHPy150Open Kitware/minerva/server/libs/carmen/resolver.py/get_resolver