Mercurial > repos > rliterman > csp2
annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/encodings/unicode_escape.py @ 69:33d812a61356
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 17:55:14 -0400 |
parents | |
children |
rev | line source |
---|---|
jpayne@69 | 1 """ Python 'unicode-escape' Codec |
jpayne@69 | 2 |
jpayne@69 | 3 |
jpayne@69 | 4 Written by Marc-Andre Lemburg (mal@lemburg.com). |
jpayne@69 | 5 |
jpayne@69 | 6 (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. |
jpayne@69 | 7 |
jpayne@69 | 8 """ |
jpayne@69 | 9 import codecs |
jpayne@69 | 10 |
jpayne@69 | 11 ### Codec APIs |
jpayne@69 | 12 |
jpayne@69 | 13 class Codec(codecs.Codec): |
jpayne@69 | 14 |
jpayne@69 | 15 # Note: Binding these as C functions will result in the class not |
jpayne@69 | 16 # converting them to methods. This is intended. |
jpayne@69 | 17 encode = codecs.unicode_escape_encode |
jpayne@69 | 18 decode = codecs.unicode_escape_decode |
jpayne@69 | 19 |
jpayne@69 | 20 class IncrementalEncoder(codecs.IncrementalEncoder): |
jpayne@69 | 21 def encode(self, input, final=False): |
jpayne@69 | 22 return codecs.unicode_escape_encode(input, self.errors)[0] |
jpayne@69 | 23 |
jpayne@69 | 24 class IncrementalDecoder(codecs.IncrementalDecoder): |
jpayne@69 | 25 def decode(self, input, final=False): |
jpayne@69 | 26 return codecs.unicode_escape_decode(input, self.errors)[0] |
jpayne@69 | 27 |
jpayne@69 | 28 class StreamWriter(Codec,codecs.StreamWriter): |
jpayne@69 | 29 pass |
jpayne@69 | 30 |
jpayne@69 | 31 class StreamReader(Codec,codecs.StreamReader): |
jpayne@69 | 32 pass |
jpayne@69 | 33 |
jpayne@69 | 34 ### encodings module API |
jpayne@69 | 35 |
jpayne@69 | 36 def getregentry(): |
jpayne@69 | 37 return codecs.CodecInfo( |
jpayne@69 | 38 name='unicode-escape', |
jpayne@69 | 39 encode=Codec.encode, |
jpayne@69 | 40 decode=Codec.decode, |
jpayne@69 | 41 incrementalencoder=IncrementalEncoder, |
jpayne@69 | 42 incrementaldecoder=IncrementalDecoder, |
jpayne@69 | 43 streamwriter=StreamWriter, |
jpayne@69 | 44 streamreader=StreamReader, |
jpayne@69 | 45 ) |