MCPcopy Index your code
hub / github.com/Textualize/textual / dump

Function dump

src/textual/_binary_encode.py:28–166  ·  view source on GitHub ↗

Encodes a data structure into bytes. Args: data: Data structure Returns: A byte string encoding the data.

(data: object)

Source from the content-addressed store, hash-verified

26
27
28def dump(data: object) -> bytes:
29 """Encodes a data structure into bytes.
30
31 Args:
32 data: Data structure
33
34 Returns:
35 A byte string encoding the data.
36 """
37
38 def encode_none(_datum: None) -> bytes:
39 """
40 Encodes a None value.
41
42 Args:
43 datum: Always None.
44
45 Returns:
46 None encoded.
47 """
48 return b"N"
49
50 def encode_bool(datum: bool) -> bytes:
51 """
52 Encode a boolean value.
53
54 Args:
55 datum: The boolean value to encode.
56
57 Returns:
58 The encoded bytes.
59 """
60 return b"T" if datum else b"F"
61
62 def encode_int(datum: int) -> bytes:
63 """
64 Encode an integer value.
65
66 Args:
67 datum: The integer value to encode.
68
69 Returns:
70 The encoded bytes.
71 """
72 return b"i%ie" % datum
73
74 def encode_bytes(datum: bytes) -> bytes:
75 """
76 Encode a bytes value.
77
78 Args:
79 datum: The bytes value to encode.
80
81 Returns:
82 The encoded bytes.
83 """
84 return b"%i:%s" % (len(datum), datum)
85

Callers 2

test_round_tripFunction · 0.90
test_dump_invalid_typeFunction · 0.90

Calls 1

encodeFunction · 0.85

Tested by 2

test_round_tripFunction · 0.72
test_dump_invalid_typeFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…