box/from_file.py
def box_from_file(
    file: Union[str, PathLike], file_type: str = None, encoding: str = "utf-8", errors: str = "strict", **kwargs
) -> Union[Box, BoxList]:
    """
    Loads the provided file and tries to parse it into a Box or BoxList object as appropriate.

    :param file: Location of file
    :param encoding: File encoding
    :param errors: How to handle encoding errors
    :param file_type: manually specify file type: json, toml or yaml
    :return: Box or BoxList
    """

    if not isinstance(file, Path):
        file = Path(file)
    if not file.exists():
        raise BoxError(f'file "{file}" does not exist')
    file_type = file_type or file.suffix
    file_type = file_type.lower().lstrip(".")
    if file_type.lower() in converters:
        return converters[file_type.lower()](file, encoding, errors, **kwargs)  # type: ignore
    raise BoxError(f'"{file_type}" is an unknown type. Please use either csv, toml, msgpack, yaml or json')

    Loads the provided file and tries to parse it into a Box or BoxList object as appropriate.

    :param file: Location of file
    :param encoding: File encoding
    :param errors: How to handle encoding errors
    :param file_type: manually specify file type: json, toml or yaml
    :return: Box or BoxList
    
Loads the provided file and tries to parse it into a Box or BoxList object as appropriate.
Loads the provided file and tries to parse it into a Box or BoxList object as appropriate .
def box_from_file(
    file: Union[str, PathLike], file_type: str = None, encoding: str = "utf-8", errors: str = "strict", **kwargs
) -> Union[Box, BoxList]:
    if not isinstance(file, Path):
        file = Path(file)
    if not file.exists():
        raise BoxError(f'file "{file}" does not exist')
    file_type = file_type or file.suffix
    file_type = file_type.lower().lstrip(".")
    if file_type.lower() in converters:
        return converters[file_type.lower()](file, encoding, errors, **kwargs)  
    raise BoxError(f'"{file_type}" is an unknown type. Please use either csv, toml, msgpack, yaml or json')
def box_from_file ( file : Union [ str , PathLike ] , file_type : str = None , encoding : str = "utf-8" , errors : str = "strict" , ** kwargs ) -> Union [ Box , BoxList ] : if not isinstance ( file , Path ) : file = Path ( file ) if not file . exists ( ) : raise BoxError ( f'file "{file}" does not exist' ) file_type = file_type or file . suffix file_type = file_type . lower ( ) . lstrip ( "." ) if file_type . lower ( ) in converters : return converters [ file_type . lower ( ) ] ( file , encoding , errors , ** kwargs ) raise BoxError ( f'"{file_type}" is an unknown type. Please use either csv, toml, msgpack, yaml or json' )
Loads the provided file and tries to parse it into a Box or BoxList object as appropriate.
Loads the provided file and tries to parse it into a Box or BoxList object as appropriate .
"""
    Loads the provided file and tries to parse it into a Box or BoxList object as appropriate.

    :param file: Location of file
    :param encoding: File encoding
    :param errors: How to handle encoding errors
    :param file_type: manually specify file type: json, toml or yaml
    :return: Box or BoxList
    """ # type: ignore
Box or BoxList
Box or BoxList
file
Union[str, PathLike]
Location of file
Location of file
file_type
str
manually specify file type: json, toml or yaml
manually specify file type : json toml or yaml
encoding
str
None
errors
str
None