Merge "Remove unused ceilometer.utils.update_nested"

This commit is contained in:
Zuul 2017-11-27 23:25:54 +00:00 committed by Gerrit Code Review
commit 6f946db775
2 changed files with 0 additions and 43 deletions

View File

@ -111,30 +111,3 @@ class TestUtils(base.BaseTestCase):
self.assertEqual(utils.hash_of_set(x), utils.hash_of_set(y))
self.assertNotEqual(utils.hash_of_set(x), utils.hash_of_set(z))
self.assertNotEqual(utils.hash_of_set(y), utils.hash_of_set(z))
def test_update_nested(self):
original_dict = {'a': 'A',
'b': 'B',
'nested': {'a': 'A',
'b': 'B',
'nested': {'a': 'A',
'b': 'B'
}
}
}
updates = {'a': 'a',
'nested': {'a': 'nested.a',
'nested': {'a': 'nested.twice.a'}
}
}
expected_dict = {'a': 'a',
'b': 'B',
'nested': {'a': 'nested.a',
'b': 'B',
'nested': {'a': 'nested.twice.a',
'b': 'B'
}
}
}
dict_to_update = utils.update_nested(original_dict, updates)
self.assertEqual(dict_to_update, expected_dict)

View File

@ -19,7 +19,6 @@
"""Utilities and helper functions."""
import calendar
import copy
import datetime
import decimal
import threading
@ -143,21 +142,6 @@ def dict_to_keyval(value, key_base=None):
yield key_gen, v
def update_nested(original_dict, updates):
"""Updates the leaf nodes in a nest dict.
Updates occur without replacing entire sub-dicts.
"""
dict_to_update = copy.deepcopy(original_dict)
for key, value in six.iteritems(updates):
if isinstance(value, dict):
sub_dict = update_nested(dict_to_update.get(key, {}), value)
dict_to_update[key] = sub_dict
else:
dict_to_update[key] = updates[key]
return dict_to_update
def hash_of_set(s):
return str(hash(frozenset(s)))