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

Class Box

box/box.py:157–1277  ·  view source on GitHub ↗

Improved dictionary access through dot notation with additional tools. :param default_box: Similar to defaultdict, return a default value :param default_box_attr: Specify the default replacement. WARNING: If this is not the default 'Box', it will not be recursive :param def

Source from the content-addressed store, hash-verified

155
156
157class Box(dict):
158 """
159 Improved dictionary access through dot notation with additional tools.
160
161 :param default_box: Similar to defaultdict, return a default value
162 :param default_box_attr: Specify the default replacement.
163 WARNING: If this is not the default 'Box', it will not be recursive
164 :param default_box_none_transform: When using default_box, treat keys with none values as absent. True by default
165 :param default_box_create_on_get: On lookup of a key that doesn't exist, create it if missing
166 :param frozen_box: After creation, the box cannot be modified
167 :param camel_killer_box: Convert CamelCase to snake_case
168 :param conversion_box: Check for near matching keys as attributes
169 :param modify_tuples_box: Recreate incoming tuples with dicts into Boxes
170 :param box_safe_prefix: Conversion box prefix for unsafe attributes
171 :param box_duplicates: "ignore", "error" or "warn" when duplicates exists in a conversion_box
172 :param box_intact_types: tuple of types to ignore converting
173 :param box_recast: cast certain keys to a specified type
174 :param box_dots: access nested Boxes by period separated keys in string
175 :param box_dots_exclude: optional regular expression for dotted keys to exclude
176 :param box_class: change what type of class sub-boxes will be created as
177 :param box_namespace: the namespace this (possibly nested) Box lives within
178 """
179
180 _box_config: dict[str, Any]
181
182 _protected_keys = [
183 "to_dict",
184 "to_json",
185 "to_yaml",
186 "from_yaml",
187 "from_json",
188 "from_toml",
189 "to_toml",
190 "merge_update",
191 ] + [attr for attr in dir({}) if not attr.startswith("_")]
192
193 def __new__(
194 cls,
195 *args: Any,
196 default_box: bool = False,
197 default_box_attr: Any = NO_DEFAULT,
198 default_box_none_transform: bool = True,
199 default_box_create_on_get: bool = True,
200 frozen_box: bool = False,
201 camel_killer_box: bool = False,
202 conversion_box: bool = True,
203 modify_tuples_box: bool = False,
204 box_safe_prefix: str = "x",
205 box_duplicates: str = "ignore",
206 box_intact_types: tuple | list = (),
207 box_recast: dict | None = None,
208 box_dots: bool = False,
209 box_dots_exclude: str | None = None,
210 box_class: dict | type[Box] | None = None,
211 box_namespace: tuple[str, ...] | Literal[False] = (),
212 **kwargs: Any,
213 ):
214 """

Callers 15

test_box_listMethod · 0.90
test_box_list_dotsMethod · 0.90
test_config_defaultMethod · 0.90
test_safe_attrsMethod · 0.90
test_camel_killerMethod · 0.90
test_boxMethod · 0.90
test_error_boxMethod · 0.90
test_box_from_dictMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_box_listMethod · 0.72
test_box_list_dotsMethod · 0.72
test_config_defaultMethod · 0.72
test_safe_attrsMethod · 0.72
test_camel_killerMethod · 0.72
test_boxMethod · 0.72
test_error_boxMethod · 0.72
test_box_from_dictMethod · 0.72