Remove unused dict functions from utils
These aren't used any more. Change-Id: Iffb4954691c288c2729171182fd5ee21f8613d2b
This commit is contained in:
@@ -410,12 +410,6 @@ def get_my_linklocal(interface):
|
|||||||
raise exception.NovaException(msg)
|
raise exception.NovaException(msg)
|
||||||
|
|
||||||
|
|
||||||
def str_dict_replace(s, mapping):
|
|
||||||
for s1, s2 in mapping.iteritems():
|
|
||||||
s = s.replace(s1, s2)
|
|
||||||
return s
|
|
||||||
|
|
||||||
|
|
||||||
class LazyPluggable(object):
|
class LazyPluggable(object):
|
||||||
"""A pluggable backend loaded lazily based on some value."""
|
"""A pluggable backend loaded lazily based on some value."""
|
||||||
|
|
||||||
@@ -524,44 +518,6 @@ def get_from_path(items, path):
|
|||||||
return get_from_path(results, remainder)
|
return get_from_path(results, remainder)
|
||||||
|
|
||||||
|
|
||||||
def flatten_dict(dict_, flattened=None):
|
|
||||||
"""Recursively flatten a nested dictionary."""
|
|
||||||
flattened = flattened or {}
|
|
||||||
for key, value in dict_.iteritems():
|
|
||||||
if hasattr(value, 'iteritems'):
|
|
||||||
flatten_dict(value, flattened)
|
|
||||||
else:
|
|
||||||
flattened[key] = value
|
|
||||||
return flattened
|
|
||||||
|
|
||||||
|
|
||||||
def partition_dict(dict_, keys):
|
|
||||||
"""Return two dicts, one with `keys` the other with everything else."""
|
|
||||||
intersection = {}
|
|
||||||
difference = {}
|
|
||||||
for key, value in dict_.iteritems():
|
|
||||||
if key in keys:
|
|
||||||
intersection[key] = value
|
|
||||||
else:
|
|
||||||
difference[key] = value
|
|
||||||
return intersection, difference
|
|
||||||
|
|
||||||
|
|
||||||
def map_dict_keys(dict_, key_map):
|
|
||||||
"""Return a dict in which the dictionaries keys are mapped to new keys."""
|
|
||||||
mapped = {}
|
|
||||||
for key, value in dict_.iteritems():
|
|
||||||
mapped_key = key_map[key] if key in key_map else key
|
|
||||||
mapped[mapped_key] = value
|
|
||||||
return mapped
|
|
||||||
|
|
||||||
|
|
||||||
def subset_dict(dict_, keys):
|
|
||||||
"""Return a dict that only contains a subset of keys."""
|
|
||||||
subset = partition_dict(dict_, keys)[0]
|
|
||||||
return subset
|
|
||||||
|
|
||||||
|
|
||||||
def diff_dict(orig, new):
|
def diff_dict(orig, new):
|
||||||
"""
|
"""
|
||||||
Return a dict describing how to change orig to new. The keys
|
Return a dict describing how to change orig to new. The keys
|
||||||
|
|||||||
Reference in New Issue
Block a user