ó
[¿Mc           @   sk   d  Z  d d l Z d d l Z d d l Z d d l Z g  Z d e f d „  ƒ  YZ e d „ Z	 d „  Z
 d S(   s¯   Classes and functions for deprecating features.

This is used for internal purposes only and not part of the official API. Do
not use it for anything outside the apt package.
iÿÿÿÿNt   AttributeDeprecatedByc           B   s,   e  Z d  Z d „  Z d d „ Z d „  Z RS(   s  Property acting as a proxy for a new attribute.

    When accessed, the property issues a DeprecationWarning and (on get) calls
    attrgetter() for the attribute 'attribute' on the current object or (on
    set) uses setattr to set the value of the wrapped attribute.
    c         C   s,   | |  _  d | |  _ t j | ƒ |  _ d S(   s   Initialize the property.s#   Deprecated, please use '%s' insteadN(   t	   attributet   __doc__t   operatort
   attrgettert   getter(   t   selfR   (    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   __init__*   s    	c         C   sK   | d k r t | |  j |  ƒ St j |  j t d d ƒ|  j | pG | ƒ S(   s;   Issue a  DeprecationWarning and return the requested value.t
   stackleveli   N(   t   Nonet   getattrR   t   warningst   warnR   t   DeprecationWarningR   (   R   t   objt   type_(    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   __get__0   s    c         C   s0   t  j |  j t d d ƒt | |  j | ƒ d S(   s8   Issue a  DeprecationWarning and set the requested value.R   i   N(   R   R   R   R   t   setattrR   (   R   R   t   value(    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   __set__7   s    N(   t   __name__t
   __module__R   R   R	   R   R   (    (    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyR    "   s   	c            s&   d ˆ j  ‰  ‡ ‡  ‡ f d †  } | S(   sd  Return a function that warns it is deprecated by another function.

    Returns a new function that warns it is deprecated by function 'func',
    then acts as a pass-through wrapper for 'func'.

    This function also converts all keyword argument names from mixedCase to
    lowercase_with_underscores, but only if 'convert_names' is True (default).
    s%   Deprecated, please use '%s()' insteadc             sk   t  j ˆ t d d ƒˆ  r^ x? | j ƒ  D]. } | j | ƒ | t j d d | ƒ j ƒ  <q) Wn  ˆ |  | Ž  S(   s%   Wrapper around a deprecated function.R   i   s   ([A-Z])s   _\1(   R   R   R   t   keyst   popt   ret   subt   lower(   t   argst   kwdst   key(   t   convert_namest   warningt   func(    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   deprecated_functionH   s
    /(   R   (   R    R   R!   (    (   R   R   R    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   function_deprecated_by=   s    	c            sW   t  j s ˆ  S‡  f d †  } ˆ  j | _ ˆ  j | _ ˆ  j | _ | j j ˆ  j ƒ | S(   s™   A function with deprecated arguments.

    Similar to function_deprecated_by() but warns on every deprecated argument
    instead of function calls.
    c             sr   xb | j  ƒ  D]T } t j d d | ƒ j ƒ  } | | k r t j d | ƒ | j | ƒ | | <q q Wˆ  |  | Ž  S(   s4   Wrapper around a function with deprecated arguments.s   ([A-Z])s   _\1s   Deprecated parameter %r(   R   R   R   R   R   R   R   (   R   R   R   t   new_key(   R    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyR!   [   s    (   t   apt_pkgt   _COMPAT_0_7R   R   R   t   __dict__t   update(   R    R!   (    (   R    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   deprecated_argsR   s    	(   R   R   R   R   R$   t   __all__t   objectR    t   TrueR"   R(   (    (    (    s3   /usr/lib/python2.7/dist-packages/apt/deprecation.pyt   <module>   s   