Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
181 views
unlisted
ubuntu2004
o

��c�@sPdZddlmZddlZddlmZdd�Zddd	�ZGd
d�d�Zdd
�Z	dS)z}
Convenience tools for handling deprecations.

Most of the code is taken from the SageMath source code in misc/superseded.py
�)�warnN)�lazy_attributecCs
d�|�S)Nz=https://gitlab.com/modulispaces/admcycles/-/merge_requests/{})�format)�num�r�8/home/user/Introduction lectures/admcycles/superseded.py�merge_request_urls
r�cCs*|d7}|d�t|��7}t|t|�dS)N�
zSee {} for details.)rrr�DeprecationWarning)�
merge_request�message�
stacklevelrrr�deprecationsrc@s8eZdZdZddd�Zedd��Zdd�Zdd	d
�ZdS)
�DeprecatedFunctionAliasze
    A wrapper around methods or functions which automatically prints a
    deprecation message.
    NcCs�z	|j�|j�Wn	tyYnw||_||_||_||_||_t|t	t
��r,d}nd}d}|d|d|jjd7}|d�t
|��7}||_dS)N�func�methzDeprecated: zUse :z:`z` instead.
zSee {} for details.

)�__dict__�update�AttributeErrorrr�instance�unbound�
__module__�
isinstance�typer�__name__rr�__doc__)�selfrr�modulerr�
sphinxrole�docrrr�__init__,s"�
z DeprecatedFunctionAlias.__init__cCs�t��D]}|dj��D]\}}||ur|Sq
qddl}ddl}|��dd�}|jdur4|n|j}|�|�D]#}||�r_||j	ur_|�|�}	|	��D]\}
}||ur^|
SqPq<t
d��)NrcSs.t|t�sdSd|vpd|v}d|v}|p|S)NFr�__package__�__new__)r�dict)�gc_ref�is_python_class�is_cython_classrrr�is_classKs

z2DeprecatedFunctionAlias.__name__.<locals>.is_classz9The name of this deprecated function cannot be determined)�inspect�stack�	f_globals�items�gc�copy�collectr�
get_referrersrr)r�frame�name�objr-r.r(�
search_for�ref�ref_copy�key�valrrrr?s(��
��z DeprecatedFunctionAlias.__name__cOs�|jdur|j|jjkr|jjd|jj}n|jj}t|jd�|j|��|jdur3|j|i|��S|j|jg|�Ri|��S)N�.z({} is deprecated. Please use {} instead.)rrrrrrr)r�args�kwds�otherrrr�__call__Zs��
z DeprecatedFunctionAlias.__call__cCs$|dur|St|j|j|j||d�S)N)rr)rrrr)r�inst�clsrrr�__get__hs
�zDeprecatedFunctionAlias.__get__)NN)N)rr�__qualname__rr!rr=r@rrrrr&s

rcCs@d}t��}|r|j}|rt�|jj�}|durd}t|||�S)a;
    Create an aliased version of a function or a method which raises a
    deprecation warning message.

    If f is a function or a method, write
    ``g = deprecated_function_alias(merge_request, f)``
    to make a deprecated aliased version of f.

    INPUT:

    - ``merge_request`` -- integer. The merge request number where the
      deprecation is introduced.

    - ``func`` -- the function or method to be aliased

    EXAMPLES::

        sage: from admcycles.superseded import deprecated_function_alias
        sage: g = deprecated_function_alias(13, number_of_partitions)
        sage: g(5)
        doctest:...: DeprecationWarning: g is deprecated. Please use sage.combinat.partition.number_of_partitions instead.
        See https://gitlab.com/modulispaces/admcycles/-/merge_requests/13 for details.
        7
    N�__main__)r)�currentframe�f_back�
getmodulename�f_code�co_filenamer)rr�module_name�frame0�frame1rrr�deprecated_function_aliasrsrK)r	)
r�warningsrr)�sage.misc.lazy_attributerrrrrKrrrr�<module>s
	L