Remove obsolete module highlevel.utils
This commit is contained in:
parent
1243894eb8
commit
7ed6c1d71c
@ -1,24 +0,0 @@
|
||||
from dataclasses import asdict, is_dataclass
|
||||
|
||||
|
||||
def collect_configs(*confs):
|
||||
"""Collect instances of dataclasses to a single dict mapping the classname to the values.
|
||||
|
||||
If any of the passed objects is not a ddataclass or if two instances
|
||||
of the same config class are passed, an error will be raised.
|
||||
|
||||
:param confs: dataclasses
|
||||
:return: Dictionary mapping class names to their instances.
|
||||
"""
|
||||
result = {}
|
||||
|
||||
for conf in confs:
|
||||
if not is_dataclass(conf):
|
||||
raise ValueError(f"Object {conf.__class__.__name__} is not a dataclass.")
|
||||
|
||||
if conf.__class__.__name__ in result:
|
||||
raise ValueError(f"Duplicate instance of {conf.__class__.__name__} found.")
|
||||
|
||||
result[conf.__class__.__name__] = asdict(conf)
|
||||
|
||||
return result
|
Loading…
x
Reference in New Issue
Block a user