mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Rabbitmq user permission fixes (#49404)
* Simplify permission changing code for rabbitmq_user module * Add check for multiple permission dicts for same host to rabbitmq_user module * Add docstring for _get_permission method of rabbitmq_user * Fix method that compares vhost permissions in rabbitmq_user * Add tests for rabbitmq_user module * Add helper function for simulating collections.Counter functionality
This commit is contained in:
parent
a1a0893ebd
commit
a4eb4b2551
5 changed files with 174 additions and 21 deletions
|
@ -39,3 +39,18 @@ def is_sequence(seq, include_strings=False):
|
|||
return False
|
||||
|
||||
return isinstance(seq, Sequence)
|
||||
|
||||
|
||||
def count(seq):
|
||||
"""Returns a dictionary with the number of appearances of each element of the iterable.
|
||||
|
||||
Resembles the collections.Counter class functionality. It is meant to be used when the
|
||||
code is run on Python 2.6.* where collections.Counter is not available. It should be
|
||||
deprecated and replaced when support for Python < 2.7 is dropped.
|
||||
"""
|
||||
if not is_iterable(seq):
|
||||
raise Exception('Argument provided is not an iterable')
|
||||
counters = dict()
|
||||
for elem in seq:
|
||||
counters[elem] = counters.get(elem, 0) + 1
|
||||
return counters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue