Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`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
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()
.. 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):