mς
­fIc           @   s   d  Z  d k Z d k Z d k Z d k Z h  Z d Z d g Z d Z e i Z	 d e i
 e i f d     YZ d   Z d   Z e i e  d S(	   sέ   Standard "encodings" Package

    Standard Python encoding modules are stored in this package
    directory.

    Codec modules must have names corresponding to normalized encoding
    names as defined in the normalize_encoding() function below, e.g.
    'utf-8' must be implemented by the module 'utf_8.py'.

    Each codec module must export the following interface:

    * getregentry() -> (encoder, decoder, stream_reader, stream_writer)
    The getregentry() API must return callable objects which adhere to
    the Python Codec Interface Standard.

    In addition, a module may optionally also define the following
    APIs which are then used by the package's codec search function:

    * getaliases() -> sequence of encoding name strings to use as aliases

    Alias names returned by getaliases() must be normalized encoding
    names as defined by normalize_encoding().

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

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

Ns   --unknown--t   *s                                                 . 0123456789       ABCDEFGHIJKLMNOPQRSTUVWXYZ      abcdefghijklmnopqrstuvwxyz                                                                                                                                     t   CodecRegistryErrorc           B   s   t  Z RS(   N(   t   __name__t
   __module__(    (    (    t/   /mit/python/lib/python2.4/encodings/__init__.pyR   +   s   c         C   sE   t  |   t i j o |  i d  }  n d i |  i t  i    S(   s΄   Normalize an encoding name.

        Normalization works as follows: all non-alphanumeric
        characters except the dot used for Python package names are
        collapsed and replaced with a single underscore, e.g. '  -;#'
        becomes '_'. Leading and trailing underscores are removed.

        Note that encoding names should be ASCII only; if they do use
        non-ASCII characters, these must be Latin-1 compatible.

    s   latin-1t   _N(	   t   typet   encodingt   typest   UnicodeTypet   encodet   joint	   translatet   _norm_encoding_mapt   split(   R   (    (    R   t   normalize_encoding/   s     c         C   s  t  i |  t  }
 |
 t j	 o |
 Sn t |   } t i |  p t i | i d d   } | d  j	 o | | g } n
 | g } xX | D]J } | p q n y t | t   t   t  } Wn t j
 o q XPq Wd  } y | i } Wn t j
 o d  } n X| d  j o d  t  |  <d  Sn t |    }
 t |
  d j o t d | i | i f  n x8 |
 D]0 } t |  p t d | i | i f  qmqmW|
 t  |  <y | i   } Wn t j
 o n1 Xx, | D]$ }	 t i |	  p | t |	 <qΨqΨW|
 S(   Nt   .R   i   s#   module "%s" (%s) failed to registers'   incompatible codecs in module "%s" (%s)(    t   _cachet   getR   t   _unknownt   entryR   t   norm_encodingt   _aliasest   replacet   aliased_encodingt   Nonet   modnamest   modnamet
   __import__t   globalst   localst   _import_tailt   modt   ImportErrort   getregentryt   AttributeErrort   tuplet   lenR   R   t   __file__t   objt   callablet
   getaliasest   codecaliasest   aliast   has_key(   R   R   R"   R*   R   R    R   R'   R   R+   R   (    (    R   t   search_functionE   sV    	+	 
 !
 (   t   __doc__t   codecst
   exceptionsR   t   aliasesR   R   R   R   R   t   LookupErrort   SystemErrorR   R   R-   t   register(   R-   R   R   R   R   R/   R0   R   R   R   R   R1   (    (    R   t   ?   s   $				L