Skip to content

Commit

Permalink
Ensure there are no duplicates in the merged/intersected lists
Browse files Browse the repository at this point in the history
  • Loading branch information
kilburn authored and jimi-c committed Jun 9, 2014
1 parent d8c8c08 commit 4dd5eeb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/ansible/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,17 +1006,20 @@ def is_list_of_strings(items):
return True

def list_union(a, b):
result = list(a)
for i in b:
if i not in result:
result.append(i)
result = []
for x in a:
if x not in result:
result.append(x)
for x in b:
if x not in result:
result.append(x)
return result

def list_intersection(a, b):
result = []
for i in a:
if i in b:
result.append(i)
for x in a:
if x in b and x not in result:
result.append(x)
return result

def safe_eval(expr, locals={}, include_exceptions=False):
Expand Down

0 comments on commit 4dd5eeb

Please sign in to comment.