diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-09-04 21:50:04 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-09-04 22:03:10 +0200 |
commit | 64d58eda4c1ebaa9d346d65d606d2a75694467ee (patch) | |
tree | 4f4c9b9720da401863c664a87e68ceda6a645377 /python | |
parent | ff34756f534bfc0f09a5ab6db0d36e1bf43546a8 (diff) | |
download | vyos-1x-64d58eda4c1ebaa9d346d65d606d2a75694467ee.tar.gz vyos-1x-64d58eda4c1ebaa9d346d65d606d2a75694467ee.zip |
Python/configdict: add list_diff function to compare two lists
A list containing only unique elements not part of the other list is
returned. This is usefull to check e.g. which IP addresses need to be
removed from the OS.
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configdict.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 157011839..a723c5322 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -78,3 +78,11 @@ def retrieve_config(path_hash, base_path, config): config_hash[k][node] = retrieve_config(inner_hash, path + [node], config) return config_hash + + +def list_diff(first, second): + """ + Diff two dictionaries and return only unique items + """ + second = set(second) + return [item for item in first if item not in second] |