� M�gq)����dZddlZddlZddlZddlZddlZ ddlZdZdZn%#e $rdZej ��dkrdZndZYnwxYwe d��e d��fZ Gd�d ej ��Zd �ZdS) z� Classic deprecation warning =========================== Classic ``@deprecated`` decorator to deprecate old python classes, functions or methods. .. _The Warnings Filter: https://docs.python.org/3/library/warnings.html#the-warnings-filter �N���PyPy��c�:��eZdZdZdddedf�fd� Zd�Zd�Z�xZS)�ClassicAdaptera8 Classic adapter -- *for advanced usage only* This adapter is used to get the deprecation message according to the wrapped object type: class, function, standard method, static method, or class method. This is the base class of the :class:`~deprecated.sphinx.SphinxAdapter` class which is used to update the wrapped object docstring. You can also inherit this class to change the deprecation message. In the following example, we change the message into "The ... is deprecated.": .. code-block:: python import inspect from deprecated.classic import ClassicAdapter from deprecated.classic import deprecated class MyClassicAdapter(ClassicAdapter): def get_deprecated_msg(self, wrapped, instance): if instance is None: if inspect.isclass(wrapped): fmt = "The class {name} is deprecated." else: fmt = "The function {name} is deprecated." else: if inspect.isclass(instance): fmt = "The class method {name} is deprecated." else: fmt = "The method {name} is deprecated." if self.reason: fmt += " ({reason})" if self.version: fmt += " -- Deprecated since version {version}." return fmt.format(name=wrapped.__name__, reason=self.reason or "", version=self.version or "") Then, you can use your ``MyClassicAdapter`` class like this in your source code: .. code-block:: python @deprecated(reason="use another function", adapter_cls=MyClassicAdapter) def some_old_function(x, y): return x + y rNrc���|pd|_|pd|_||_||_||_t t |�����dS)a Construct a wrapper adapter. :type reason: str :param reason: Reason message which documents the deprecation in your library (can be omitted). :type version: str :param version: Version of your project which deprecates this feature. If you follow the `Semantic Versioning <https://semver.org/>`_, the version number has the format "MAJOR.MINOR.PATCH". :type action: Literal["default", "error", "ignore", "always", "module", "once"] :param action: A warning filter used to activate or not the deprecation warning. Can be one of "error", "ignore", "always", "default", "module", or "once". If ``None`` or empty, the global filtering mechanism is used. See: `The Warnings Filter`_ in the Python documentation. :type category: Type[Warning] :param category: The warning category to use for the deprecation warning. By default, the category class is :class:`~DeprecationWarning`, you can inherit this class to define your own deprecation warning category. :type extra_stacklevel: int :param extra_stacklevel: Number of additional stack levels to consider instrumentation rather than user code. With the default value of 0, the warning refers to where the class was instantiated or the function was called. .. versionchanged:: 1.2.15 Add the *extra_stacklevel* parameter. rN)�reason�version�action�category�extra_stacklevel�superr �__init__)�selfr r r rr� __class__s ��b/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/deprecated/classic.pyrzClassicAdapter.__init__VsT���H�l��� ��}�"�� ��� � �� � 0��� �n�d�#�#�,�,�.�.�.�.�.rc���|�tj|��rd}nd}ntj|��rd}nd}|jr|dz }|jr|dz }|�|j|jpd|jpd� ��S) z� Get the deprecation warning message for the user. :param wrapped: Wrapped class or function. :param instance: The object to which the wrapped function was bound when it was called. :return: The warning message. Nz Call to deprecated class {name}.z5Call to deprecated function (or staticmethod) {name}.z'Call to deprecated class method {name}.z!Call to deprecated method {name}.z ({reason})z' -- Deprecated since version {version}.r)�namer r )�inspect�isclassr r �format�__name__)r�wrapped�instance�fmts r�get_deprecated_msgz!ClassicAdapter.get_deprecated_msg�s��� � ���w�'�'� N�8���M�����x�(�(� :�?���9�� �;� !� �=� �C� �<� =� �<� <�C��z�z�w�/�� �8I�r�SW�S_�Se�ce�z�f�f�frc�8����tj���r#�j����fd�}t|���_n_tj���r"t j�fd���}|���Sttt���������S)a� Decorate your class or function. :param wrapped: Wrapped class or function. :return: the decorated class or function. .. versionchanged:: 1.2.4 Don't pass arguments to :meth:`object.__new__` (other than *cls*). .. versionchanged:: 1.2.8 The warning filter is not set if the *action* parameter is ``None`` or empty. c������d��}t�jz}�jrgt j��5t j�j�j��t j|�j|���ddd��n #1swxYwYnt j|�j|����tj ur �|��S�|g|�Ri|��S�N)r� stacklevel) r�_class_stacklevelrr �warnings�catch_warnings� simplefilterr�warn�object�__new__)�cls�args�kwargs�msgr"�old_new1rrs ���r� wrapped_clsz,ClassicAdapter.__call__.<locals>.wrapped_cls�s,����-�-�g�t�<�<��.��1F�F� ��;�V�!�0�2�2�Z�Z� �-�d�k�4�=�I�I�I� � �c�D�M�j�Y�Y�Y�Y�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z����Z�Z�Z�Z���M�#�� �*�U�U�U�U��v�~�-�-�#�8�C�=�=�(��x��5�d�5�5�5�f�5�5�5��<B � B �B c�r����||��}t�jz}�jrgt j��5t j�j�j��t j|�j|���ddd��n #1swxYwYnt j|�j|���||i|��Sr!) r�_routine_stacklevelrr r$r%r&rr')�wrapped_� instance_�args_�kwargs_r-r"rs �r�wrapper_functionz1ClassicAdapter.__call__.<locals>.wrapper_function�s����-�-�h� �B�B��0�4�3H�H� ��;�V�!�0�2�2�Z�Z� �-�d�k�4�=�I�I�I� � �c�D�M�j�Y�Y�Y�Y�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z�Z����Z�Z�Z�Z���M�#�� �*�U�U�U�U��x��2�'�2�2�2r0) rrr)� staticmethod� isroutine�wrapt� decorator� TypeError�repr�type)rrr/r7r.s`` @r�__call__zClassicAdapter.__call__�s������ �?�7� #� #�# 1���H� 6� 6� 6� 6� 6� 6� 6�+�;�7�7�G�O�O� � �w� '� '� 1� �_� 3� 3� 3� 3��_� 3�$�#�G�,�,� ,��D��g���/�/�0�0� 0��r) r� __module__� __qualname__�__doc__�DeprecationWarningrrr?� __classcell__)rs@rr r #sy�������0�0�d!�"�T�DV�ij�)/�)/�)/�)/�)/�)/�Vg�g�g�43�3�3�3�3�3�3rr c��|r0t|dt��r|d|d<|dd�}|rDt|d��s/tt t |d�������|r6|�dt��}|di|��}|d}||��Stj tfi|��S)a� This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used. **Classic usage:** To use this, decorate your deprecated function with **@deprecated** decorator: .. code-block:: python from deprecated import deprecated @deprecated def some_old_function(x, y): return x + y You can also decorate a class or a method: .. code-block:: python from deprecated import deprecated class SomeClass(object): @deprecated def some_old_method(self, x, y): return x + y @deprecated class SomeOldClass(object): pass You can give a *reason* message to help the developer to choose another function/class, and a *version* number to specify the starting version number of the deprecation. .. code-block:: python from deprecated import deprecated @deprecated(reason="use another function", version='1.2.0') def some_old_function(x, y): return x + y The *category* keyword argument allow you to specify the deprecation warning class of your choice. By default, :exc:`DeprecationWarning` is used, but you can choose :exc:`FutureWarning`, :exc:`PendingDeprecationWarning` or a custom subclass. .. code-block:: python from deprecated import deprecated @deprecated(category=PendingDeprecationWarning) def some_old_function(x, y): return x + y The *action* keyword argument allow you to locally change the warning filtering. *action* can be one of "error", "ignore", "always", "default", "module", or "once". If ``None``, empty or missing, the global filtering mechanism is used. See: `The Warnings Filter`_ in the Python documentation. .. code-block:: python from deprecated import deprecated @deprecated(action="error") def some_old_function(x, y): return x + y The *extra_stacklevel* keyword argument allows you to specify additional stack levels to consider instrumentation rather than user code. With the default value of 0, the warning refers to where the class was instantiated or the function was called. rr �N� adapter_cls�) � isinstance� string_types�callabler<r=r>�popr � functools�partial� deprecated)r+r,rG�adapterrs rrOrO�s���^ �� �4��7�L�1�1����7��x���A�B�B�x�� �-�H�T�!�W�%�%�-���T�$�q�'�]�]�+�+�,�,�,� � ��j�j���?�?� ��+�'�'��'�'���q�'���w�w���� � �Z� 2� 2�6� 2� 2�2r)rBrMr�platformr$r:�wrapt._wrappersr2r#� ImportError�python_implementationr>rJ�AdapterFactoryr rOrHrr�<module>rVs�������������������� � � � � �����������������%�x�%�'�'�6�1�1�������� ������S� � �4�4��9�9�%� �k�k�k�k�k�U�)�k�k�k�\\3�\3�\3�\3�\3s�!�A�A
Memory