ó
è¾bc           @   s¤   d  Z  d d l Z d d l Z e j Z d d „ Z d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d	 e j	 f d
 „  ƒ  YZ	 d e j
 f d „  ƒ  YZ
 d „  Z d S(   s‚    Python 'utf-16' Codec


Written by Marc-Andre Lemburg (mal@lemburg.com).

(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.

iÿÿÿÿNt   strictc         C   s   t  j |  | t ƒ S(   N(   t   codecst   utf_16_decodet   True(   t   inputt   errors(    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   decode   s    t   IncrementalEncoderc           B   s;   e  Z d  d „ Z e d „ Z d „  Z d „  Z d „  Z RS(   R    c         C   s    t  j j |  | ƒ d  |  _ d  S(   N(   R   R   t   __init__t   Nonet   encoder(   t   selfR   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR      s    c         C   sm   |  j  d  k rV t j | |  j ƒ d } t j d k rF t j |  _  n t j |  _  | S|  j  | |  j ƒ d S(   Ni    t   little(	   R
   R	   R   t   utf_16_encodeR   t   syst	   byteordert   utf_16_le_encodet   utf_16_be_encode(   R   R   t   finalt   result(    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   encode   s    c         C   s   t  j j |  ƒ d  |  _ d  S(   N(   R   R   t   resetR	   R
   (   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   !   s    c         C   s   |  j  d  k r d Sd S(   Ni   i    (   R
   R	   (   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   getstate%   s    c         C   s@   | r d  |  _ n* t j d k r0 t j |  _ n t j |  _ d  S(   NR   (   R	   R
   R   R   R   R   R   (   R   t   state(    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   setstate,   s
    (   t   __name__t
   __module__R   t   FalseR   R   R   R   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR      s
   
		t   IncrementalDecoderc           B   s&   e  Z d  d „ Z d „  Z d „  Z RS(   R    c         C   s    t  j j |  | ƒ d  |  _ d  S(   N(   R   t   BufferedIncrementalDecoderR   R	   t   decoder(   R   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   6   s    c         C   s¡   |  j  d  k r‹ t j | | d | ƒ \ } } } | d k rK t j |  _  n6 | d k rf t j |  _  n | d k r t d ƒ ‚ n  | | f S|  j  | |  j | ƒ S(   Ni    iÿÿÿÿi   i   s%   UTF-16 stream does not start with BOM(   R   R	   R   t   utf_16_ex_decodet   utf_16_le_decodet   utf_16_be_decodet   UnicodeErrorR   (   R   R   R   R   t   outputt   consumedR   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   _buffer_decode:   s    !
c         C   s   t  j j |  ƒ d  |  _ d  S(   N(   R   R   R   R	   R   (   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   G   s    (   R   R   R   R%   R   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   5   s   	t   StreamWriterc           B   s)   e  Z d  d „ Z d „  Z d  d „ Z RS(   R    c         C   s#   t  j j |  | | ƒ d  |  _ d  S(   N(   R   R&   R   R	   R
   (   R   t   streamR   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   L   s    c         C   s   t  j j |  ƒ d  |  _ d  S(   N(   R   R&   R   R	   R
   (   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   P   s    c         C   sc   |  j  d  k rO t j | | ƒ } t j d k r? t j |  _  n t j |  _  | S|  j  | | ƒ Sd  S(   NR   (   R
   R	   R   R   R   R   R   R   (   R   R   R   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   T   s    (   R   R   R   R   R   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR&   K   s   	t   StreamReaderc           B   s   e  Z d  „  Z d d „ Z RS(   c         C   s2   t  j j |  ƒ y
 |  ` Wn t k
 r- n Xd  S(   N(   R   R(   R   R   t   AttributeError(   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   a   s
    
R    c         C   sy   t  j | | d t ƒ \ } } } | d k r< t  j |  _ n3 | d k rW t  j |  _ n | d k ro t d ‚ n  | | f S(   Ni    iÿÿÿÿi   i   s%   UTF-16 stream does not start with BOM(   R   R   R   R    R   R!   R"   (   R   R   R   t   objectR$   R   (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR   h   s    !(   R   R   R   R   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyR(   _   s   	c           C   s4   t  j d d d t d t d t d t d t d t ƒ S(	   Nt   names   utf-16R   R   t   incrementalencodert   incrementaldecodert   streamreadert   streamwriter(   R   t	   CodecInfoR   R   R   R   R(   R&   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   getregentryu   s    	(   t   __doc__R   R   R   R   R   R   R   R   R&   R(   R1   (    (    (    s&   /usr/lib/python2.7/encodings/utf_16.pyt   <module>   s   	#