dot

packages and services management
Log | Files | Refs | README

commit 7389c237dc7cf9f4f0df9909e9e48710d3274496
parent 92a23737888e013e00928203106b790c271c0ea1
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 12 May 2017 23:44:31 +0200

not needed anymore

Diffstat:
Dutil.py | 49-------------------------------------------------
1 file changed, 0 insertions(+), 49 deletions(-)

diff --git a/util.py b/util.py @@ -1,49 +0,0 @@ -def full_map(li1, li2, key): - """Given a dict: - obj['key'] = 1 - obj.get('key') = 1 - obj1 == obj2 - - and two lists: - li1 = [ obj1, obj2, obj3 ] - obj3.value += 1 - li2 = [ obj1, obj3 ] - - returns : - ( - [], # added - [obj2], # missing - [(old_obj3, new_obj3), ..] # common - ) - - "key" is the sorting key for lists. - """ - def sanitize_keys(li): - i = 0 - for x in li: - if x.get(key) is None: - x[key] = i - i = x[key] - i += 1 - - def has(some_list, key, some_object): - return [ x for x in some_list - if x.get(key) == some_object.get(key) - ] - - def get(some_list, key, some_object): - for x in some_list: - if x.get(key) == some_object.get(key): - return x - - sanitize_keys(li1) - sanitize_keys(li2) - - return ( - [ x for x in li2 if - not has(li1, key, x) ], - [ x for x in li1 if - not has(li2, key, x) ], - [ (get(li1, key, x), x) for x in li2 if - has(li1, key, x) ] - )