%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/deprecate.cpython-312.pyc |
� Ϫ�f�m � �� � d Z ddlmZ g d�ZddlZddlZddlmZ ddlm Z ddl mZ ddlm Z mZmZmZmZmZ dd lmamZ dd lmZmZ ddlmZ ed� Z ed � ZdZd� Zde_ de_ de_ d� Z!d+d�Z"d,d�Z#d,d�Z$d� Z% d+ d-d�Z&d+d�Z'd� Z(d� Z) G d� d� Z* G d� d� Z+ G d� d � Z,d!� Z-d"� Z.d#� Z/d$� Z0d%� Z1d&� Z2 ed'ed(e f �)� Z3 d+ d.d*�Z4y)/ah Deprecation framework for Twisted. To mark a method, function, or class as being deprecated do this:: from incremental import Version from twisted.python.deprecate import deprecated @deprecated(Version("Twisted", 22, 10, 0)) def badAPI(self, first, second): ''' Docstring for badAPI. ''' ... @deprecated(Version("Twisted", 22, 10, 0)) class BadClass: ''' Docstring for BadClass. ''' The newly-decorated badAPI will issue a warning when called, and BadClass will issue a warning when instantiated. Both will also have a deprecation notice appended to their docstring. To deprecate properties you can use:: from incremental import Version from twisted.python.deprecate import deprecatedProperty class OtherwiseUndeprecatedClass: @deprecatedProperty(Version("Twisted", 22, 10, 0)) def badProperty(self): ''' Docstring for badProperty. ''' @badProperty.setter def badProperty(self, value): ''' Setter sill also raise the deprecation warning. ''' To mark module-level attributes as being deprecated you can use:: badAttribute = "someValue" ... deprecatedModuleAttribute( Version("Twisted", 22, 10, 0), "Use goodAttribute instead.", "your.full.module.name", "badAttribute") The deprecated attributes will issue a warning whenever they are accessed. If the attributes being deprecated are in the same module as the L{deprecatedModuleAttribute} call is being made from, the C{__name__} global can be used as the C{moduleName} parameter. To mark an optional, keyword parameter of a function or method as deprecated without deprecating the function itself, you can use:: @deprecatedKeywordParameter(Version("Twisted", 22, 10, 0), "baz") def someFunction(foo, bar=0, baz=None): ... See also L{incremental.Version}. @type DEPRECATION_WARNING_FORMAT: C{str} @var DEPRECATION_WARNING_FORMAT: The default deprecation warning string format to use when one is not provided by the user. � )�annotations)� deprecated�deprecatedProperty�getDeprecationWarningString�getWarningMethod�setWarningMethod�deprecatedModuleAttribute�deprecatedKeywordParameterN)�findlinestarts��wraps)� ModuleType)�Any�Callable�Dict�Optional�TypeVar�cast)�warn� warn_explicit)�Version�getVersionString)� ParamSpec�_P�_Rz&%(fqpn)s was deprecated in %(version)sc �0 � | j }t j | � st j | � r| j }|� d|� �S t j | � r| j � d| j � �S |S # t $ r | j }Y ��w xY w)z� Return the fully qualified name of a module, class, method or function. Classes and functions need to be module level ones to be correctly qualified. @rtype: C{str}. �.)�__qualname__�AttributeError�__name__�inspect�isclass� isfunction� __module__�ismethod)�obj�name� moduleNames �:/usr/lib/python3/dist-packages/twisted/python/deprecate.py�_fullyQualifiedNamer* s s� � ������ ���s��w�1�1�#�6��^�^� ���Q�t�f�%�%� � � �#� ��.�.�!��3�#3�#3�"4�5�5��K�� � ��|�|���s �A= �=B�Bztwisted.python.reflect�fullyQualifiedNamec �: � t | � rt | � } d| � d�S )a Surround a replacement for a deprecated API with some polite text exhorting the user to consider it as an alternative. @type replacement: C{str} or callable @return: a string like "please use twisted.python.modules.getModule instead". zplease use z instead)�callabler* ��replacements r) �_getReplacementStringr0 � s% � � ���)�+�6�� �� �X�.�.� c �L � dt | � � �}|r|� dt |� � �}|dz S )a� Generate an addition to a deprecated object's docstring that explains its deprecation. @param version: the version it was deprecated. @type version: L{incremental.Version} @param replacement: The replacement, if specified. @type replacement: C{str} or callable @return: a string like "Deprecated in Twisted 27.2.0; please use twisted.timestream.tachyon.flux instead." zDeprecated in �; r )r r0 )�versionr/ �docs r) �_getDeprecationDocstringr6 � s; � � �+�G�4�5� 6�C����R�-�k�:�;�<����9�r1 c �r � |�t }|| t |� d�z }|rdj |t |� � }|S )ag Return a string indicating that the Python name was deprecated in the given version. @param fqpn: Fully qualified Python name of the thing being deprecated @type fqpn: C{str} @param version: Version that C{fqpn} was deprecated in. @type version: L{incremental.Version} @param format: A user-provided format to interpolate warning values into, or L{DEPRECATION_WARNING_FORMAT <twisted.python.deprecate.DEPRECATION_WARNING_FORMAT>} if L{None} is given. @type format: C{str} @param replacement: what should be used in place of C{fqpn}. Either pass in a string, which will be inserted into the warning message, or a callable, which will be expanded to its full import path. @type replacement: C{str} or callable @return: A textual description of the deprecation @rtype: C{str} )�fqpnr4 z{}; {})�DEPRECATION_WARNING_FORMATr �formatr0 )r8 r4 r: r/ � warningStrings r) �_getDeprecationWarningStringr<