Files
boost_beast/python/beast/util/Dict.py
T

17 lines
540 B
Python
Raw Normal View History

2014-04-09 15:33:34 -04:00
from __future__ import absolute_import, division, print_function, unicode_literals
def compose(*dicts):
result = {}
for d in dicts:
result.update(**d)
return result
def get_items_with_prefix(key, mapping):
"""Get all elements from the mapping whose keys are a prefix of the given
key, sorted by increasing key length."""
for k, v in sorted(mapping.items()):
if key.startswith(k):
yield v
def compose_prefix_dicts(key, mapping):
return compose(*get_items_with_prefix(key, mapping))