o
    h                     @   sJ   d dl Z d dlmZ G dd deZeZG dd deZG dd dZdS )	    N)import_modulec                   @      e Zd ZdS )RemovedInWagtail70WarningN__name__
__module____qualname__ r	   r	   Y/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/utils/deprecation.pyr          r   c                   @   r   )RemovedInWagtail80WarningNr   r	   r	   r	   r
   r      r   r   c                   @   s    e Zd ZdZdd Zdd ZdS )MovedDefinitionHandlera  
    A wrapper for module objects to enable definitions to be moved to a new module, with a
    deprecation path for the old location. Importing the name from the old location will
    raise a deprecation warning (but will still complete successfully).

    To use, place the following code in the old module:

    import sys
    from wagtail.utils.deprecation import MovedDefinitionHandler, RemovedInWagtailXWarning

    MOVED_DEFINITIONS = {
        'SomeClassOrVariableName': 'path.to.new.module',
    }

    sys.modules[__name__] = MovedDefinitionHandler(sys.modules[__name__], MOVED_DEFINITIONS, RemovedInWagtailXWarning)

    If the name of the definition has also changed, you can specify its new name along with
    the path to its new module using a tuple. For example:

    MOVED_DEFINITIONS = {
        'SomeClassOrVariableName': ('path.to.new.module', 'NewClassOrVariableName'),
    }
    c                 C   s   || _ || _|| _d S )N)real_modulemoved_definitionswarning_class)selfr   r   r   r	   r	   r
   __init__)   s   
zMovedDefinitionHandler.__init__c                 C   s   zt | j|W S  ty6 } z#z| j| }|}t|tr |\}}W n
 ty+   |d w W Y d }~nd }~ww ||krMtjd|| jj	||f | j
dd ntjd|| jj	|f | j
dd t|}t ||}t| j|| |S )Nz1%s has been moved from %s to %s and renamed to %s   )category
stacklevelz%s has been moved from %s to %s)getattrr   AttributeErrorr   
isinstancetupleKeyErrorwarningswarnr   r   r   setattr)r   nameenew_module_namenew_name
new_module
definitionr	   r	   r
   __getattr__.   sB   


z"MovedDefinitionHandler.__getattr__N)r   r   r   __doc__r   r$   r	   r	   r	   r
   r      s    r   )	r   	importlibr   DeprecationWarningr   removed_in_next_version_warningPendingDeprecationWarningr   r   r	   r	   r	   r
   <module>   s    