mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 20:15:31 +00:00
Replaced escaped_split() logic with regex
This commit is contained in:
parent
fcdf685302
commit
630281349e
|
@ -632,18 +632,10 @@ def escaped_split(inp_str, split_char):
|
||||||
"""
|
"""
|
||||||
if len(split_char) > 1:
|
if len(split_char) > 1:
|
||||||
raise ValueError('Expected split character. Found string!')
|
raise ValueError('Expected split character. Found string!')
|
||||||
out = []
|
out = re.sub(r'(\\.)|' + split_char,
|
||||||
part = ''
|
lambda m: m.group(1) or '\n', inp_str,
|
||||||
escape = False
|
len(inp_str)).split('\n')
|
||||||
for character in inp_str:
|
out = filter(lambda x: x or False, out)
|
||||||
if not escape and character == split_char:
|
|
||||||
out.append(part)
|
|
||||||
part = ''
|
|
||||||
else:
|
|
||||||
part += character
|
|
||||||
escape = not escape and character == '\\'
|
|
||||||
if part:
|
|
||||||
out.append(part)
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,18 +77,10 @@ class TestDataParser(object):
|
||||||
"""
|
"""
|
||||||
if len(split_char) > 1:
|
if len(split_char) > 1:
|
||||||
raise ValueError('Expected split character. Found string!')
|
raise ValueError('Expected split character. Found string!')
|
||||||
out = []
|
out = re.sub(r'(\\.)|' + split_char,
|
||||||
part = ''
|
lambda m: m.group(1) or '\n', inp_str,
|
||||||
escape = False
|
len(inp_str)).split('\n')
|
||||||
for character in inp_str:
|
out = filter(lambda x: x or False, out)
|
||||||
if not escape and character == split_char:
|
|
||||||
out.append(part)
|
|
||||||
part = ''
|
|
||||||
else:
|
|
||||||
part += character
|
|
||||||
escape = not escape and character == '\\'
|
|
||||||
if part:
|
|
||||||
out.append(part)
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def __parse(self, data_f):
|
def __parse(self, data_f):
|
||||||
|
|
Loading…
Reference in a new issue