From 6d96351b37928958f96ea96cf286518b74331ed9 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 6 Aug 2014 16:56:33 +0100 Subject: [PATCH] Remove diff_items utility method This was originally introduced in the Icehouse cycle and is no longer used in Tuskar. Change-Id: I104e046a3a12c6b379fb555d506d076d77a1ea7b --- tuskar/common/utils.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/tuskar/common/utils.py b/tuskar/common/utils.py index 1ad3fa19..d2e4c540 100644 --- a/tuskar/common/utils.py +++ b/tuskar/common/utils.py @@ -91,24 +91,3 @@ def read_cached_file(filename, cache_info, reload_func=None): if reload_func: reload_func(cache_info['data']) return cache_info['data'] - - -def diff_items(old, new, key=None): - """Calculates a difference between two collections of items. - - Returns a tuple of two lists, the first contains all the items from - the ``new`` collection that are not in the ``old`` collection, the - second all the items from the ``old`` collection that are not in the - ``new`` collection. The order of items is preserved. - - If an optional ``key`` function is specified, it is used to compare - the items, instead of comparing them directly. That function may be - called multiple times, so it should have no side effects. - """ - if key is None: - key = lambda item: item - old_keys = set(key(item) for item in old) - new_keys = set(key(item) for item in new) - added = [item for item in new if key(item) not in old_keys] - removed = [item for item in old if key(item) not in new_keys] - return added, removed