r""" Escapes the string 's' in the same fashion as is done for display in Kconfig format and when writing strings to a .config file. " and \ are replaced by \" and \\, respectively.
(s)
| 6215 | |
| 6216 | |
| 6217 | def escape(s): |
| 6218 | r""" |
| 6219 | Escapes the string 's' in the same fashion as is done for display in |
| 6220 | Kconfig format and when writing strings to a .config file. " and \ are |
| 6221 | replaced by \" and \\, respectively. |
| 6222 | """ |
| 6223 | # \ must be escaped before " to avoid double escaping |
| 6224 | return s.replace("\\", r"\\").replace('"', r'\"') |
| 6225 | |
| 6226 | |
| 6227 | def unescape(s): |