Package sabayon :: Module util :: Class DictCompare
[hide private]
[frames] | no frames]

Class DictCompare

source code

Instance Methods [hide private]
  __init__(self, a, b)
  compare(self)
Given two dictionaries a,b analyze them for their differences and similarities.
  intersection(self)
return list of keys shared between a and b
  only_a(self)
return list of keys only present in a
  only_b(self)
return list of keys only present in b
  equal(self)
return list of keys present in both a and b whole values are equal
  not_equal(self)
return list of keys present in both a and b whole values are not equal
  get_change_set(self, dict_lhs, dict_rhs)
Return changes necessary to make dict_lhs equivalent to dict_rhs, (e.g.
  is_equal(self)
  dump(self)
Print the results of the dictionary comparision

Method Details [hide private]

__init__(self, a, b)
(Constructor)

source code 
None

compare(self)

source code 

Given two dictionaries a,b analyze them for their differences and similarities.

intersection - keys shared between a and b only_a - keys only present in a only_b - keys only present in b equal - keys present in both a and b whole values are equal not_equal - keys present in both a and b whole values are not equal

intersection(self)

source code 
return list of keys shared between a and b

only_a(self)

source code 
return list of keys only present in a

only_b(self)

source code 
return list of keys only present in b

equal(self)

source code 
return list of keys present in both a and b whole values are equal

not_equal(self)

source code 
return list of keys present in both a and b whole values are not equal

get_change_set(self, dict_lhs, dict_rhs)

source code 

Return changes necessary to make dict_lhs equivalent to dict_rhs, (e.g. lhs = rhs), the two dictionary parameters are specified as either the string 'a' or the string 'b' corresponding to the parameters this class was created with.

Return value is a dictionary with 3 keys (add, del, mod) whose values are dictionaries containing containing (key,value) pairs to add, delete, or modify respectively in dict_lhs.

is_equal(self)

source code 
None

dump(self)

source code 
Print the results of the dictionary comparision