Example #1
0
def parse(stream, Loader=Loader):
    """
    Parse a YAML stream and produce parsing events.
    """
    loader = Loader(stream)
    try:
        while loader.check_event():
            yield loader.get_event()
    finally:
        loader.dispose()
Example #2
0
def compose(stream, Loader=Loader):
    """
    Parse the first YAML document in a stream
    and produce the corresponding representation tree.
    """
    loader = Loader(stream)
    try:
        return loader.get_single_node()
    finally:
        loader.dispose()
Example #3
0
def compose(stream, Loader=Loader):
    """
    Parse the first YAML document in a stream
    and produce the corresponding representation tree.
    """
    loader = Loader(stream)
    try:
        return loader.get_single_node()
    finally:
        loader.dispose()
Example #4
0
def scan(stream, Loader=Loader):
    """
    Scan a YAML stream and produce scanning tokens.
    """
    loader = Loader(stream)
    try:
        while loader.check_token():
            yield loader.get_token()
    finally:
        loader.dispose()
Example #5
0
def parse(stream, Loader=Loader):
    """
    Parse a YAML stream and produce parsing events.
    """
    loader = Loader(stream)
    try:
        while loader.check_event():
            yield loader.get_event()
    finally:
        loader.dispose()
Example #6
0
def scan(stream, Loader=Loader):
    """
    Scan a YAML stream and produce scanning tokens.
    """
    loader = Loader(stream)
    try:
        while loader.check_token():
            yield loader.get_token()
    finally:
        loader.dispose()
Example #7
0
def load_all(stream, Loader=Loader, version=None, preserve_quotes=None):
    """
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    """
    loader = Loader(stream, version, preserve_quotes=preserve_quotes)
    try:
        while loader.check_data():
            yield loader.get_data()
    finally:
        loader.dispose()
Example #8
0
def load(stream, Loader=Loader, version=None, preserve_quotes=None):
    # type: (StreamType, Any, VersionType, Any) -> Any
    """
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    """
    loader = Loader(stream, version, preserve_quotes=preserve_quotes)
    try:
        return loader.get_single_data()
    finally:
        loader.dispose()
Example #9
0
def compose_all(stream, Loader=Loader):
    """
    Parse all YAML documents in a stream
    and produce corresponding representation trees.
    """
    loader = Loader(stream)
    try:
        while loader.check_node():
            yield loader.get_node()
    finally:
        loader.dispose()
Example #10
0
def compose_all(stream, Loader=Loader):
    """
    Parse all YAML documents in a stream
    and produce corresponding representation trees.
    """
    loader = Loader(stream)
    try:
        while loader.check_node():
            yield loader.get_node()
    finally:
        loader.dispose()
Example #11
0
def load_all(stream, Loader=Loader, version=None):
    """
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    """
    loader = Loader(stream, version)
    try:
        while loader.check_data():
            yield loader.get_data()
    finally:
        loader.dispose()
Example #12
0
def load(stream, Loader=Loader, version=None, preserve_quotes=None):
    # type: (StreamType, Any, VersionType, Any) -> Any
    """
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    """
    loader = Loader(stream, version, preserve_quotes=preserve_quotes)
    try:
        return loader.get_single_data()
    finally:
        loader.dispose()
Example #13
0
def load_all(stream, Loader=None, version=None, preserve_quotes=None):
    """
    Parse all YAML documents in a stream
    and produce corresponding Python objects.
    """
    if Loader is None:
        from ruamel.yaml.loader import Loader as UnsafeLoader
        import warnings
        warnings.warn(UnsafeLoaderWarning.text,
                      UnsafeLoaderWarning,
                      stacklevel=2)
        Loader = UnsafeLoader
    loader = Loader(stream, version, preserve_quotes=preserve_quotes)
    try:
        while loader.check_data():
            yield loader.get_data()
    finally:
        loader.dispose()
Example #14
0
def load(stream, Loader=None, version=None, preserve_quotes=None):
    # type: (StreamType, Any, VersionType, Any) -> Any
    """
    Parse the first YAML document in a stream
    and produce the corresponding Python object.
    """
    if Loader is None:
        from ruamel.yaml.loader import Loader as UnsafeLoader
        import warnings
        warnings.warn(UnsafeLoaderWarning.text,
                      UnsafeLoaderWarning,
                      stacklevel=2)
        Loader = UnsafeLoader
    loader = Loader(stream, version, preserve_quotes=preserve_quotes)
    try:
        return loader.get_single_data()
    finally:
        loader.dispose()