def _cr(reader, elem): return model.CubeRegion( included=elem.attrib["include"], # Combine member selections for Dimensions and Attributes member={ ms.values_for: ms for ms in reader.pop_all(model.MemberSelection) }, )
def cr_from(info: dict, dsd: m.DataStructureDefinition) -> m.CubeRegion: """Create a :class:`.CubeRegion` from a simple :class:`dict` of `info`.""" cr = m.CubeRegion(included=info.pop("included", True)) for dim_id, values in info.items(): dim = cast(m.Dimension, dsd.dimensions.get(dim_id)) values = values.split() if values[0] == "!": included = False values.pop(0) else: included = True cr.member[dim] = m.MemberSelection( included=included, values_for=dim, values=[m.MemberValue(value=value) for value in values], ) return cr