Skip to content

links

Replicate of LinksMapper in OPTIMADE Python tools.

LinksMapper

Bases: BaseResourceMapper

Replicate of LinksMapper in OPTIMADE Python tools.

This is based on the OPTIMADE Gateway BaseResourceMapper however.

Source code in optimade_gateway/mappers/links.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class LinksMapper(BaseResourceMapper):
    """Replicate of
    [`LinksMapper`](https://www.optimade.org/optimade-python-tools/api_reference/server/mappers/links/#optimade.server.mappers.links.LinksMapper)
    in OPTIMADE Python tools.

    This is based on the OPTIMADE Gateway
    [`BaseResourceMapper`][optimade_gateway.mappers.base.BaseResourceMapper] however.
    """

    ENDPOINT = "links"
    ENTRY_RESOURCE_CLASS = LinksResource

    @classmethod
    def map_back(cls, doc: dict) -> dict:
        type_ = doc.get("type") or "links"
        newdoc = super().map_back(doc)
        newdoc["type"] = type_
        return newdoc