0x1949 Team - FAZEMRX - MANAGER
Edit File: deprecate.cpython-310.pyc
o �bl � @ s� d Z g d�ZddlZddlZddlmZ ddlmZ ddlm Z ddl mZmZm Z mZmZmZ ddlmamZ dd lmZmZ d Zdd� Zd e_de_de_dd� Zd<dd�Zd=dd�Zd=dd�Zdd� Z d<dd�Z!d<dd�Z"dd� Z#dd � Z$G d!d"� d"�Z%G d#d$� d$�Z&G d%d&� d&�Z'd'd(� Z(d)d*� Z)d+d,� Z*d-d.� Z+d/d0� Z,d1d2� Z-ed3ed4ef d5�Z. d<d6ed7e/d8ee/ d9ee.ge.f fd:d;�Z0dS )>aa 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", 8, 0, 0)) def badAPI(self, first, second): ''' Docstring for badAPI. ''' ... @deprecated(Version("Twisted", 16, 0, 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', 16, 0, 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", 8, 0, 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", 19, 2, 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. )� deprecated�deprecatedProperty�getDeprecationWarningString�getWarningMethod�setWarningMethod�deprecatedModuleAttribute�deprecatedKeywordParameter� N)�findlinestarts��wraps)� ModuleType)�Any�Callable�Dict�Optional�TypeVar�cast)�warn� warn_explicit)�Version�getVersionStringz&%(fqpn)s was deprecated in %(version)sc C sl z| j }W n ty | j}Y nw t�| �st�| �r&| j}|� d|� �S t�| �r4| j� d| j � �S |S )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� moduleName� r# �:/usr/lib/python3/dist-packages/twisted/python/deprecate.py�_fullyQualifiedNameo s � r% ztwisted.python.reflect�fullyQualifiedNamec C s 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% ��replacementr# r# r$ �_getReplacementString� s r* c C s, dt | �� �}|r|� dt|�� �}|d 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 r* )�versionr) �docr# r# r$ �_getDeprecationDocstring� s r. c C s6 |du rt }|| t|�d� }|rd�|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} N)�fqpnr, z{}; {})�DEPRECATION_WARNING_FORMATr �formatr* )r/ r, r1 r) � warningStringr# r# r$ �_getDeprecationWarningString� s �r3 c C s t t| �|||�S )ak Return a string indicating that the callable was deprecated in the given version. @type callableThing: C{callable} @param callableThing: Callable object to be deprecated @type version: L{incremental.Version} @param version: Version that C{callableThing} was deprecated in. @type format: C{str} @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 @param replacement: what should be used in place of the callable. 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 string describing the deprecation. @rtype: C{str} )r3 r% )� callableThingr, r1 r) r# r# r$ r � s �r c C sx | j r | j �� }ng }t|�dkr|�|� nt|�dkr&|�d|dg� n|�� }|�d|| |g� d�|�| _ dS )av Append the given text to the docstring of C{thingWithDoc}. If C{thingWithDoc} has no docstring, then the text just replaces the docstring. If it has a single-line docstring then it appends a blank line and the message text. If it has a multi-line docstring, then in appends a blank line a the message text, and also does the indentation correctly. r � � � N)�__doc__� splitlines�len�append�extend�pop�join)�thingWithDoc�textToAppend�docstringLines�spacesr# r# r$ �_appendToDocstring� s rC c s � �fdd�}|S )a� Return a decorator that marks callables as deprecated. To deprecate a property, see L{deprecatedProperty}. @type version: L{incremental.Version} @param version: The version in which the callable will be marked as having been deprecated. The decorated function will be annotated with this version, having it set as its C{deprecatedVersion} attribute. @param replacement: what should be used in place of the callable. 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 c s>