B ˆ f%ã@stdZddlZddd„Zddd„ZGdd „d ejƒZGd d „d ejƒZGd d „d ejƒZGdd„dejƒZdd„Z dS)a Python 'utf-8-sig' Codec This work similar to UTF-8 with the following changes: * On encoding/writing a UTF-8 encoded BOM will be prepended/written as the first three bytes. * On decoding/reading if the first three bytes are a UTF-8 encoded BOM, these bytes will be skipped. éNÚstrictcCstjt ||¡dt|ƒfS)Nr)ÚcodecsÚBOM_UTF8Ú utf_8_encodeÚlen)ÚinputÚerrors©r ú8/opt/alt/python37/lib64/python3.7/encodings/utf_8_sig.pyÚencodesr cCsDd}|dd…tjkr&|dd…}d}t ||d¡\}}|||fS)NréT)rrÚ utf_8_decode)rrÚprefixÚoutputÚconsumedr r r Údecodes  rc@s8eZdZddd„Zddd„Zdd„Zd d „Zd d „Zd S)ÚIncrementalEncoderrcCstj ||¡d|_dS)Né)rrÚ__init__Úfirst)Úselfrr r r rszIncrementalEncoder.__init__FcCs:|jr$d|_tjt ||j¡dSt ||j¡dSdS)Nr)rrrrr)rrÚfinalr r r r s zIncrementalEncoder.encodecCstj |¡d|_dS)Nr)rrÚresetr)rr r r r's zIncrementalEncoder.resetcCs|jS)N)r)rr r r Úgetstate+szIncrementalEncoder.getstatecCs ||_dS)N)r)rÚstater r r Úsetstate.szIncrementalEncoder.setstateN)r)F)Ú__name__Ú __module__Ú __qualname__rr rrrr r r r rs   rc@s6eZdZd dd„Zdd„Zdd„Zdd „Zd d „Zd S)ÚIncrementalDecoderrcCstj ||¡d|_dS)Nr)rÚBufferedIncrementalDecoderrr)rrr r r r2szIncrementalDecoder.__init__cCsv|jrht|ƒdkr*tj |¡r"dSd|_n>d|_|dd…tjkrht |dd…||¡\}}||dfSt |||¡S)Nr )Úrr)rrrrÚ startswithr )rrrrrrr r r Ú_buffer_decode6s   z!IncrementalDecoder._buffer_decodecCstj |¡d|_dS)Nr)rr rr)rr r r rGs zIncrementalDecoder.resetcCstj |¡}|d|jfS)Nr)rr rr)rrr r r rKs zIncrementalDecoder.getstatecCstj ||¡|d|_dS)Nr)rr rr)rrr r r rPszIncrementalDecoder.setstateN)r)rrrrr#rrrr r r r r1s  rc@seZdZdd„Zddd„ZdS)Ú StreamWritercCs.tj |¡y|`Wntk r(YnXdS)N)rr$rr ÚAttributeError)rr r r rVs  zStreamWriter.resetrcCstj|_t||ƒS)N)rrr )rrrr r r r ]szStreamWriter.encodeN)r)rrrrr r r r r r$Usr$c@seZdZdd„Zddd„ZdS)Ú StreamReadercCs.tj |¡y|`Wntk r(YnXdS)N)rr&rrr%)rr r r rbs  zStreamReader.resetrcCspt|ƒdkrtj |¡r\dSn>|dd…tjkr\tj|_t |dd…|¡\}}||dfStj|_t ||¡S)Nr )r!r)rrrr"r r)rrrrrr r r ris   zStreamReader.decodeN)r)rrrrrr r r r r&asr&c Cstjdttttttd�S)Nz utf-8-sig)Únamer rÚincrementalencoderÚincrementaldecoderÚ streamreaderÚ streamwriter)rÚ CodecInfor rrrr&r$r r r r Ú getregentryysr-)r)r) Ú__doc__rr rrr rr$r&r-r r r r Ú s  $