File: _general_store.py

package info (click to toggle)
python-mp-api 0.45.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,988 kB
  • sloc: python: 6,712; makefile: 14
file content (45 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations

from emmet.core._general_store import GeneralStoreDoc

from mp_api.client.core import BaseRester


class GeneralStoreRester(BaseRester[GeneralStoreDoc]):  # pragma: no cover
    suffix = "_general_store"
    document_model = GeneralStoreDoc  # type: ignore
    primary_key = "submission_id"
    monty_decode = False
    use_document_model = False

    def add_item(self, kind: str, markdown: str, meta: dict):  # pragma: no cover
        """Set general store data.

        Args:
            kind: Data type description
            markdown: Markdown data
            meta: Metadata
        Returns:
            Dictionary with written data and submission id.


        Raises:
            MPRestError.
        """
        return self._post_resource(
            body=meta, params={"kind": kind, "markdown": markdown}
        ).get("data")

    def get_items(self, kind):  # pragma: no cover
        """Get general store data.

        Args:
            kind: Data type description
        Returns:
            List of dictionaries with kind, markdown, metadata, and submission_id.


        Raises:
            MPRestError.
        """
        return self.search(kind=kind)