1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Specify key to use while sorting permissions (#49126)

Without specifying the dictionary key to use while sorting it will fail
in Python 3 environments due to simplifying Python's rules for ordering
comparisons: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
This commit is contained in:
Gregor Wegberg 2018-11-30 21:18:57 +01:00 committed by John R Barker
parent 19035dbcb2
commit 4096d74245

View file

@ -117,6 +117,7 @@ EXAMPLES = '''
write_priv: .* write_priv: .*
state: present state: present
''' '''
import operator
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
@ -230,7 +231,8 @@ class RabbitMqUser(object):
return set(self.tags) != set(self._tags) return set(self.tags) != set(self._tags)
def has_permissions_modifications(self): def has_permissions_modifications(self):
return sorted(self._permissions) != sorted(self.permissions) sort_key_fetch = operator.itemgetter('vhost')
return sorted(self._permissions, key=sort_key_fetch) != sorted(self.permissions, key=sort_key_fetch)
def main(): def main():