
-X7                 @   s  d  Z  d d l Z d d d d d d d	 d
 g Z d d d d  Z d d d  Z d e d d d d d  Z e d d d d  Z d d	   Z Gd d   d e	  Z
 d d   Z d d   Z d d   Z d d   Z d d d d  Z d d d d d  Z Gd d    d  e  Z Gd! d
   d
 e  Z d Z yD d d" l m Z m Z m Z m Z m Z m Z e Z e Z d# Z Wn6 e k
 rg  Z d$ Z i  Z d a d% d&   Z Yn Xe e j  e sye e  g Z! e! j" e#  x e! D] Z$ e d' d( e$ qWe j% j& Z& e& d k rd) Z' n e& r&d$ Z' n d' Z' e e' d( e( d* d e) e d+  rZd, Z* n d' Z* e e* d( e+ d* d n  [ d S)-z&Python part of the warnings subsystem.    Nwarnwarn_explicitshowwarningformatwarningfilterwarningssimplefilterresetwarningscatch_warningsc             C   sd   | d k r( t  j } | d k r( d Sn  y# | j t |  | | | |   Wn t k
 r_ Yn Xd S)z7Hook to write a warning to a file; replace if you like.N)sysstderrwriter   OSError)messagecategoryfilenamelinenofileline r   8/home/kubikplay/www/django_dtb/lib/python3.4/warnings.pyr   
   s    	#c             C   sp   d d l  } d | | | j |  f } | d k rC | j | |  n | } | rl | j   } | d | 7} n  | S)z.Function to format a warning the standard way.r   Nz%s:%s: %s: %s
z  %s
)	linecache__name__getlinestrip)r   r   r   r   r   r   sr   r   r   r      s    $ Fc             C   s  d d l  } |  d k s+ t d	 |  f   t | t  sF t d
   t | t  sa t d   t | t  s| t d   t | t  s t d   t | t  r | d k s t d   |  | j | | j	  | | j |  | f } | rt
 j |  n t
 j d |  t   d S)a  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
    r   Nerrorignorealwaysdefaultmoduleoncezinvalid action: %rzmessage must be a stringzcategory must be a classz#category must be a Warning subclasszmodule must be a stringzlineno must be an int >= 0)zerrorzignorer   zdefaultzmoduler!   )reAssertionError
isinstancestrtype
issubclassWarningintcompileIfiltersappendinsert_filters_mutated)actionr   r   r    r   r-   r"   itemr   r   r   r       s    	c             C   s   |  d k s t  d |  f   t | t  r: | d k sF t  d	   |  d
 | d
 | f } | rq t j |  n t j d |  t   d
 S)a  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!   zinvalid action: %rr   zlineno must be an int >= 0N)zerrorzignorezalwayszdefaultzmodulezonce)r#   r$   r)   r,   r-   r.   r/   )r0   r   r   r-   r1   r   r   r   r   =   s    
	c               C   s   g  t  d d  <t   d S)zAClear the list of warning filters, so that no filters are active.N)r,   r/   r   r   r   r   r   R   s    c               @   s   e  Z d  Z d Z d S)_OptionErrorz,Exception used by option processing helpers.N)r   
__module____qualname____doc__r   r   r   r   r2   W   s   r2   c             C   sa   xZ |  D]R } y t  |  Wq t k
 rX } z t d | d t j WYd  d  } ~ Xq Xq Wd  S)NzInvalid -W option ignored:r   )
_setoptionr2   printr
   r   )argsargmsgr   r   r   _processoptions\   s
    r;   c             C   sP  d d  l  } |  j d  } t |  d k rC t d |  f   n  x# t |  d k  rh | j d  qF Wd d   | D \ } } } } } t |  } | j |  } t |  } | j |  } | r | d } n  | r0y% t |  } | d k  r t	  n  Wq6t	 t
 f k
 r,t d	 | f   Yq6Xn d } t | | | | |  d  S)
Nr   :   ztoo many fields (max 5): %rr   c             S   s   g  |  ] } | j     q Sr   )r   ).0r   r   r   r   
<listcomp>k   s   	z_setoption.<locals>.<listcomp>$zinvalid lineno %r)r"   splitlenr2   r-   
_getactionescape_getcategoryr)   
ValueErrorOverflowErrorr   )r9   r"   partsr0   r   r   r    r   r   r   r   r6   d   s.    	r6   c             C   sU   |  s
 d S|  d k r d Sx! d	 D] } | j  |   r! | Sq! Wt d |  f   d  S)
Nr   allr   r   r    r!   r   zinvalid action: %r)zdefaultzalwayszignorezmodulezoncezerror)
startswithr2   )r0   ar   r   r   rC      s     rC   c             C   s>  d d  l  } |  s t S| j d |   rc y t |   } Wqt k
 r_ t d |  f   YqXn |  j d  } |  d  |  } |  | d d   } y t | d  d  | g  } Wn% t k
 r t d | f   Yn Xy t	 | |  } Wn% t
 k
 rt d |  f   Yn Xt | t  s:t d |  f   n  | S)Nr   z^[a-zA-Z0-9_]+$zunknown warning category: %r.   zinvalid module name: %rzinvalid warning category: %r)r"   r(   matcheval	NameErrorr2   rfind
__import__ImportErrorgetattrAttributeErrorr'   )r   r"   catir    klassmr   r   r   rE      s,    rE   rM   c       
      C   so  t  |  t  r |  j } n  | d k r0 t } n  t | t  sE t  y t j |  } Wn! t k
 r{ t j	 } d } Yn X| j
 } | j } d | k r | d } n d } | j d  } | r | j   } | j d  r=| d d  } q=nJ | d k r.y t j d	 } Wq.t k
 r*d } Yq.Xn  | s=| } n  | j d
 i   }	 t |  | | | | |	 |  d S)z:Issue a warning, or maybe ignore it or raise an exception.NrM   r   z<string>__file__.pyc.pyo__main__r   Z__warningregistry__)r[   r\   )r$   r(   	__class__UserWarningr'   r#   r
   	_getframerF   __dict__	f_globalsf_linenogetlowerendswithargvrU   
setdefaultr   )
r   r   
stacklevelZcallerglobalsr   r    r   Zfnlregistryr   r   r   r      s<    					c             C   s  t  |  } | d  k rV | p! d } | d d   j   d k rV | d  d  } qV n  | d  k rk i  } n  | j d d  t k r | j   t | d <n  t |  t  r t |   } |  j } n |  } | |   }  | | | f } | j |  r d  Sx t	 D]| }	 |	 \ }
 } } } } | d  k s2| j
 |  r t | |  r | d  k s\| j
 |  r | d k st| | k r Pq q Wt }
 |
 d k rd | | <d  Sd d  l } | j | |  |
 d k r|   n  |
 d	 k rd | | <| | f } t j |  rd  Sd t | <n |
 d
 k rnt |
 d k rcd | | <| | d f } | j |  rVd  Sd | | <n/ |
 d k r|d | | <n t d |
 |	 f   t t  st d   n  t |  | | |  d  S)Nz	<unknown>   z.pyversionr   r   rM   r   r!   r   r    r   z1Unrecognized action (%r) in warnings.filters:
 %sz:warnings.showwarning() must be set to a function or methodro   )r)   rf   re   _filters_versionclearr$   r(   r%   r_   r,   rN   r'   defaultactionr   getlinesonceregistryRuntimeErrorcallabler   	TypeError)r   r   r   r   r    rl   module_globalstextkeyr1   r0   r:   rV   modZlnr   ZoncekeyZaltkeyr   r   r   r      sn    	

	

c               @   s:   e  Z d  Z d Z d Z d d d	 d
  Z d d   Z d S)WarningMessagez0Holds the result of a single showwarning() call.r   r   r   r   r   r   Nc       	      C   sM   t    } x% |  j D] } t |  | | |  q W| r@ | j n d  |  _ d  S)N)locals_WARNING_DETAILSsetattrr   _category_name)	selfr   r   r   r   r   r   Zlocal_valuesattrr   r   r   __init__  s    	zWarningMessage.__init__c             C   s&   d |  j  |  j |  j |  j |  j f S)NzD{message : %r, category : %r, filename : %r, lineno : %s, line : %r})r   r   r   r   r   )r   r   r   r   __str__#  s    zWarningMessage.__str__)zmessagezcategoryzfilenamezlinenozfilezline)r   r3   r4   r5   r~   r   r   r   r   r   r   r|     s    r|   c               @   sR   e  Z d  Z d Z d d d d d d  Z d d	   Z d
 d   Z d d   Z d S)r	   a  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.

    recordFr    Nc            C   s8   | |  _  | d k r" t j d n | |  _ d |  _ d S)zSpecify 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.

        NwarningsF)_recordr
   modules_module_entered)r   r   r    r   r   r   r   :  s    	"zcatch_warnings.__init__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)Nzrecord=Truer   z	module=%rz%s(%s)z, )r   r-   r   r
   r   r&   r   join)r   r8   namer   r   r   __repr__F  s    	zcatch_warnings.__repr__c                s   |  j  r t d |    n  d |  _  |  j j |  _ |  j d  d   |  j _ |  j j   |  j j |  _ |  j r g      f d d   } | |  j _   Sd  Sd  S)NzCannot enter %r twiceTc                 s     j  t |  |    d  S)N)r-   r|   )r8   kwargs)logr   r   r   Y  s    z-catch_warnings.__enter__.<locals>.showwarning)	r   ru   r   r,   _filtersr/   r   _showwarningr   )r   r   r   )r   r   	__enter__O  s    			zcatch_warnings.__enter__c             G   sK   |  j  s t d |    n  |  j |  j _ |  j j   |  j |  j _ d  S)Nz%Cannot exit %r without entering first)r   ru   r   r   r,   r/   r   r   )r   exc_infor   r   r   __exit__`  s
    	zcatch_warnings.__exit__)r   r3   r4   r5   r   r   r   r   r   r   r   r   r	   )  s
   	)r,   _defaultaction_onceregistryr   r   r/   Tr   c               C   s   t  d 7a  d  S)NrM   )rp   r   r   r   r   r/     s    r/   r   r   r   r-   gettotalrefcountr   ),r5   r
   __all__r   r   r(   r   r   r   	Exceptionr2   r;   r6   rC   rE   r   r   objectr|   r	   Z_warnings_defaults	_warningsr,   r   r   r/   rr   rt   rS   rp   warnoptionsImportWarningPendingDeprecationWarningZsilencer-   DeprecationWarningclsflagsbytes_warningZbytes_actionBytesWarninghasattrZresource_actionResourceWarningr   r   r   r   <module>   sb   		

)HG.
			