-
<c       s+    d  Z   
 d k Z d k Z  y  d k TWn(  e j
 o Z  e d e  n X d d d d d d	 d
 d d d d g Z  e i d d  Z	  d Z
 Z ! d Z Z ( d Z * d Z 0 d f  d     YZ p d e f d     YZ  d e f d     YZ %d f  d     YZ fd f  d     YZ d e d  d! d"  Z e d  d#  Z  d$   Z *d%   Z 4d&   Z >d'   Z Jd(   Z Wd)   Z nd* Z oe o pd k Z n te  d+ j oF vd k! Z! ye e! i" d, d-  e! _" |e e! i# d- d,  e! _# n d S(.   s    codecs -- Python Codec Registry, API and helpers.


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

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

N(   s   *s%   Failed to load the builtin codecs: %ss   registers   lookups   opens   EncodedFiles   BOMs   BOM_BEs   BOM_LEs   BOM32_BEs   BOM32_LEs   BOM64_BEs   BOM64_LEs   =Hi  s   s   s     s     s   Codecc      s2   0 t  Z d  Z > ? d d  Z R d d  Z RS(   s0   Defines the interface for stateless encoders/decoders.

        The .encode()/.decode() methods may implement different error
        handling schemes by providing the errors argument. These
        string values are defined:

         'strict' - raise a ValueError error (or a subclass)
         'ignore' - ignore the character and continue with the next
         'replace' - replace with a suitable replacement character;
                    Python will use the official U+FFFD REPLACEMENT
                    CHARACTER for the builtin Unicode codecs.

    s   strictc    s   ? O P t   d S(   s+   Encodes the object input and returns a tuple (output
            object, length consumed).

            errors defines the error handling to apply. It defaults to
            'strict' handling.

            The method may not store state in the Codec instance. Use
            StreamCodec for codecs which have to keep state in order to
            make encoding/decoding efficient.

            The encoder must be able to handle zero length input and
            return an empty object of the output object type in this
            situation.

        N(   s   NotImplementedError(   s   selfs   inputs   errors(    (    s   /usr/lib/python2.2/codecs.pys   encode? s   c    s   R f g t   d S(   s   Decodes the object input and returns a tuple (output
            object, length consumed).

            input must be an object which provides the bf_getreadbuf
            buffer slot. Python strings, buffer objects and memory
            mapped files are examples of objects providing this slot.

            errors defines the error handling to apply. It defaults to
            'strict' handling.

            The method may not store state in the Codec instance. Use
            StreamCodec for codecs which have to keep state in order to
            make encoding/decoding efficient.

            The decoder must be able to handle zero length input and
            return an empty object of the output object type in this
            situation.

        N(   s   NotImplementedError(   s   selfs   inputs   errors(    (    s   /usr/lib/python2.2/codecs.pys   decodeR s   (   s   __name__s
   __module__s   __doc__s   encodes   decode(    (    (    s   /usr/lib/python2.2/codecs.pys   Codec0 s   s   StreamWriterc      sM   p t  Z r d d  Z  d   Z  d   Z  d   Z  e d  Z RS(   Ns   strictc    s"   r   | |  _   | |  _ d S(   s   Creates a StreamWriter instance.

            stream must be a file-like object open for writing
            (binary) data.

            The StreamWriter may implement different error handling
            schemes by providing the errors keyword argument. These
            parameters are defined:

             'strict' - raise a ValueError (or a subclass)
             'ignore' - ignore the character and continue with the next
             'replace'- replace with a suitable replacement character

        N(   s   streams   selfs   errors(   s   selfs   streams   errors(    (    s   /usr/lib/python2.2/codecs.pys   __init__r s   c    s;      |  i | |  i  \ } }  |  i i |  d S(   s>    Writes the object's contents encoded to self.stream.
        N(   s   selfs   encodes   objects   errorss   datas   consumeds   streams   write(   s   selfs   objects   datas   consumed(    (    s   /usr/lib/python2.2/codecs.pys   write s   c    s#      |  i d i |   d S(   s[    Writes the concatenated list of strings to the stream
            using .write().
        s    N(   s   selfs   writes   joins   list(   s   selfs   list(    (    s   /usr/lib/python2.2/codecs.pys
   writelines s   c    s      d S(   s5   Flushes and resets the codec buffers used for keeping state.

            Calling this method should ensure that the data on the
            output is put into a clean state, that allows appending
            of new fresh data without having to rescan the whole
            stream to recover state.

        N(    (   s   self(    (    s   /usr/lib/python2.2/codecs.pys   reset s   	c    s      | |  i |  Sd S(   s?    Inherit all other methods from the underlying stream.
        N(   s   getattrs   selfs   streams   name(   s   selfs   names   getattr(    (    s   /usr/lib/python2.2/codecs.pys   __getattr__ s   (   s   __name__s
   __module__s   __init__s   writes
   writeliness   resets   getattrs   __getattr__(    (    (    s   /usr/lib/python2.2/codecs.pys   StreamWriterp s
   	s   StreamReaderc      sb    t  Z  d d  Z  d d  Z  e d  Z  e d  Z d   Z e d  Z	 RS(	   Ns   strictc    s"      | |  _   | |  _ d S(   s   Creates a StreamReader instance.

            stream must be a file-like object open for reading
            (binary) data.

            The StreamReader may implement different error handling
            schemes by providing the errors keyword argument. These
            parameters are defined:

             'strict' - raise a ValueError (or a subclass)
             'ignore' - ignore the character and continue with the next
             'replace'- replace with a suitable replacement character;

        N(   s   streams   selfs   errors(   s   selfs   streams   errors(    (    s   /usr/lib/python2.2/codecs.pys   __init__ s   ic 
   s     | d j  o'  |  i |  i i   |  i  d Sn  |  i i }  |  i }  | |  }  d }  x  d o  y  | | |  i  \ } } Wnc  t
 j
 oT }  | d }  | d  }	  |	 p
 | d j o
    n  | |	 } n	 X | Sqv Wd S(   s   Decodes data from the stream self.stream and returns the
            resulting object.

            size indicates the approximate maximum number of bytes to
            read from the stream for decoding purposes. The decoder
            can modify this setting as appropriate. The default value
            -1 indicates to read and decode as much as possible.  size
            is intended to prevent having to decode huge files in one
            step.

            The method should use a greedy read strategy meaning that
            it should read as much data as is allowed within the
            definition of the encoding and the given size, e.g.  if
            optional encoding endings or state markers are available
            on the stream, these should be read too.

        i    i   i
   N(   s   sizes   selfs   decodes   streams   reads   errorss   datas   is   objects   decodedbytess
   ValueErrors   whys   newdata(
   s   selfs   sizes   whys   decodedbytess   is   objects   decodes   reads   datas   newdata(    (    s   /usr/lib/python2.2/codecs.pys   read s$   '	 

c    s_      | t j o  |  i i   } n  |  i i |  }  |  i | |  i  d Sd S(   sv   Read one line from the input stream and return the
            decoded data.

            Note: Unlike the .readlines() method, this method inherits
            the line breaking knowledge from the underlying stream's
            .readline() method -- there is currently no support for
            line breaking using the codec decoder due to lack of line
            buffering. Sublcasses should however, if possible, try to
            implement this method using their own knowledge of line
            breaking.

            size, if given, is passed as size argument to the stream's
            .readline() method.

        i    N(   s   sizes   Nones   selfs   streams   readlines   lines   decodes   errors(   s   selfs   sizes   line(    (    s   /usr/lib/python2.2/codecs.pys   readline s
   c    sh    
| t j o |  i i   } n |  i i |  } |  i | |  i  d i d  Sd S(   sI   Read all lines available on the input stream
            and return them as list of lines.

            Line breaks are implemented using the codec's decoder
            method and are included in the list entries.

            sizehint, if given, is passed as size argument to the
            stream's .read() method.

        i    i   N(	   s   sizehints   Nones   selfs   streams   reads   datas   decodes   errorss
   splitlines(   s   selfs   sizehints   data(    (    s   /usr/lib/python2.2/codecs.pys	   readlines s
   c    s   d S(   s    Resets the codec buffers used for keeping state.

            Note that no stream repositioning should take place.
            This method is primarily intended to be able to recover
            from decoding errors.

        N(    (   s   self(    (    s   /usr/lib/python2.2/codecs.pys   resets   c    s    !| |  i |  Sd S(   s?    Inherit all other methods from the underlying stream.
        N(   s   getattrs   selfs   streams   name(   s   selfs   names   getattr(    (    s   /usr/lib/python2.2/codecs.pys   __getattr__s   (
   s   __name__s
   __module__s   __init__s   reads   Nones   readlines	   readliness   resets   getattrs   __getattr__(    (    (    s   /usr/lib/python2.2/codecs.pys   StreamReader s   	*s   StreamReaderWriterc      s   %t  Z d  Z .0d Z 2d d  Z Dd d  Z He d  Z Le d  Z Pd   Z	 Td	   Z
 Xd
   Z ]e d  Z RS(   s   StreamReaderWriter instances allow wrapping streams which
        work in both read and write modes.

        The design is such that one can use the factory functions
        returned by the codec.lookup() function to construct the
        instance.

    s   unknowns   strictc    sL   2>?| |  _  @| | |  |  _ A| | |  |  _ B| |  _ d S(   sR   Creates a StreamReaderWriter instance.

            stream must be a Stream-like object.

            Reader, Writer must be factory functions or classes
            providing the StreamReader, StreamWriter interface resp.

            Error handling is done in the same way as defined for the
            StreamWriter/Readers.

        N(   s   streams   selfs   Readers   errorss   readers   Writers   writer(   s   selfs   streams   Readers   Writers   errors(    (    s   /usr/lib/python2.2/codecs.pys   __init__2s
   ic    s   DF|  i i |  Sd  S(   N(   s   selfs   readers   reads   size(   s   selfs   size(    (    s   /usr/lib/python2.2/codecs.pys   readDs   c    s   HJ|  i i |  Sd  S(   N(   s   selfs   readers   readlines   size(   s   selfs   size(    (    s   /usr/lib/python2.2/codecs.pys   readlineHs   c    s   LN|  i i |  Sd  S(   N(   s   selfs   readers	   readliness   sizehint(   s   selfs   sizehint(    (    s   /usr/lib/python2.2/codecs.pys	   readlinesLs   c    s   PR|  i i |  Sd  S(   N(   s   selfs   writers   writes   data(   s   selfs   data(    (    s   /usr/lib/python2.2/codecs.pys   writePs   c    s   TV|  i i |  Sd  S(   N(   s   selfs   writers
   writeliness   list(   s   selfs   list(    (    s   /usr/lib/python2.2/codecs.pys
   writelinesTs   c    s'   XZ|  i i   [|  i i   d  S(   N(   s   selfs   readers   resets   writer(   s   self(    (    s   /usr/lib/python2.2/codecs.pys   resetXs   c    s   ]ab| |  i |  Sd S(   s?    Inherit all other methods from the underlying stream.
        N(   s   getattrs   selfs   streams   name(   s   selfs   names   getattr(    (    s   /usr/lib/python2.2/codecs.pys   __getattr__]s   (   s   __name__s
   __module__s   __doc__s   encodings   __init__s   reads   Nones   readlines	   readliness   writes
   writeliness   resets   getattrs   __getattr__(    (    (    s   /usr/lib/python2.2/codecs.pys   StreamReaderWriter%s   		s   StreamRecoderc      s   ft  Z d  Z vxd Z yd Z {d d  Z d d  Z e d  Z e d  Z	 d   Z
 d	   Z d
   Z e d  Z RS(   sE   StreamRecoder instances provide a frontend - backend
        view of encoding data.

        They use the complete set of APIs returned by the
        codecs.lookup() function to implement their task.

        Data written to the stream is first decoded into an
        intermediate format (which is dependent on the given codec
        combination) and then written to the stream using an instance
        of the provided Writer class.

        In the other direction, data is read from the stream using a
        Reader instance and then return encoded data to the caller.

    s   unknowns   strictc    sd   {| |  _  | |  _ | |  _ | | |  |  _ | | |  |  _ | |  _ d S(   s   Creates a StreamRecoder instance which implements a two-way
            conversion: encode and decode work on the frontend (the
            input to .read() and output of .write()) while
            Reader and Writer work on the backend (reading and
            writing to the stream).

            You can use these objects to do transparent direct
            recodings from e.g. latin-1 to utf-8 and back.

            stream must be a file-like object.

            encode, decode must adhere to the Codec interface, Reader,
            Writer must be factory functions or classes providing the
            StreamReader, StreamWriter interface resp.

            encode and decode are needed for the frontend translation,
            Reader and Writer for the backend translation. Unicode is
            used as intermediate encoding.

            Error handling is done in the same way as defined for the
            StreamWriter/Readers.

        N(	   s   streams   selfs   encodes   decodes   Readers   errorss   readers   Writers   writer(   s   selfs   streams   encodes   decodes   Readers   Writers   errors(    (    s   /usr/lib/python2.2/codecs.pys   __init__{s   ic    sA   |  i i |  } |  i | |  i  \ } } | Sd  S(   N(   s   selfs   readers   reads   sizes   datas   encodes   errorss   bytesencoded(   s   selfs   sizes   bytesencodeds   data(    (    s   /usr/lib/python2.2/codecs.pys   reads   c    sg   | t j o |  i i   } n |  i i |  } |  i | |  i  \ } } | Sd  S(   N(	   s   sizes   Nones   selfs   readers   readlines   datas   encodes   errorss   bytesencoded(   s   selfs   sizes   bytesencodeds   data(    (    s   /usr/lib/python2.2/codecs.pys   readlines
   c    sp   | t j o |  i i   } n |  i i |  } |  i | |  i  \ } } | i	 d  Sd  S(   Ni   (
   s   sizehints   Nones   selfs   readers   reads   datas   encodes   errorss   bytesencodeds
   splitlines(   s   selfs   sizehints   datas   bytesencoded(    (    s   /usr/lib/python2.2/codecs.pys	   readliness
   c    s8   |  i | |  i  \ } } |  i i |  Sd  S(   N(   s   selfs   decodes   datas   errorss   bytesdecodeds   writers   write(   s   selfs   datas   bytesdecoded(    (    s   /usr/lib/python2.2/codecs.pys   writes   c    sJ   d i  |  } |  i | |  i  \ } } |  i i |  Sd  S(   Ns    (	   s   joins   lists   datas   selfs   decodes   errorss   bytesdecodeds   writers   write(   s   selfs   lists   datas   bytesdecoded(    (    s   /usr/lib/python2.2/codecs.pys
   writeliness   c    s'   |  i i   |  i i   d  S(   N(   s   selfs   readers   resets   writer(   s   self(    (    s   /usr/lib/python2.2/codecs.pys   resets   c    s   | |  i |  Sd S(   s?    Inherit all other methods from the underlying stream.
        N(   s   getattrs   selfs   streams   name(   s   selfs   names   getattr(    (    s   /usr/lib/python2.2/codecs.pys   __getattr__s   (   s   __name__s
   __module__s   __doc__s   data_encodings   file_encodings   __init__s   reads   Nones   readlines	   readliness   writes
   writeliness   resets   getattrs   __getattr__(    (    (    s   /usr/lib/python2.2/codecs.pys   StreamRecoderfs   		!		s   rbs   stricti   c    s   | t j	 o
 d | j o | d } n t i |  | |  }	 | t j o |	 Sn t |  \ } } } } t |	 | | |  }
 | |
 _  |
 Sd S(   s   Open an encoded file using the given mode and return
        a wrapped version providing transparent encoding/decoding.

        Note: The wrapped version will only accept the object format
        defined by the codecs, i.e. Unicode objects for most builtin
        codecs. Output is also codec dependent and will usually by
        Unicode as well.

        Files are always opened in binary mode, even if no binary mode
        was specified. Thisis done to avoid data loss due to encodings
        using 8-bit values. The default file mode is 'rb' meaning to
        open the file in binary read mode.

        encoding specifies the encoding which is to be used for the
        the file.

        errors may be given to define the error handling. It defaults
        to 'strict' which causes ValueErrors to be raised in case an
        encoding error occurs.

        buffering has the same meaning as for the builtin open() API.
        It defaults to line buffered.

        The returned wrapped file object provides an extra attribute
        .encoding which allows querying the used encoding. This
        attribute is only available if an encoding was specified as
        parameter.

    s   bN(   s   encodings   Nones   modes   __builtin__s   opens   filenames	   bufferings   files   lookups   es   ds   srs   sws   StreamReaderWriters   errorss   srw(   s   filenames   modes   encodings   errorss	   bufferings   es   ds   srs   sws   files   srw(    (    s   /usr/lib/python2.2/codecs.pys   opens   c 	   s   | t j o | } n t |  d  \ } } t |  d \ } } t |  | | | | |  } | | _ | | _  | Sd S(   s   Return a wrapped version of file which provides transparent
        encoding translation.

        Strings written to the wrapped file are interpreted according
        to the given data_encoding and then written to the original
        file as string using file_encoding. The intermediate encoding
        will usually be Unicode but depends on the specified codecs.

        Strings are read from the file using file_encoding and then
        passed back to the caller as string using data_encoding.

        If file_encoding is not given, it defaults to data_encoding.

        errors may be given to define the error handling. It defaults
        to 'strict' which causes ValueErrors to be raised in case an
        encoding error occurs.

        The returned wrapped file object provides two extra attributes
        .data_encoding and .file_encoding which reflect the given
        parameters of the same name. The attributes can be used for
        introspection by Python programs.

    i   N(   s   file_encodings   Nones   data_encodings   lookups   encodes   decodes   Readers   Writers   StreamRecoders   files   errorss   sr(	   s   files   data_encodings   file_encodings   errorss   srs   Writers   decodes   Readers   encode(    (    s   /usr/lib/python2.2/codecs.pys   EncodedFiles   	c    s    '(t  |   d Sd S(   s    Lookup up the codec for the given encoding and return
        its encoder function.

        Raises a LookupError in case the encoding cannot be found.

    i    N(   s   lookups   encoding(   s   encoding(    (    s   /usr/lib/python2.2/codecs.pys
   getencoder s   c    s   *12t  |   d Sd S(   s    Lookup up the codec for the given encoding and return
        its decoder function.

        Raises a LookupError in case the encoding cannot be found.

    i   N(   s   lookups   encoding(   s   encoding(    (    s   /usr/lib/python2.2/codecs.pys
   getdecoder*s   c    s   4;<t  |   d Sd S(   s    Lookup up the codec for the given encoding and return
        its StreamReader class or factory function.

        Raises a LookupError in case the encoding cannot be found.

    i   N(   s   lookups   encoding(   s   encoding(    (    s   /usr/lib/python2.2/codecs.pys	   getreader4s   c    s   >EFt  |   d Sd S(   s    Lookup up the codec for the given encoding and return
        its StreamWriter class or factory function.

        Raises a LookupError in case the encoding cannot be found.

    i   N(   s   lookups   encoding(   s   encoding(    (    s   /usr/lib/python2.2/codecs.pys	   getwriter>s   c    s>   JQRh  } Sx |  DS] } T| | | <q WU| Sd S(   s    make_identity_dict(rng) -> dict

        Return a dictionary where elements of the rng sequence are
        mapped to themselves.

    N(   s   ress   rngs   i(   s   rngs   is   res(    (    s   /usr/lib/python2.2/codecs.pys   make_identity_dictJs   	
 	c    so   Wcdh  } exO |  i   De]> \ } } f| i |  o g| | | <n it | | <q Wj| Sd S(   s   Creates an encoding map from a decoding map.

        If a target mapping in the decoding map occurrs multiple
        times, then that target is mapped to None (undefined mapping),
        causing an exception when encountered by the charmap codec
        during translation.

        One example where this happens is cp875.py which decodes
        multiple character to \u001a.

    N(   s   ms   decoding_maps   itemss   ks   vs   has_keys   None(   s   decoding_maps   ms   ks   v(    (    s   /usr/lib/python2.2/codecs.pys   make_encoding_mapWs   	 i    s   __main__s   latin-1s   utf-8($   s   __doc__s   structs   __builtin__s   _codecss   ImportErrors   whys   SystemErrors   __all__s   packs   BOMs   BOM_BEs   BOM32_BEs   BOM_LEs   BOM32_LEs   BOM64_BEs   BOM64_LEs   Codecs   StreamWriters   StreamReaders   StreamReaderWriters   StreamRecoders   Nones   opens   EncodedFiles
   getencoders
   getdecoders	   getreaders	   getwriters   make_identity_dicts   make_encoding_maps   _falses	   encodingss   __name__s   syss   stdouts   stdin(   s   make_encoding_maps
   getdecoders   StreamReaderWriters   __builtin__s   BOM64_LEs   syss   BOM_LEs   Codecs   BOMs   _falses	   encodingss	   getreaders   StreamRecoders   opens   whys   EncodedFiles   StreamWriters   structs   __all__s   BOM64_BEs   BOM_BEs   BOM32_BEs	   getwriters
   getencoders   BOM32_LEs   make_identity_dicts   StreamReader(    (    s   /usr/lib/python2.2/codecs.pys   ? s>   *		@8}Ag,'


	
