;
Îâ"Ic               @   sy   d  Z  d d l Z d d l m Z i  Z d Z d g Z e j Z Gd „  d e e	 ƒ Z
 d	 „  Z d
 „  Z e j e ƒ d S(   u,   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() -> codecs.CodecInfo object
    The getregentry() API must a CodecInfo object with encoder, decoder,
    incrementalencoder, incrementaldecoder, streamwriter and streamreader
    atttributes 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.

i    Ni   (   u   aliasesu   --unknown--u   *c             B   s   |  Ee  Z d  S(   N(   u   __name__u
   __module__(   u
   __locals__(    (    u/   /mit/python/lib/python3.0/encodings/__init__.pyu   CodecRegistryError'   s   
u   CodecRegistryErrorc             C   s£   t  |  t ƒ o t |  d ƒ }  n g  } d } xd |  D]\ } | j ƒ  p | d k o6 | o | o | j d ƒ n | j | ƒ d } q6 d } q6 Wd j | ƒ S(   u´   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.

    u   asciiu   .u   _u    FT(   u
   isinstanceu   bytesu   stru   Falseu   isalnumu   appendu   Trueu   join(   u   encodingu   charsu   punctu   c(    (    u/   /mit/python/lib/python3.0/encodings/__init__.pyu   normalize_encoding*   s     

c       
      C   sh  t  j |  t ƒ } | t k	 o | St |  ƒ } t j | ƒ p t j | j d d ƒ ƒ } | d  k	 o | | g } n
 | g } xh | D]Z } | p d | k o qˆ n y  t d | d t d d ƒ} Wn t	 k
 o Yqˆ XPqˆ Wd  } y | j
 } Wn t k
 o d  } Yn X| d  k o d  t  |  <d  S| ƒ  } t | t j ƒ p¹d t | ƒ k o
 d k n p  t d	 | j | j f ƒ ‚ n t | d d
 ƒ pÓ t | d d
 ƒ p¾ | d d  k	 o t | d d
 ƒ p˜ | d d  k	 o t | d d
 ƒ pr t | ƒ d k o& | d d  k	 o t | d d
 ƒ p9 t | ƒ d k oF | d d  k	 o5 t | d d
 ƒ o  t d | j | j f ƒ ‚ n t | ƒ d k  p | d d  k o6 | d d t | ƒ | j j d d ƒ d f 7} n t j | Œ  } n | t  |  <y | j ƒ  } Wn t k
 o Yn. Xx) | D]! }	 |	 t k o | t |	 <q?q?W| S(   Nu   .u   _u
   encodings.u   fromlistu   leveli    i   i   u#   module "%s" (%s) failed to registeru   __call__i   i   i   i   u'   incompatible codecs in module "%s" (%s)i   (   N(   u   _cacheu   getu   _unknownu   normalize_encodingu   _aliasesu   replaceu   Noneu
   __import__u   _import_tailu   ImportErroru   getregentryu   AttributeErroru
   isinstanceu   codecsu	   CodecInfou   lenu   CodecRegistryErroru   __name__u   __file__u   hasattru   splitu
   getaliases(
   u   encodingu   entryu   norm_encodingu   aliased_encodingu   modnamesu   modnameu   modu   getregentryu   codecaliasesu   alias(    (    u/   /mit/python/lib/python3.0/encodings/__init__.pyu   search_functionE   sl    		 
	$&&99$6
 (   u   __doc__u   codecsu    u   aliasesu   _cacheu   _unknownu   _import_tailu   _aliasesu   LookupErroru   SystemErroru   CodecRegistryErroru   normalize_encodingu   search_functionu   register(    (    (    u/   /mit/python/lib/python3.0/encodings/__init__.pyu   <module>   s   				T