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

Method from_toml

box/box.py:1496–1520  ·  view source on GitHub ↗

Transforms a toml string or file into a Box object :param toml_string: string to pass to `toml.load` :param filename: filename to open and pass to `toml.load` :param encoding: File encoding :param errors: How to handle encoding errors

(
            cls,
            toml_string: str | None = None,
            filename: str | PathLike | None = None,
            encoding: str = "utf-8",
            errors: str = "strict",
            **kwargs,
        )

Source from the content-addressed store, hash-verified

1494
1495 @classmethod
1496 def from_toml(
1497 cls,
1498 toml_string: str | None = None,
1499 filename: str | PathLike | None = None,
1500 encoding: str = "utf-8",
1501 errors: str = "strict",
1502 **kwargs,
1503 ) -> Box:
1504 """
1505 Transforms a toml string or file into a Box object
1506
1507 :param toml_string: string to pass to `toml.load`
1508 :param filename: filename to open and pass to `toml.load`
1509 :param encoding: File encoding
1510 :param errors: How to handle encoding errors
1511 :param kwargs: parameters to pass to `Box()`
1512 :return: Box object
1513 """
1514 box_args = {}
1515 for arg in kwargs.copy():
1516 if arg in BOX_PARAMETERS:
1517 box_args[arg] = kwargs.pop(arg)
1518
1519 data = _from_toml(toml_string=toml_string, filename=filename, encoding=encoding, errors=errors)
1520 return cls(data, **box_args)
1521
1522 else:
1523

Callers 7

test_box_list_to_tomlMethod · 0.45
test_tomlMethod · 0.45
_to_tomlFunction · 0.45
box_from_stringFunction · 0.45

Calls 4

_from_tomlFunction · 0.90
BoxErrorClass · 0.90
copyMethod · 0.80
popMethod · 0.45

Tested by 5

test_box_list_to_tomlMethod · 0.36
test_tomlMethod · 0.36