] @sddlZddlZejZdddZGdddejZGdddejZGd d d ejZGd d d ej Z d dZ dS)NstrictcCstj||dS)NT)codecs utf_32_decode)inputerrorsr+/opt/alt/python35/lib64/python3.5/utf_32.pydecode sr c@sReZdZdddZdddZddZd d Zd d Zd S)IncrementalEncoderrcCs tjj||d|_dS)N)rr __init__encoder)selfrrrrr szIncrementalEncoder.__init__FcCsm|jdkrVtj||jd}tjdkrFtj|_n tj|_|S|j||jdS)Nrlittle)r r utf_32_encodersys byteorderutf_32_le_encodeutf_32_be_encode)r rfinalresultrrrencodes zIncrementalEncoder.encodecCstjj|d|_dS)N)rr resetr )r rrrrszIncrementalEncoder.resetcCs|jdkrdSdS)Nr)r )r rrrgetstate szIncrementalEncoder.getstatecCs@|rd|_n*tjdkr0tj|_n tj|_dS)Nr)r rrrrr)r staterrrsetstate's  zIncrementalEncoder.setstateN)__name__ __module__ __qualname__r rrrrrrrrr s   r c@sOeZdZdddZddZddZdd Zd d Zd S) IncrementalDecoderrcCs tjj||d|_dS)N)rBufferedIncrementalDecoderr decoder)r rrrrr 1szIncrementalDecoder.__init__cCs|jdkrtj||d|\}}}|dkrKtj|_n3|dkrftj|_n|dkr~td||fS|j||j|S)Nrz%UTF-32 stream does not start with BOM)r!rutf_32_ex_decodeutf_32_le_decodeutf_32_be_decode UnicodeErrorr)r rrroutputconsumedrrrr_buffer_decode5s!     z!IncrementalDecoder._buffer_decodecCstjj|d|_dS)N)rr rr!)r rrrrBszIncrementalDecoder.resetcCs`tjj|d}|jdkr/|dfSttjdk|jtjkk}||fS)Nrrbig)rr rr!intrrr')r rZaddstaterrrrFs  zIncrementalDecoder.getstatecCstjj|||d}|dkrPtjdkrAtjntj|_n<|dkrtjdkrttjntj|_n d|_dS)Nr"rr,)rr rrrr'r&r!)r rrrrrTs   zIncrementalDecoder.setstateN)rrrr r+rrrrrrrr0s   rc@s:eZdZdddZddZdddZdS) StreamWriterrcCs#d|_tjj|||dS)N)r rr.r )r streamrrrrr ds zStreamWriter.__init__cCstjj|d|_dS)N)rr.rr )r rrrrhszStreamWriter.resetcCsc|jdkrOtj||}tjdkr?tj|_n tj|_|S|j||SdS)Nr)r rrrrrr)r rrrrrrrls zStreamWriter.encodeN)rrrr rrrrrrr.cs  r.c@s+eZdZddZdddZdS) StreamReaderc Cs3tjj|y |`Wntk r.YnXdS)N)rr0rr AttributeError)r rrrrys   zStreamReader.resetrcCsytj||dd\}}}|dkr<tj|_n3|dkrWtj|_n|dkrotd||fS)NrFr"r#z%UTF-32 stream does not start with BOMr$)rr%r&r r'r()r rrobjectr*rrrrr s!    zStreamReader.decodeN)rrrrr rrrrr0ws  r0cCs4tjdddtdtdtdtdtdtS) Nnamezutf-32rr incrementalencoderincrementaldecoder streamreader streamwriter)r CodecInforr r rr0r.rrrr getregentrys r9) rrrrr r r rr.r0r9rrrrs #3