src/metaloaders/yaml.py
def load(stream: str, *, loader_cls: TypeOf[Loader] = Loader) -> Node:
    """Loads a string representation of a document.

    Raises `metaloaders.exceptions.MetaloaderError` if any parsing error occur.
    """
    # pylint: disable=protected-access
    items: List[Node] = []
    loader = loader_cls(stream)

    try:
        while loader._constructor.check_data():
            items.append(loader._constructor.get_data())
    except _yaml.YAMLError as exc:  # type: ignore
        raise MetaloaderError(f'Unable to parse stream: {exc}')
    else:
        if len(items) == 0:
            return Node(
                data=None,
                data_type=Type.NULL,
                end_column=0,
                end_line=1,
                start_column=0,
                start_line=1,
            )

        if len(items) == 1:
            return items[0]

        return Node(
            data=items,
            data_type=Type.ARRAY,
            end_column=items[-1].end_column,
            end_line=items[-1].end_line,
            start_column=items[0].start_column,
            start_line=items[0].start_line,
        )
    finally:
        loader._parser.dispose()
        with suppress(AttributeError):
            loader._reader.reset_reader()
        with suppress(AttributeError):
            loader._scanner.reset_scanner()
Loads a string representation of a document.

    Raises `metaloaders.exceptions.MetaloaderError` if any parsing error occur.
    
Loads a string representation of a document.
Raises `metaloaders.exceptions.MetaloaderError` if any parsing error occur.
Loads a string representation of a document . Raises ` metaloaders . exceptions . MetaloaderError ` if any parsing error occur .
def load(stream: str, *, loader_cls: TypeOf[Loader] = Loader) -> Node:
    items: List[Node] = []
    loader = loader_cls(stream)
    try:
        while loader._constructor.check_data():
            items.append(loader._constructor.get_data())
    except _yaml.YAMLError as exc:  
        raise MetaloaderError(f'Unable to parse stream: {exc}')
    else:
        if len(items) == 0:
            return Node(
                data=None,
                data_type=Type.NULL,
                end_column=0,
                end_line=1,
                start_column=0,
                start_line=1,
            )
        if len(items) == 1:
            return items[0]
        return Node(
            data=items,
            data_type=Type.ARRAY,
            end_column=items[-1].end_column,
            end_line=items[-1].end_line,
            start_column=items[0].start_column,
            start_line=items[0].start_line,
        )
    finally:
        loader._parser.dispose()
        with suppress(AttributeError):
            loader._reader.reset_reader()
        with suppress(AttributeError):
            loader._scanner.reset_scanner()
def load ( stream : str , * , loader_cls : TypeOf [ Loader ] = Loader ) -> Node : items : List [ Node ] = [ ] loader = loader_cls ( stream ) try : while loader . _constructor . check_data ( ) : items . append ( loader . _constructor . get_data ( ) ) except _yaml . YAMLError as exc : raise MetaloaderError ( f'Unable to parse stream: {exc}' ) else : if len ( items ) == 0 : return Node ( data = None , data_type = Type . NULL , end_column = 0 , end_line = 1 , start_column = 0 , start_line = 1 , ) if len ( items ) == 1 : return items [ 0 ] return Node ( data = items , data_type = Type . ARRAY , end_column = items [ - 1 ] . end_column , end_line = items [ - 1 ] . end_line , start_column = items [ 0 ] . start_column , start_line = items [ 0 ] . start_line , ) finally : loader . _parser . dispose ( ) with suppress ( AttributeError ) : loader . _reader . reset_reader ( ) with suppress ( AttributeError ) : loader . _scanner . reset_scanner ( )
Loads a string representation of a document.
Loads a string representation of a document .
"""Loads a string representation of a document.

    Raises `metaloaders.exceptions.MetaloaderError` if any parsing error occur.
    """ # pylint: disable=protected-access # type: ignore
stream
str
loader_cls
TypeOf[Loader]