ó
H`¾Tc           @   s«   d  Z  d d l m Z d d l Z d d l Z d d l m Z d d „ Z d d	 „ Z d e
 d
 „ Z d e
 d „ Z d „  Z d d „ Z d d l Z d „  Z d „  Z d S(   sS   Helpers related to deprecation of functions, methods, classes, other
functionality.i   (   t   exciÿÿÿÿNi   (   t	   decoratori   c         C   s   t  j |  t j d | ƒd  S(   Nt
   stacklevel(   t   warningst   warnR    t   SADeprecationWarning(   t   msgR   (    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   warn_deprecated   s    c         C   s   t  j |  t j d | ƒd  S(   NR   (   R   R   R    t   SAPendingDeprecationWarning(   R   R   (    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   warn_pending_deprecation   s    c            sP   | r d |  ˆ p d f ‰  n d ‰  ˆ d k r: d ‰ n  ‡  ‡ f d †  } | S(   s¨  Decorates a function and issues a deprecation warning on use.

    :param message:
      If provided, issue message in the warning.  A sensible default
      is used if not provided.

    :param add_deprecation_to_docstring:
      Default True.  If False, the wrapped function's __doc__ is left
      as-is.  If True, the 'message' is prepended to the docs if
      provided, or sensible default if message is omitted.

    s   .. deprecated:: %s %st    s$   Call to deprecated function %(func)sc            s&   t  |  t j ˆ t d |  j ƒ ˆ  ƒ S(   Nt   func(   t   _decorate_with_warningR    R   t   dictt   __name__(   t   fn(   t   headert   message(    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   decorate0   s    	N(   t   None(   t   versionR   t   add_deprecation_to_docstringR   (    (   R   R   sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt
   deprecated   s    	c            sP   | r d |  ˆ p d f ‰  n d ‰  ˆ d k r: d ‰ n  ‡  ‡ f d †  } | S(   sE  Decorates a function and issues a pending deprecation warning on use.

    :param version:
      An approximate future version at which point the pending deprecation
      will become deprecated.  Not used in messaging.

    :param message:
      If provided, issue message in the warning.  A sensible default
      is used if not provided.

    :param add_deprecation_to_docstring:
      Default True.  If False, the wrapped function's __doc__ is left
      as-is.  If True, the 'message' is prepended to the docs if
      provided, or sensible default if message is omitted.
    s   .. deprecated:: %s (pending) %sR
   s$   Call to deprecated function %(func)sc            s&   t  |  t j ˆ t d |  j ƒ ˆ  ƒ S(   NR   (   R   R    R   R   R   (   R   (   R   R   (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyR   R   s    	N(   R   (   R   R   R   R   (    (   R   R   sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   pending_deprecation7   s    	c         C   s   d „  } t  j d | |  ƒ S(   Nc         S   s5   |  j  d d ƒ \ } } | d k r1 | d 7} n  | S(   Ni   i   R   t   meths   ()(   s   funcR   (   t   group(   t   mt   type_t   name(    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   replZ   s    s   \:(\w+)\:`~?\.?(.+?)`(   t   ret   sub(   t   textR   (    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   _sanitize_restructured_textY   s    	c            s’   t  ˆ ƒ ‰ t ‡  ‡ f d †  ƒ } |  j d k	 r< |  j p? d } | d k	 ry | t d |  j ƒ ;} t | | d ƒ } n  | |  ƒ } | | _ | S(   s=   Wrap a function with a warnings.warn and augmented docstring.c            s&   t  j ˆ  ˆ ƒ d d ƒ|  | | Ž  S(   NR   i   (   R   R   (   R   t   argst   kwargs(   t   wtypeR   (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   warnedg   s    R
   R   i   N(   R!   R   t   __doc__R   R   R   t   inject_docstring_text(   R   R$   R   t   docstring_headerR%   t   doct	   decorated(    (   R$   R   sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyR   b   s    	c         C   si   |  j  d d ƒ } t | ƒ d k r( |  S| \ } } | j d ƒ sX | d t j | ƒ St j |  ƒ Sd  S(   Ns   
i   t    (   t   splitt   lent
   startswitht   textwrapt   dedent(   R    t
   split_textt	   firstlinet	   remaining(    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   _dedent_docstringy   s    c   	      C   sÚ   t  |  p d ƒ }  |  j d ƒ } t j | ƒ j d ƒ } | d rV | j d d ƒ n  g  t | ƒ D] \ } } | j ƒ  sc | ^ qc } | j d d ƒ | t | t | ƒ d ƒ } | d | !| | | } d j	 | ƒ S(   NR
   s   
i    i   (
   R4   R,   R/   R0   t   insertt	   enumeratet   stript   minR-   t   join(	   t   doctextt
   injecttextt   post   linest   injectlinest   numt   linet   blankst
   inject_pos(    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyR'   …   s    
1(   R&   R
   R    R   R   t   langhelpersR   R   R	   R   t   TrueR   R   R!   R   R/   R4   R'   (    (    (    sb   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/sqlalchemy/util/deprecations.pyt   <module>	   s   !			