How to use the javaproperties.util.ascii_splitlines function in javaproperties

To help you get started, we’ve selected a few javaproperties examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jwodder / javaproperties / javaproperties / reading.py View on Github external
`InvalidUEscapeError` to be raised

    .. versionchanged:: 0.7.0
        `parse()` now accepts strings as input, and it now returns a generator
        of custom objects instead of triples of strings

    :param src: the ``.properties`` document
    :type src: string or file-like object
    :rtype: Iterable[PropertiesElement]
    :raises InvalidUEscapeError: if an invalid ``\\uXXXX`` escape sequence
        occurs in the input
    """
    if isinstance(src, binary_type):
        liter = iter(ascii_splitlines(src.decode('iso-8859-1')))
    elif isinstance(src, text_type):
        liter = iter(ascii_splitlines(src))
    else:
        def lineiter():
            while True:
                line = src.readline()
                if isinstance(line, binary_type):
                    line = line.decode('iso-8859-1')
                if line == '':
                    return
                for ln in ascii_splitlines(line):
                    yield ln
        liter = lineiter()
    for source in liter:
        line = source
        if COMMENT_RGX.match(line):
            yield Comment(source)
            continue
github jwodder / javaproperties / javaproperties / reading.py View on Github external
def lineiter():
            while True:
                line = src.readline()
                if isinstance(line, binary_type):
                    line = line.decode('iso-8859-1')
                if line == '':
                    return
                for ln in ascii_splitlines(line):
                    yield ln
        liter = lineiter()
github jwodder / javaproperties / javaproperties / reading.py View on Github external
.. versionchanged:: 0.5.0
        Invalid ``\\uXXXX`` escape sequences will now cause an
        `InvalidUEscapeError` to be raised

    .. versionchanged:: 0.7.0
        `parse()` now accepts strings as input, and it now returns a generator
        of custom objects instead of triples of strings

    :param src: the ``.properties`` document
    :type src: string or file-like object
    :rtype: Iterable[PropertiesElement]
    :raises InvalidUEscapeError: if an invalid ``\\uXXXX`` escape sequence
        occurs in the input
    """
    if isinstance(src, binary_type):
        liter = iter(ascii_splitlines(src.decode('iso-8859-1')))
    elif isinstance(src, text_type):
        liter = iter(ascii_splitlines(src))
    else:
        def lineiter():
            while True:
                line = src.readline()
                if isinstance(line, binary_type):
                    line = line.decode('iso-8859-1')
                if line == '':
                    return
                for ln in ascii_splitlines(line):
                    yield ln
        liter = lineiter()
    for source in liter:
        line = source
        if COMMENT_RGX.match(line):