mò
­fIc           @   s%  d  Z  d k Z d k Z d k Z d d d d d g Z g  Z d Z h  Z d d d	 „ Z	 d d d
 „ Z
 d d „ Z d „  Z d e d d d d „ Z e d d d „ Z d „  Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z e e i ƒ e d d e d d ƒe d d e d d ƒd S(   s&   Python part of the warnings subsystem.Nt   warnt   showwarningt   formatwarningt   filterwarningst   resetwarningst   defaulti   c   
      C   sˆ  t  |  t ƒ o |  i } n | d j o
 t } n t | t ƒ p t ‚ y t	 i
 | ƒ } Wn" t j
 o t	 i } d } n X| i } | i } d | j o | d } n d } | i d ƒ } | o> | i ƒ  } | i d ƒ p | i d ƒ o | d  } qYnP | d j o1 y t	 i d	 } WqHt j
 o d } qHXn | p
 | } n | i d
 h  ƒ }	 t |  | | | | |	 ƒ d S(   s:   Issue a warning, or maybe ignore it or raise an exception.i   t   __name__s   <string>t   __file__s   .pycs   .pyoiÿÿÿÿt   __main__i    t   __warningregistry__N(   t
   isinstancet   messaget   Warningt	   __class__t   categoryt   Nonet   UserWarningt
   issubclasst   AssertionErrort   syst	   _getframet
   stacklevelt   callert
   ValueErrort   __dict__t   globalst   linenot	   f_globalst   f_linenot   modulet   gett   filenamet   lowert   fnlt   endswitht   argvt   AttributeErrort
   setdefaultt   registryt   warn_explicit(
   R   R   R   R!   R   R   R   R   R   R&   (    (    t%   /mit/python/lib/python2.4/warnings.pyR       s<     
			 
c         C   su  | d  j o6 | p d } | d i ƒ  d j o | d  } qC n | d  j o
 h  } n t |  t ƒ o t |  ƒ } |  i
 } n |  } | |  ƒ }  | | | f }	 | i |	 ƒ o d  Sn x’ t D]„ } | \ } } } }
 } | d  j p | i | ƒ oL t | | ƒ o< |
 d  j p |
 i | ƒ o | d j p | | j o PqÃ qÃ Wt } | d j o d | |	 <d  Sn | d j o
 |  ‚ n | d j o< d | |	 <| | f } t i | ƒ o d  Sn d t | <n | d	 j o n~ | d
 j o? d | |	 <| | d f } | i | ƒ o d  Sn d | | <n2 | d j o d | |	 <n t d | | f ƒ ‚ t |  | | | ƒ d  S(   Ns	   <unknown>iýÿÿÿs   .pyi    t   ignorei   t   errort   oncet   alwaysR   R   s1   Unrecognized action (%r) in warnings.filters:
 %s(   R   R   R   R    R&   R
   R   R   t   strt   textR   R   R   t   keyR   t   filterst   itemt   actiont   msgt   catt   modt   lnt   matchR   t   defaultactiont   oncekeyt   onceregistryt   altkeyt   RuntimeErrorR   (   R   R   R   R   R   R&   R.   R6   R3   R/   R5   R4   R;   R1   R2   R9   (    (    R(   R'   ?   sV    
 d	



c         C   sT   | d j o t i } n y  | i t |  | | | ƒ ƒ Wn t
 j
 o n Xd S(   s7   Hook to write a warning to a file; replace if you like.N(   t   fileR   R   t   stderrt   writeR   R   R   R   R   t   IOError(   R   R   R   R   R=   (    (    R(   R   z   s      c         C   sR   d | | | i |  f } t i | | ƒ i ƒ  } | o | d | d } n | S(   s.   Function to format a warning the standard way.s   %s:%s: %s: %s
s     s   
N(
   R   R   R   R   R   t   st	   linecachet   getlinet   stript   line(   R   R   R   R   RA   RE   (    (    R(   R   ƒ   s     t    i    c         C   s  d k  } |  d j p t d |  f ‚ t | t ƒ p
 t d	 ‚ t | t i ƒ p
 t d
 ‚ t	 | t
 ƒ p
 t d ‚ t | t ƒ p
 t d ‚ t | t ƒ o | d j p
 t d ‚ |  | i | | i ƒ | | i | ƒ | f } | o t i | ƒ n t i d | ƒ d S(   s†   Insert an entry into the list of warnings filters (at the front).

    Use assertions to check that all arguments have the right type.NR*   R)   R,   R   R   R+   s   invalid action: %rs   message must be a strings   category must be a classs#   category must be a Warning subclasss   module must be a stringi    s   lineno must be an int >= 0(   s   errors   ignores   alwayss   defaults   modules   once(   t   reR2   R   R
   R   t
   basestringR   t   typest	   ClassTypeR   R   R   R   t   intt   compilet   IR1   t   appendR0   t   insert(   R2   R   R   R   R   RN   R1   RG   (    (    R(   R   ‹   s     	'-c         C   s†   |  d j p t d |  f ‚ t | t ƒ o | d j p
 t d	 ‚ |  d
 | d
 | f } | o t	 i | ƒ n t	 i
 d | ƒ d
 S(   sƒ   Insert a simple entry into the list of warnings filters (at the front).

    A simple filter matches all modules and messages.
    R*   R)   R,   R   R   R+   s   invalid action: %ri    s   lineno must be an int >= 0N(   s   errors   ignores   alwayss   defaults   modules   once(   R2   R   R
   R   RK   R   R   R1   RN   R0   RO   (   R2   R   R   RN   R1   (    (    R(   t   simplefilter    s     'c           C   s   g  t  (d S(   sA   Clear the list of warning filters, so that no filters are active.N(   R0   (    (    (    R(   R   ¯   s     t   _OptionErrorc           B   s   t  Z d  Z RS(   s,   Exception used by option processing helpers.(   R   t
   __module__t   __doc__(    (    (    R(   RQ   ³   s   c         C   sN   xG |  D]? } y t | ƒ Wq t j
 o } t i d I| IJq Xq Wd  S(   Ns   Invalid -W option ignored:(   t   argst   argt
   _setoptionRQ   R3   R   R>   (   RT   R3   RU   (    (    R(   t   _processoptions¸   s     c   
      C   sl  d  k  } |  i d ƒ } t | ƒ d j o t d |  f ƒ ‚ n x% t | ƒ d j  o | i d ƒ qE Wg  } | D] } | | i	 ƒ  qu ~ \ } } } } }	 t | ƒ } | i | ƒ } t | ƒ } | i | ƒ } | o | d } n |	 oZ y' t |	 ƒ }	 |	 d j  o
 t ‚ n WqRt t f j
 o t d |	 f ƒ ‚ qRXn d }	 t | | | | |	 ƒ d  S(   Nt   :i   s   too many fields (max 5): %rRF   t   $i    s   invalid lineno %r(   RG   RU   t   splitt   partst   lenRQ   RN   t   _[1]RA   RD   R2   R   R   R   R   t
   _getactiont   escapet   _getcategoryRK   R   t   OverflowErrorR   (
   RU   R   RA   R]   RG   R[   R   R2   R   R   (    (    R(   RV   À   s.    	 6c         C   sv   |  p d Sn |  d j o d Sn x8 d d d d d d g D] } | i |  ƒ o | Sq= q= Wt d |  f ƒ ‚ d  S(	   NR   t   allR,   R)   R   R+   R*   s   invalid action: %r(   R2   t   at
   startswithRQ   (   R2   Rc   (    (    R(   R^   Û   s      c         C   sP  d  k  } |  p t Sn | i d |  ƒ o= y t |  ƒ } Wqt j
 o t d |  f ƒ ‚ qXn© |  i d ƒ } |  |  } |  | d } y t | d  d  | g ƒ } Wn& t j
 o t d | f ƒ ‚ n Xy t | | ƒ } Wn& t j
 o t d |  f ƒ ‚ n Xt | t i ƒ p t | t ƒ o t d |  f ƒ ‚ n | S(   Ns   ^[a-zA-Z0-9_]+$s   unknown warning category: %rt   .i   s   invalid module name: %rs   invalid warning category: %r(   RG   R   R   R7   t   evalR4   t	   NameErrorRQ   t   rfindt   iR   t   klasst
   __import__R   t   mt   ImportErrort   getattrR$   R
   RI   RJ   R   (   R   Ri   Rl   R   R4   RG   Rj   (    (    R(   R`   å   s,    	
%R)   R   RN   (   RS   R   RI   RB   t   __all__R0   R8   R:   R   R    R'   R   R   R   R   RP   R   t	   ExceptionRQ   RW   RV   R^   R`   t   warnoptionst   OverflowWarningt   PendingDeprecationWarning(   R   R0   RV   R   Ro   R:   RP   R`   R8   R'   RI   R   RW   R    RB   RQ   R   R   R^   (    (    R(   t   ?   s*   	';						
	