Esempio n. 1
0
def _dk(reader, elem):
    return model.DataKey(
        included=elem.attrib.get("isIncluded", True),
        # Convert MemberSelection/MemberValue from _ms() to ComponentValue
        key_value={
            ms.values_for: model.ComponentValue(value_for=ms.values_for,
                                                value=ms.values.pop().value)
            for ms in reader.pop_all(model.MemberSelection)
        },
    )
Esempio n. 2
0
def dks(dsd):
    dim = dsd.dimensions.get("FOO")
    yield m.DataKeySet(
        included=True,
        keys=[
            m.DataKey(
                included=True,
                key_value={dim: m.ComponentValue(value_for=dim, value="foo0")},
            )
        ],
    )
Esempio n. 3
0
def dks_from_anno(obj: m.ContentConstraint,
                  dsd: m.DataStructureDefinition) -> None:
    """Convert an annotation on `obj` into a :class:`.DataKeySet` constraint."""
    info = _pop_anno(obj, "_data_content_keys")
    if info is None:
        return

    dks = m.DataKeySet(included=True, keys=[])
    for dim_id, values in info.items():
        dim = dsd.dimensions.get(dim_id)

        for value in values:
            dks.keys.append(
                m.DataKey(
                    key_value={
                        dim: m.ComponentValue(value_for=dim, value=value)
                    },
                    included=True,
                ))

    obj.data_content_keys = dks