
    5f(                        d Z ddlZddlZddlZddlmZ ddlmZ  ej                  e	      Z
ej                  Z e       Z ej                  ddd      gZ ed	      Z ed
      Z ed      Z ed      Zi dddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4Zd5 Z G d6 d7e      Zd8 Zdd9e
fd:Zi Zd; Z G d< d=e      Zy)>z(
Helpers for comparing version strings.
    N)cfg)_fatal_deprecationsFz1Enables or disables fatal status of deprecations.)defaulthelpzg%(what)s is deprecated as of %(as_of)s in favor of %(in_favor_of)s and may be removed in %(remove_in)s.zf%(what)s is deprecated as of %(as_of)s and may be removed in %(remove_in)s. It will not be superseded.zC%(what)s is deprecated as of %(as_of)s in favor of %(in_favor_of)s.zB%(what)s is deprecated as of %(as_of)s. It will not be superseded.BBexarFFolsomGGrizzlyHHavanaIIcehouseJJunoKKiloLLibertyMMitakaNNewtonOOcataPPikeQQueensRRockySSteinTTrainUUssuriVictoriaWallabyXenaYogaZed)VWXYZc                  6    t         j                  t               y)zRegister configuration options used by this library.

    .. note: This is optional since the options are also registered
        automatically when the functions in this module are used.

    N)CONFregister_optsdeprecated_opts     7/usr/lib/python3/dist-packages/oslo_log/versionutils.pyregister_optionsr;   T   s     	'r9   c                   v    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZddZd Zy)
deprecateda  A decorator to mark callables as deprecated.

    This decorator logs a deprecation message when the callable it decorates is
    used. The message will include the release where the callable was
    deprecated, the release where it may be removed and possibly an optional
    replacement. It also logs a message when a deprecated exception is being
    caught in a try-except block, but not when subclasses of that exception
    are being caught.

    Examples:

    1. Specifying the required deprecated release

    >>> @deprecated(as_of=deprecated.ICEHOUSE)
    ... def a(): pass

    2. Specifying a replacement:

    >>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of='f()')
    ... def b(): pass

    3. Specifying the release where the functionality may be removed:

    >>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=+1)
    ... def c(): pass

    4. Specifying the deprecated functionality will not be removed:

    >>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=None)
    ... def d(): pass

    5. Specifying a replacement, deprecated functionality will not be removed:

    >>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of='f()',
    ...             remove_in=None)
    ... def e(): pass

    .. warning::

       The hook used to detect when a deprecated exception is being
       *caught* does not work under Python 3. Deprecated exceptions
       are still logged if they are thrown.

    r   r
   r   r   r   r   r   r   r   r   r   r   r    r"   r$   r&   r(   r/   r0   r1   r2   r3   Nc                 <    || _         || _        || _        || _        y)a  Initialize decorator

        :param as_of: the release deprecating the callable. Constants
            are define in this class for convenience.
        :param in_favor_of: the replacement for the callable (optional)
        :param remove_in: an integer specifying how many releases to wait
            before removing (default: 2)
        :param what: name of the thing being deprecated (default: the
            callable's name)

        N)as_ofin_favor_of	remove_inwhat)selfr?   r@   rA   rB   s        r:   __init__zdeprecated.__init__   s!     
&"	r9   c                 r   t        j                  t        | j                  xs j                  dz   | j
                  | j                  | j                        t        j                        r t        j                        fd       }|S t        j                        rj                  t        j                  d      fd       }|_        t        j                         t        t               r. G fddt"              _        t        j                         S t'        d	      )
Nz())rB   r?   r@   rA   c                  "              | i |S Nr8   )argskwargsfunc_or_clsreport_deprecateds     r:   wrappedz$deprecated.__call__.<locals>.wrapped   s    !#"D3F33r9   )__name____doc__)assignedc                 P    | j                   t        v r          | g|i | y rG   )	__class___DEPRECATED_EXCEPTIONS)rC   rH   rI   	orig_initrK   s      r:   new_initz%deprecated.__call__.<locals>.new_init   s(    >>%;;%'$000r9   c                   $     e Zd Z fdZ xZS )*deprecated.__call__.<locals>.ExceptionMetac                 @    | t         v r         t        |   |      S rG   )rR   super__subclasscheck__)rC   subclassExceptionMetarQ   rK   s     r:   rY   z<deprecated.__call__.<locals>.ExceptionMeta.__subclasscheck__   s+    #99-/$]%) ==E+FGr9   )rM   
__module____qualname__rY   __classcell__)rQ   r[   rK   s   @r:   r[   rV      s    G Gr9   r[   z5deprecated can be used only with functions or classes)	functoolspartialdeprecation_warningrB   rM   r?   r@   rA   inspect
isfunctionwrapsisclassrD   rR   add
issubclass	Exceptiontype__meta__	TypeError)rC   rJ   rL   rT   r[   rS   rK   s    `  @@@r:   __call__zdeprecated.__call__   s   %--9k22T9**((nn& k*__[)4 *4 N__[)#,,I__Y1HI1 J1 $,K "&&{3+y1GD G (5$&**;7 & ' 'r9   )N   N)rM   r\   r]   rN   BEXARFOLSOMGRIZZLYHAVANAICEHOUSEJUNOKILOLIBERTYMITAKANEWTONOCATAPIKEQUEENSROCKYSTEINTRAINUSSURIVICTORIAWALLABYXENAYOGAZEDrD   rl   r8   r9   r:   r=   r=   ^   s    +^ EFGFHDDGFFEDFEEEFHGDD
C"1'r9   r=   c                 ^    |d}t        t        |       |z         }|t        v r	t        |   S |S )Nr   )chrord	_RELEASES)releaserA   new_releases      r:   _get_safe_to_remove_releaser      s;     	c'lY./Ki%%r9   rm   c                     t        | t        |   t        ||            }|r||d<   ||dkD  rt        }nt        }n||dkD  rt
        }nt        }t        |||       y)a  Warn about the deprecation of a feature.

    :param what: name of the thing being deprecated.
    :param as_of: the release deprecating the callable.
    :param in_favor_of: the replacement for the callable (optional)
    :param remove_in: an integer specifying how many releases to wait
        before removing (default: 2)
    :param logger: the logging object to use for reporting (optional).
    )rB   r?   rA   r@   Nr   )dictr   r    _deprecated_msg_with_alternative+_deprecated_msg_with_alternative_no_removal_deprecated_msg_no_alternative._deprecated_msg_with_no_alternative_no_removalreport_deprecated_feature)rB   r?   r@   rA   loggerdetailsmsgs          r:   ra   ra      so     "5)8	JLG !, Y]2C >C Y]0C ACfc73r9   c                 ,   t        d      |z  }t                t        j                  r" | j                  |g|i | t        |      t        j                  |t                     }||v ry|j                  |        | j                  |g|i | y)a  Call this function when a deprecated feature is used.

    If the system is configured for fatal deprecations then the message
    is logged at the 'critical' level and :class:`DeprecatedConfig` will
    be raised.

    Otherwise, the message will be logged (once) at the 'warn' level.

    :raises: :class:`DeprecatedConfig` if the system is configured for
             fatal deprecations.
    zDeprecated: %sr   N)r   r;   r5   r   criticalDeprecatedConfig_deprecated_messages_sent
setdefaultlistappendwarning)r   r   rH   rI   stdmsg	sent_argss         r:   r   r     s      3&F0006** *44S$&AIyTFNN6+D+F+r9   c                   .     e Zd Z ed      Z fdZ xZS )r   z(Fatal call to deprecated config: %(msg)sc                 Z    t         t        |   | j                  t	        |      z         y )Nr   )rX   rh   rD   messager   )rC   r   rQ   s     r:   rD   zDeprecatedConfig.__init__>  s    i't}(DEr9   )rM   r\   r]   r   r   rD   r^   )rQ   s   @r:   r   r   ;  s    :;GF Fr9   r   )rN   r_   rb   loggingoslo_configr   oslo_log._i18nr   	getLoggerrM   LOGr5   setrR   BoolOptr7   r   r   r   r   r   r;   objectr=   r   ra   r   r   rh   r   r8   r9   r:   <module>r      s         g!
xx  CKK$HJ $%;$<   "#;"<  /0I/K + 23H2J .  	
             !" #$ %& '( 
				1	8(I' I'X
 26"#C4H  ,:Fy Fr9   