Skip to content

Commit

Permalink
yaml writer: fix indentation on reserve and control characters list
Browse files Browse the repository at this point in the history
  • Loading branch information
Qonfused committed Jun 21, 2023
1 parent 28a620c commit 4157146
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/parsers/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def writeSerializedTypes(value: Tuple[str, any] | any,
case _: svalue = str(svalue)
# Escape control and reserved characters
# @see https://symfony.com/doc/current/reference/formats/yaml.html
reserve_chars = [':', '{', '}', '[', ']', ',', '&', '*', '#', '?',
'|', '-', '<', '>', '=', '!', '%',' @', '`']
control_chars = ['\0', '\x01', '\x02', '\x03', '\x04', '\x05',
'\x06', '\a', '\b', '\t', '\n', '\v', '\f', '\r',
'\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13',
'\x14', '\x15', '\x16', '\x17', '\x18', '\x19',
'\x1a', '\e', '\x1c', '\x1d', '\x1e', '\x1f',
r'\N', r'\_', r'\L', r'\P']
reserve_chars = [':', '{', '}', '[', ']', ',', '&',
'*', '#', '?', '|', '-', '<', '>',
'=', '!', '%', '@', '`']
control_chars = ['\0', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06',
'\a', '\b', '\t', '\n', '\v', '\f', '\r',
'\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14',
'\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', r'\e',
'\x1c', '\x1d', '\x1e', '\x1f', r'\N', r'\_', r'\L',
r'\P']
if any([c for c in control_chars if c in svalue]):
svalue = f'"{svalue}"'
elif any([c for c in reserve_chars if c in svalue]):
Expand Down

0 comments on commit 4157146

Please sign in to comment.