mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-07 17:51:29 -07:00
preserve same order as inventory manager when using host lookup (#55331)
* preserve same order as inventory manager when using inventory_hostnames lookup add a test * move generic code
This commit is contained in:
parent
0330ea616e
commit
afb5e02c19
7 changed files with 37 additions and 3 deletions
|
@ -41,3 +41,11 @@ def object_to_dict(obj, exclude=None):
|
|||
if exclude is None or not isinstance(exclude, list):
|
||||
exclude = []
|
||||
return dict((key, getattr(obj, key)) for key in dir(obj) if not (key.startswith('_') or key in exclude))
|
||||
|
||||
|
||||
def deduplicate_list(original_list):
|
||||
"""
|
||||
Creates a deduplicated list with the order in which each item is first found.
|
||||
"""
|
||||
seen = set()
|
||||
return [x for x in original_list if x not in seen and not seen.add(x)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue