示例#1
0
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")
示例#2
0
文件: from_file.py 项目: jkylling/Box
def _to_toml(data):
    try:
        return Box.from_toml(data)
    except TomlDecodeError:
        raise BoxError('File is not TOML as expected')