def quote_ps_string(s):
s=s.replace("<STR_LIT:\\>", "<STR_LIT>")<EOL>s=s.replace("<STR_LIT:(>", "<STR_LIT>")<EOL>s=s.replace("<STR_LIT:)>", "<STR_LIT>")<EOL>s=s.replace("<STR_LIT:'>", "<STR_LIT>")<EOL>s=s.replace("<STR_LIT>", "<STR_LIT>")<EOL>s=re.sub(r"<STR_LIT>", lambda x: r"<STR_LIT>"%ord(x.group()), s)<EOL>return s<EOL>
Quote dangerous characters of S for use in a PostScript string constant.