MCPcopy Create free account
hub / github.com/dialect-app/dialect / encode_data

Method encode_data

dialect/providers/soup.py:28–44  ·  view source on GitHub ↗

Convert Python data to JSON and bytes. Args: data: Data to encode, anything json.dumps can handle. Returns: The GLib Bytes or None if something failed.

(self, data: Any)

Source from the content-addressed store, hash-verified

26 """ Max number of tries """
27
28 def encode_data(self, data: Any) -> GLib.Bytes | None:
29 """
30 Convert Python data to JSON and bytes.
31
32 Args:
33 data: Data to encode, anything json.dumps can handle.
34
35 Returns:
36 The GLib Bytes or None if something failed.
37 """
38 data_glib_bytes = None
39 try:
40 data_bytes = json.dumps(data).encode("utf-8")
41 data_glib_bytes = GLib.Bytes.new(data_bytes)
42 except Exception as exc:
43 logging.warning(exc)
44 return data_glib_bytes
45
46 def create_message(
47 self, method: str, url: str, data: Any = {}, headers: dict = {}, form: bool = False

Callers 1

create_messageMethod · 0.95

Calls 1

newMethod · 0.45

Tested by

no test coverage detected