def _to_toml(file, encoding, errors, **kwargs): if not toml_available: raise BoxError( f'File "{file}" is toml but no package is available to open it. Please install "toml"' ) try: return Box.from_toml(filename=file, encoding=encoding, errors=errors, **kwargs) except TomlDecodeError: raise BoxError("File is not TOML as expected")
def _to_toml(data): try: return Box.from_toml(data) except TomlDecodeError: raise BoxError('File is not TOML as expected')