ó
è¾bc           @   sY  d  Z  d d l Z d d l Z d d l Z d d d d d d d	 d
 g Z d d d „ Z d d d „ Z e Z d 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 d d d „ Z d d d d „ Z d e f d „  ƒ  YZ d
 e f d „  ƒ  YZ e Z y> d d l m Z m Z m Z m Z m Z e Z e Z  e! Z Wn# e" k
 r›g  Z d  Z i  Z  n Xe e j# ƒ e sRe$ e% g Z& e j' râe j( j) râe& j* e+ ƒ n  x e& D] Z, e d! d" e, ƒqéWe j( j- Z- e- d k r$d# Z. n e- r3d  Z. n d! Z. e e. d" e/ d$ d ƒn  [ d S(%   s&   Python part of the warnings subsystem.iÿÿÿÿNt   warnt   warn_explicitt   showwarningt   formatwarningt   filterwarningst   simplefiltert   resetwarningst   catch_warningsi   c         C   s9   t  j r5 | d k r t } n  t |  | | d ƒ n  d S(   s‡   Issue a deprecation warning for Python 3.x related changes.

    Warnings are omitted unless Python is started with the -3 option.
    i   N(   t   syst   py3kwarningt   Nonet   DeprecationWarningR    (   t   messaget   categoryt
   stacklevel(    (    s   /usr/lib/python2.7/warnings.pyt   warnpy3k   s    		c         C   si   | d k r( t j } | d k r( d Sn  y# | j t |  | | | | ƒ ƒ Wn t t f k
 rd n Xd S(   s7   Hook to write a warning to a file; replace if you like.N(   R
   R   t   stderrt   writeR   t   IOErrort   UnicodeError(   R   R   t   filenamet   linenot   filet   line(    (    s   /usr/lib/python2.7/warnings.pyt   _show_warning   s    	#c         C   sF  y
 t  } Wn t k
 r# d } n Xy t |  ƒ }  Wn t k
 rG n Xd | | j |  f } | d k r| t j | | ƒ n | } | rÕ | j ƒ  } t	 | | ƒ rÄ t	 | t ƒ rÄ t  | d ƒ } n  | d | 7} n  t	 | | ƒ r2t	 | t ƒ r2t
 j ƒ  } | r2y t  | | ƒ } Wq/t k
 r+q/Xq2n  d | | f } | S(   s.   Function to format a warning the standard way.s   %s: %s: %s
t   latin1s     %s
s   %s:%s(    N(   t   unicodet	   NameErrort   strt   UnicodeEncodeErrort   __name__R
   t	   linecachet   getlinet   stript
   isinstanceR   t   getfilesystemencodingt   UnicodeDecodeError(   R   R   R   R   R   t   unicodetypet   st   enc(    (    s   /usr/lib/python2.7/warnings.pyR   (   s0    

$
t    i    c         C   s*  d d l  } |  d k s+ t d	 |  f ƒ ‚ t | t ƒ sF t d
 ƒ ‚ t | t t j f ƒ sj t d ƒ ‚ t | t ƒ s… t d ƒ ‚ t | t ƒ s  t d ƒ ‚ t | t	 t
 f ƒ rÁ | d k sÍ t d ƒ ‚ |  | j | | j ƒ | | j | ƒ t	 | ƒ f } | rt j | ƒ n t j d | ƒ d S(   sÖ  Insert an entry into the list of warnings filters (at the front).

    'action' -- one of "error", "ignore", "always", "default", "module",
                or "once"
    'message' -- a regex that the warning message must match
    'category' -- a class that the warning must be a subclass of
    'module' -- a regex that the module name must match
    'lineno' -- an integer line number, 0 matches all warnings
    'append' -- if true, append to the list of filters
    iÿÿÿÿNt   errort   ignoret   alwayst   defaultt   modulet   onces   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(   R)   R*   R+   R,   R-   R.   (   t   ret   AssertionErrorR"   t
   basestringt   typet   typest	   ClassTypet
   issubclasst   Warningt   intt   longt   compilet   It   filterst   appendt   insert(   t   actionR   R   R-   R   R<   R/   t   item(    (    s   /usr/lib/python2.7/warnings.pyR   C   s    	$	c         C   s‘   |  d k s t  d |  f ƒ ‚ t | t t f ƒ r@ | d k sL t  d	 ƒ ‚ |  d
 | d
 t | ƒ f } | r} t j | ƒ n t j 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.
    'action' -- one of "error", "ignore", "always", "default", "module",
                or "once"
    'category' -- a class that the warning must be a subclass of
    'lineno' -- an integer line number, 0 matches all warnings
    'append' -- if true, append to the list of filters
    R)   R*   R+   R,   R-   R.   s   invalid action: %ri    s   lineno must be an int >= 0N(   R)   R*   R+   R,   R-   R.   (   R0   R"   R7   R8   R
   R;   R<   R=   (   R>   R   R   R<   R?   (    (    s   /usr/lib/python2.7/warnings.pyR   `   s    
$	c           C   s   g  t  (d S(   sA   Clear the list of warning filters, so that no filters are active.N(   R;   (    (    (    s   /usr/lib/python2.7/warnings.pyR   t   s    t   _OptionErrorc           B   s   e  Z d  Z RS(   s,   Exception used by option processing helpers.(   R   t
   __module__t   __doc__(    (    (    s   /usr/lib/python2.7/warnings.pyR@   x   s   c         C   sL   xE |  D]= } y t  | ƒ Wq t k
 rC } t j d I| IJq Xq Wd  S(   Ns   Invalid -W option ignored:(   t
   _setoptionR@   R   R   (   t   argst   argt   msg(    (    s   /usr/lib/python2.7/warnings.pyt   _processoptions}   s
    c   	      C   s[  d d  l  } |  j d ƒ } t | ƒ d k rC t d |  f ƒ ‚ n  x# t | ƒ d k  rh | j d ƒ qF Wg  | D] } | j ƒ  ^ qp \ } } } } } t | ƒ } | j | ƒ } t | ƒ } | j | ƒ } | rà | d } n  | r;y% t	 | ƒ } | d k  r
t
 ‚ n  WqAt
 t f k
 r7t d | f ƒ ‚ qAXn d } t | | | | | ƒ d  S(	   Niÿÿÿÿt   :i   s   too many fields (max 5): %rR(   t   $i    s   invalid lineno %r(   R/   t   splitt   lenR@   R<   R!   t
   _getactiont   escapet   _getcategoryR7   t
   ValueErrort   OverflowErrorR   (	   RE   R/   t   partsR&   R>   R   R   R-   R   (    (    s   /usr/lib/python2.7/warnings.pyRC   …   s.    +c         C   sU   |  s
 d S|  d k r d Sx! d	 D] } | j  |  ƒ r! | Sq! Wt d |  f ƒ ‚ d  S(
   NR,   t   allR+   R*   R-   R.   R)   s   invalid action: %r(   R,   R+   R*   R-   R.   R)   (   t
   startswithR@   (   R>   t   a(    (    s   /usr/lib/python2.7/warnings.pyRL       s     c         C   s/  d d  l  } |  s t S| j d |  ƒ rb y t |  ƒ } Wqt k
 r^ t d |  f ƒ ‚ qXn¤ |  j d ƒ } |  |  } |  | d } y t | d  d  | g ƒ } Wn$ t	 k
 rË t d | f ƒ ‚ n Xy t
 | | ƒ } Wn$ t k
 rt d |  f ƒ ‚ n Xt | t ƒ s+t d |  f ƒ ‚ n  | S(   Niÿÿÿÿs   ^[a-zA-Z0-9_]+$s   unknown warning category: %rt   .i   s   invalid module name: %rs   invalid warning category: %r(   R/   R6   t   matcht   evalR   R@   t   rfindt
   __import__R
   t   ImportErrort   getattrt   AttributeErrorR5   (   R   R/   t   catt   iR-   t   klasst   m(    (    s   /usr/lib/python2.7/warnings.pyRN   ª   s,    
c   
      C   sg  t  |  t ƒ r |  j } n  | d k r0 t } n  t | t ƒ sE t ‚ y t j | ƒ } Wn  t	 k
 rz t j
 } d } n X| j } | j } d | k r¦ | d } n d } | j d ƒ } | rì | j ƒ  } | j d ƒ r5| d  } q5nI | d k r&y t j d	 } Wq&t k
 r"d } q&Xn  | s5| } n  | j d
 i  ƒ }	 t |  | | | | |	 | ƒ d S(   s:   Issue a warning, or maybe ignore it or raise an exception.i   R   s   <string>t   __file__s   .pycs   .pyoiÿÿÿÿt   __main__i    t   __warningregistry__N(   s   .pycs   .pyo(   R"   R6   t	   __class__R
   t   UserWarningR5   R0   R   t	   _getframeRO   t   __dict__t	   f_globalst   f_linenot   gett   lowert   endswitht   argvR\   t
   setdefaultR   (
   R   R   R   t   callert   globalsR   R-   R   t   fnlt   registry(    (    s   /usr/lib/python2.7/warnings.pyR    Å   s<    		
			c         C   sb  t  | ƒ } | d  k rJ | p! d } | d j ƒ  d k rJ | d  } qJ n  | d  k r_ i  } n  t |  t ƒ r† t |  ƒ } |  j } n |  } | |  ƒ }  | | | f } | j | ƒ rº d  SxŠ t D]| }	 |	 \ }
 } } } } | d  k s÷ | j	 | ƒ rÁ t
 | | ƒ rÁ | d  k s!| j	 | ƒ rÁ | d k s9| | k rÁ PqÁ qÁ Wt }
 |
 d k rad | | <d  St j | | ƒ |
 d k r†|  ‚ n  |
 d k rÈd | | <| | f } t j | ƒ r»d  Sd t | <nƒ |
 d	 k r×nt |
 d
 k rd | | <| | d f } | j | ƒ rd  Sd | | <n/ |
 d k r5d | | <n t d |
 |	 f ƒ ‚ t |  | | | ƒ d  S(   Ns	   <unknown>iýÿÿÿs   .pyi    R*   i   R)   R.   R+   R-   R,   s1   Unrecognized action (%r) in warnings.filters:
 %s(   R7   R
   Rk   R"   R6   R   Rd   Rj   R;   RV   R5   t   defaultactionR   t   getlinest   onceregistryt   RuntimeErrorR   (   R   R   R   R   R-   Rr   t   module_globalst   textt   keyR?   R>   RF   R]   t   modt   lnt   oncekeyt   altkey(    (    s   /usr/lib/python2.7/warnings.pyR   í   sb    	
	

t   WarningMessagec           B   s,   e  Z d  Z d	 Z d
 d
 d „ Z d „  Z RS(   s0   Holds the result of a single showwarning() call.R   R   R   R   R   R   c         C   sR   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | rE | j n d  |  _ d  S(   N(	   R   R   R   R   R   R   R   R
   t   _category_name(   t   selfR   R   R   R   R   R   (    (    s   /usr/lib/python2.7/warnings.pyt   __init__6  s    						c         C   s&   d |  j  |  j |  j |  j |  j f S(   NsD   {message : %r, category : %r, filename : %r, lineno : %s, line : %r}(   R   R   R   R   R   (   R€   (    (    s   /usr/lib/python2.7/warnings.pyt   __str__@  s    (   R   R   R   R   R   R   N(   R   RA   RB   t   _WARNING_DETAILSR
   R   R‚   (    (    (    s   /usr/lib/python2.7/warnings.pyR~   /  s    	c           B   s8   e  Z d  Z e d d „ Z d „  Z d „  Z d „  Z RS(   s  A context manager that copies and restores the warnings filter upon
    exiting the context.

    The 'record' argument specifies whether warnings should be captured by a
    custom implementation of warnings.showwarning() and be appended to a list
    returned by the context manager. Otherwise None is returned by the context
    manager. The objects appended to the list are arguments whose attributes
    mirror the arguments to showwarning().

    The 'module' argument is to specify an alternative module to the module
    named 'warnings' and imported under that name. This argument is only useful
    when testing the warnings module itself.

    c         C   s8   | |  _  | d k r" t j d n | |  _ t |  _ d S(   sê   Specify whether to record warnings and if an alternative module
        should be used other than sys.modules['warnings'].

        For compatibility with Python 3.0, please consider all arguments to be
        keyword-only.

        t   warningsN(   t   _recordR
   R   t   modulest   _modulet   Falset   _entered(   R€   t   recordR-   (    (    s   /usr/lib/python2.7/warnings.pyR   W  s    	"c         C   sr   g  } |  j  r | j d ƒ n  |  j t j d k	 rL | j d |  j ƒ n  t |  ƒ j } d | d j | ƒ f S(   Ns   record=TrueR„   s	   module=%rs   %s(%s)s   , (   R…   R<   R‡   R   R†   R2   R   t   join(   R€   RD   t   name(    (    s   /usr/lib/python2.7/warnings.pyt   __repr__c  s    	c            s‰   |  j  r t d |  ƒ ‚ n  t |  _  |  j j |  _ |  j |  j _ |  j j |  _ |  j r g  ‰  ‡  f d †  } | |  j _ ˆ  Sd  Sd  S(   Ns   Cannot enter %r twicec             s   ˆ  j  t |  | Ž  ƒ d  S(   N(   R<   R~   (   RD   t   kwargs(   t   log(    s   /usr/lib/python2.7/warnings.pyR   u  s    (
   R‰   Rv   t   TrueR‡   R;   t   _filtersR   t   _showwarningR…   R
   (   R€   R   (    (   R   s   /usr/lib/python2.7/warnings.pyt	   __enter__l  s    			c         G   s>   |  j  s t d |  ƒ ‚ n  |  j |  j _ |  j |  j _ d  S(   Ns%   Cannot exit %r without entering first(   R‰   Rv   R‘   R‡   R;   R’   R   (   R€   t   exc_info(    (    s   /usr/lib/python2.7/warnings.pyt   __exit__|  s    	N(	   R   RA   RB   Rˆ   R
   R   R   R“   R•   (    (    (    s   /usr/lib/python2.7/warnings.pyR   F  s
   			(   R;   t   default_actiont   once_registryR    R   R,   R*   R   R)   R<   (0   RB   R   R   R3   t   __all__R
   R   R   R   R   R6   R   R   R   t	   ExceptionR@   RG   RC   RL   RN   R    R   t   objectR~   R   Rˆ   t   _warnings_defaultst	   _warningsR;   R–   R—   Rs   Ru   R   RZ   t   warnoptionst   ImportWarningt   PendingDeprecationWarningt   silenceR	   t   flagst   division_warningR<   R   t   clst   bytes_warningt   bytes_actiont   BytesWarning(    (    (    s   /usr/lib/python2.7/warnings.pyt   <module>   s`   		
				
	)AE(

		