MCPcopy Create free account
hub / github.com/cdgriffith/Box / SBox

Class SBox

box/shorthand_box.py:10–47  ·  view source on GitHub ↗

ShorthandBox (SBox) allows for property access of `dict` `json` and `yaml`

Source from the content-addressed store, hash-verified

8
9
10class SBox(Box):
11 """
12 ShorthandBox (SBox) allows for
13 property access of `dict` `json` and `yaml`
14 """
15
16 _protected_keys = dir({}) + [
17 "to_dict",
18 "to_json",
19 "to_yaml",
20 "json",
21 "yaml",
22 "from_yaml",
23 "from_json",
24 "dict",
25 "toml",
26 "from_toml",
27 "to_toml",
28 ]
29
30 @property
31 def dict(self) -> dict:
32 return self.to_dict()
33
34 @property
35 def json(self) -> str:
36 return self.to_json()
37
38 @property
39 def yaml(self) -> str:
40 return self.to_yaml()
41
42 @property
43 def toml(self) -> str:
44 return self.to_toml()
45
46 def __repr__(self):
47 return f"{self.__class__.__name__}({self})"
48
49
50class DDBox(SBox):

Calls

no outgoing calls