B 4]@sdZddlZddlZddlmZddlmZddlmZddlmZdd lm Z d!d d Z d"d dZ d#ddZ d$ddZ ddZd%ddZddZddZd&ddZd'dd ZdS)(zSHelpers related to deprecation of functions, methods, classes, other functionality.N)compat) decorator)inject_docstring_text)inject_param_text)exccCstj|tj|ddS)N) stacklevel)warningswarnrSADeprecationWarning)msgr rO/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/util/deprecations.pywarn_deprecatedsrcCstj|tj|ddS)N)r )r r rSAPendingDeprecationWarning)rr rrrwarn_pending_deprecationsr__init__cs$d|p dffdd}|S)Nz.. deprecated:: %s %scst|tjtdS)N)func)_decorate_cls_with_warningrr dict)cls) constructorheadermessagerrdecorate s  z deprecated_cls..decorater)versionrrrr)rrrrdeprecated_clss rTcs8|rd|pdfnddkr&dfdd}|S)aDecorates a function and issues a deprecation warning on use. :param version: Issue version in the warning. :param message: If provided, issue message in the warning. A sensible default is used if not provided. :param add_deprecation_to_docstring: Default True. If False, the wrapped function's __doc__ is left as-is. If True, the 'message' is prepended to the docs if provided, or sensible default if message is omitted. z.. deprecated:: %s %srNz$Call to deprecated function %(func)scst|tjt|jdS)N)r)_decorate_with_warningrr r__name__)fn)rrrrrEs zdeprecated..decorater)rradd_deprecation_to_docstringrr)rrr deprecated,sr$c s<ix$D]\}\}}t||<qWfdd}|S)a"Decorates a function to warn on use of certain parameters. e.g. :: @deprecated_params( weak_identity_map=( "0.7", "the :paramref:`.Session.weak_identity_map parameter " "is deprecated." ) ) cst|}|jdk r\tt|jt|jt|jd|jtt n dtt fdd}|j dk r|j pd}|rt |dd D}||}||_ |S)Nrcsjx2D]*}|||krtj|tjddqWx*D]"}||kr:tj|tjddq:W|||S)Nr )r )r r rr )r"argskwargsm)check_defaultscheck_kwdefaultsmessagesrrwarnedss  z3deprecated_params..decorate..warnedrcSs&i|]\}\}}d||pdf|qS)z.. deprecated:: %s %srr).0paramrrrrr sz7deprecated_params..decorate..)rZinspect_getfullargspecr*rzipr%lenset intersection differencer__doc__ritems)r"specr,doc decorated)r+specs)r(r)r*rrds(   z#deprecated_params..decorate)r6_sanitize_restructured_text)r:r.rrrr)r+r:rdeprecated_paramsPs +r<cs8|rd|pdfnddkr&dfdd}|S)aEDecorates a function and issues a pending deprecation warning on use. :param version: An approximate future version at which point the pending deprecation will become deprecated. Not used in messaging. :param message: If provided, issue message in the warning. A sensible default is used if not provided. :param add_deprecation_to_docstring: Default True. If False, the wrapped function's __doc__ is left as-is. If True, the 'message' is prepended to the docs if provided, or sensible default if message is omitted. z.. deprecated:: %s (pending) %srNz$Call to deprecated function %(func)scst|tjt|jdS)N)r)r rrrr!)r")rrrrrs z%pending_deprecation..decorater)rrr#rr)rrrpending_deprecationsr=cCs|dkr |St||SdS)N)r)Zparameter_valueZ default_valueZ warning_textrrrdeprecated_option_valuesr>cCsdd}td||S)NcSs$|dd\}}|dkr |d7}|S)Nrr)rZmethz())group)r'Ztype_namerrrreplsz)_sanitize_restructured_text..replz\:(\w+)\:`~?\.?(.+?)`)resub)textrArrrr;sr;cCs|jdk r|jpd}|dk r~|t|d;}t||d}t|tkrnt|j}||d<t|j|j|}||}n||_t||}t||t |||d|S)Nr)rrr5) r5rrtype__dict__r! __bases__getattrsetattrr )rrwtyperdocstring_headerr8ZclsdictZconstructor_fnrrrrs      rcstttfdd}|jdk r*|jp,d}|dk rR|t|jd;}t||d}||}||_fdd|_|S) z=Wrap a function with a warnings.warn and augmented docstring.cstjdd|||S)Nr )r )r r )r"r%r&)rrJrrr,sz&_decorate_with_warning..warnedNr)rrcstjddS)Nr )r )r r r)rrJrrz(_decorate_with_warning..)r;rr5rr!rZ_sa_warn)rrJrrKr,r8r9r)rrJrr s r )r )r )r)NT)NT)N)N)r5rBr rrZ langhelpersrrrrrrrr$r<r=r>r;rr rrrr s"         $C %