| 241 | |
| 242 | |
| 243 | def normalize(s, encoding): |
| 244 | # This converts the various Python string types into a format that is |
| 245 | # appropriate for .po files, namely much closer to C style. |
| 246 | lines = s.split('\n') |
| 247 | if len(lines) == 1: |
| 248 | s = '"' + escape(s, encoding) + '"' |
| 249 | else: |
| 250 | if not lines[-1]: |
| 251 | del lines[-1] |
| 252 | lines[-1] = lines[-1] + '\n' |
| 253 | for i in range(len(lines)): |
| 254 | lines[i] = escape(lines[i], encoding) |
| 255 | lineterm = '\\n"\n"' |
| 256 | s = '""\n"' + lineterm.join(lines) + '"' |
| 257 | return s |
| 258 | |
| 259 | |
| 260 | def containsAny(str, set): |