a
    Dg                     @   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                   @   s   e Zd ZdS )RemovedInWagtail70WarningN__name__
__module____qualname__ r   r   X/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/utils/deprecation.pyr      s   r   c                   @   s   e Zd ZdS )RemovedInWagtail80WarningNr   r   r   r   r	   r
      s   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yp } zJz$| j| }|}t|tr@|\}}W n tyZ   |d Y n0 W Y d }~n
d }~0 0 ||krt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eZnew_module_namenew_nameZ
new_moduleZ
definitionr   r   r	   __getattr__.   s:    

"
z"MovedDefinitionHandler.__getattr__N)r   r   r   __doc__r   r   r   r   r   r	   r      s   r   )	r   	importlibr   DeprecationWarningr   Zremoved_in_next_version_warningPendingDeprecationWarningr
   r   r   r   r   r	   <module>   s
   