in hpcpack-autoscaler/src/cyclecloud-hpcpack/commonutil.py [0:0]
def make_dict_single(
source: List[T], keyfunc: Callable[[T], K], valuefunc: Callable[[T], V] = lambda x: x, strict: bool = True) -> Dict[K, V]:
result = make_dict(source, keyfunc, valuefunc)
ret: Dict[K, V] = {}
for key, value in result.items():
if len(value) > 1:
if strict or not reduce(lambda x, y: x == y, value): # type: ignore
raise RuntimeError(
"Could not partition list into single values - key={} values={}".format(
key, value,
)
)
ret[key] = value[0]
return ret