def escape_string(self, string):
if self.quote:<EOL><INDENT>quote = self.quote<EOL><DEDENT>else:<EOL><INDENT>found = QUOTE_REGEX.search(string)<EOL>quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES))<EOL><DEDENT>for match, seq in ESCAPE_SUBS.items():<EOL><INDENT>if match == quote or match not in STRING_QUOTES:<EOL><INDENT>string = string.replace(match, seq)<EOL><DEDENT><DEDENT>return f'<STR_LIT>'<EOL>
Return the escaped literal representation of an nbt string.