^]8dZddlmZddlZddlZ edZ ddZ ddZ GddejZ Gd d ejZ Gd d ejZGd de ejZGdde ej ZdZy#eef$reZYwxYw)aLPython 'hex' Codec - 2-digit hex with spaces content transfer encoding. Encode and decode may be a bit missleading at first sight... The textual representation is a hex dump: e.g. "40 41" The "encoded" data of this is the binary form, e.g. b"@A" Therefore decoding is binary to text and thus converting binary data to hex dump. )absolute_importN0123456789ABCDEFc tj|jDcgc]}t|dc}t |fScc}wz'40 41 42' -> b'@ab')serialto_bytessplitintlen)dataerrorshs ASBZ> ?T KK>sActdjdtj|Dt |fS)b'@ab' -> '40 41 42'c3PK|]}djt| ywz{:02X} Nformatord.0bs r zhex_decode..-sUI,,SV4U$&)unicodejoinr iterbytesr )r rs r hex_decoder"+s3 BGGUf>N>Nt>TUU VX[\`Xa bbceZdZddZddZy)Codecc tj|jDcgc]}t|dc}Scc}wr)rr r r )selfr rrs rencodez Codec.encode1s+DJJLAqAr ABBAs<cjtdjdtj|DS)rrc3PK|]}djt| ywrrrs rrzCodec.decode..7XAy//A7Xrrr rr!)r'r rs rdecodez Codec.decode5s(rwwXAQAQRVAWXXYYr#Nstrict)__name__ __module__ __qualname__r(r-r#rr%r%0sCZr#r%c2eZdZdZddZdZdZdZd dZy) IncrementalEncoderzIncremental hex encoderc ||_d|_yNr)rstate)r'rs r__init__zIncrementalEncoder.__init__=s  r#cd|_yr7r8r's rresetzIncrementalEncoder.resetAs  r#c|jSNr;r<s rgetstatezIncrementalEncoder.getstateDs zzr#c||_yr?r;)r'r8s rsetstatezIncrementalEncoder.setstateGs  r#c|j}g}|jD]}|tvr:tj|}|r|j ||dzzd}.hr+rr,)r'r rMs rr-zIncrementalDecoder.decodegs(rwwXAQAQRVAWXXYYr#NrQ)r0r1r2rRr-r3r#rrTrTes Zr#rTceZdZdZy) StreamWriterz-Combination of hexlify codec and StreamWriterNr0r1r2rRr3r#rrXrXk7r#rXceZdZdZy) StreamReaderz-Combination of hexlify codec and StreamReaderNrYr3r#rr\r\orZr#r\c jtjdtttt t tS)zencodings module APIhexlify)namer(r-incrementalencoderincrementaldecoder streamwriter streamreader)codecs CodecInforr"r5rTrXr\r3r#r getregentryrfss*    --!!  r#r.)rR __future__rrdrr NameErrorAttributeErrorstrrIrr"r%r5rTrXr\rfr3r#rrks '   L c ZFLLZ((22((VZ22Z 85&--885&--8 m >"GsB BB