← 返回首页
links - OPTIMADE Python tools
Skip to content
OPTIMADE Python tools
links
optimade-python-tools

links

LinksMapper

Bases: BaseResourceMapper

Source code in optimade/server/mappers/links.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
class LinksMapper(BaseResourceMapper): ENTRY_RESOURCE_CLASS = LinksResource def map_back(self, doc: dict) -> dict: """Map properties from MongoDB to OPTIMADE :param doc: A resource object in MongoDB format :type doc: dict :return: A resource object in OPTIMADE format :rtype: dict """ type_ = doc["type"] newdoc = super().map_back(doc) newdoc["type"] = type_ return newdoc

__init__(config=None)

Parameters:

Name Type Description Default
config ServerConfig | None

Server CONFIG-like object (must expose: .provider.prefix, .provider_fields, .aliases, .length_aliases)

None
Source code in optimade/server/mappers/entries.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
def __init__(self, config: ServerConfig | None = None): """ Args: config: Server CONFIG-like object (must expose: .provider.prefix, .provider_fields, .aliases, .length_aliases) """ if config is None: config = ServerConfig() self.config = config try: from optimade.server.data import providers as PROVIDERS # type: ignore except (ImportError, ModuleNotFoundError): PROVIDERS = {} self.providers = PROVIDERS self.KNOWN_PROVIDER_PREFIXES: set[str] = { prov["id"] for prov in self.providers.get("data", []) }

map_back(doc)

Map properties from MongoDB to OPTIMADE

:param doc: A resource object in MongoDB format :type doc: dict

:return: A resource object in OPTIMADE format :rtype: dict

Source code in optimade/server/mappers/links.py
10 11 12 13 14 15 16 17 18 19 20 21 22
def map_back(self, doc: dict) -> dict: """Map properties from MongoDB to OPTIMADE :param doc: A resource object in MongoDB format :type doc: dict :return: A resource object in OPTIMADE format :rtype: dict """ type_ = doc["type"] newdoc = super().map_back(doc) newdoc["type"] = type_ return newdoc