def _promote_or_demote_in_group(self, ret, member_levels, user_levels,
                                    group_id):
        """Promote or demote a set of users.

        :param ret: the current dict of return values
        :param members_levels: the current access levels of each member
        :param user_levels: the desired levels of each member
        :param types: a mapping between resource names and access levels
        :returns: info about what has (or has not) been updated
        :rtype: dict

        """

        reverse_type = {v: k for k, v in self.access_types.items()}

        for login in (set(member_levels.keys()) &
                      set(user_levels.keys())):
            user = self._get_user_by_login(login)
            _id = user["_id"]

            # We're promoting
            if member_levels[login] < user_levels[login]:
                resource = reverse_type[user_levels[login]]
                self.post("group/{}/{}"
                          .format(group_id, resource),
                          {"userId": _id})

                user['from_level'] = member_levels[login]
                user['to_level'] = user_levels[login]
                ret['updated'].append(user)

            # We're demoting
            elif user_levels[login] > member_levels[login]:
                resource = reverse_type[member_levels[login]]
                self.delete("group/{}/{}"
                            .format(group_id, resource),
                            {"userId": _id})

                # In case we're not demoting to member make sure
                # to update to promote to whatever level we ARE
                # demoting too now that our user is a only a member
                if user_levels[login] != 0:
                    resource = reverse_type[user_levels[login]]
                    self.post("group/{}/{}"
                              .format(group_id, resource),
                              {"userId": _id})

                    user['from_level'] = member_levels[login]
                    user['to_level'] = user_levels[login]
                    ret['updated'].append(user)

        return ret
dataset/ETHPy150Open girder/girder/clients/ansible/girder.py/GirderClientModule._promote_or_demote_in_group/swapped operands of `>`