a
    Dg                     @   s   d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 ddlmZ G dd	 d	Zg ai Zd
d Zdd Zdd Zdd Zdadd Zeededdd eededdd eededdd d S )!    )warn)escape)gettext_lazy)get_app_submodules)RemovedInWagtail70Warning   )get_rendition_or_not_foundc                   @   sJ   e Zd Zdd Zdd Zdd Zedd Zd	d
 Zdd Z	dddZ
dS )Formatc                 C   s   || _ || _|| _|| _d S Nnamelabel	classnamefilter_spec)selfr   r   r   r    r   U/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/images/formats.py__init__   s    zFormat.__init__c              	   C   s&   d| j  d| j d| j d| j d	S )N"z", "r   r   r   r   r   __str__   s    $zFormat.__str__c                 C   s   d|  dS )NzFormat()r   r   r   r   r   __repr__   s    zFormat.__repr__c                 C   s   t dtd | jS )NzHThe class property `classnames` is deprecated - use `classname` instead.)category)r   r   r   r   r   r   r   
classnames   s
    zFormat.classnamesc                 C   s   d|j | jt|dS )z
        Return additional attributes to go on the HTML element
        when outputting this image within a rich text editor field
        image)zdata-embedtypezdata-idzdata-formatzdata-alt)idr   r   r   r   alt_textr   r   r   editor_attributes#   s
    zFormat.editor_attributesc                 C   s   |  ||| ||S r
   )image_to_htmlr   r   r   r   r   image_to_editor_html/   s    zFormat.image_to_editor_htmlNc                 C   sF   |d u ri }t || j}t||d< | jr<dt| j |d< ||S )NZaltz%sclass)r   r   r   r   Zimg_tag)r   r   r   Zextra_attributesZ	renditionr   r   r   r    4   s    zFormat.image_to_html)N)__name__
__module____qualname__r   r   r   propertyr   r   r!   r    r   r   r   r   r	      s   
r	   c                 C   s0   | j tv rtd| j  | t| j < t|  d S )Nz'Image format '%s' is already registered)r   FORMATS_BY_NAMEKeyErrorFORMATSappend)formatr   r   r   register_image_formatD   s    

r,   c                    s^   z
 j  W n ty   Y n0 zt =  fddtD aW n tyX   td  Y n0 d S )Nc                    s   g | ]}|j  kr|qS r   r   ).0fmtformat_namer   r   
<listcomp>U       z+unregister_image_format.<locals>.<listcomp>z#Image format '%s' is not registered)r   AttributeErrorr'   r)   r(   r0   r   r0   r   unregister_image_formatK   s    
r5   c                   C   s
   t   tS r
   )search_for_image_formatsr)   r   r   r   r   get_image_formatsZ   s    r7   c                 C   s   t   t|  S r
   )r6   r'   r-   r   r   r   get_image_format_   s    r8   Fc                   C   s   t sttd da d S )NZimage_formatsT)_searched_for_image_formatslistr   r   r   r   r   r6   g   s    r6   Z	fullwidthz
Full widthzrichtext-image full-widthz	width-800leftzLeft-alignedzrichtext-image leftz	width-500rightzRight-alignedzrichtext-image rightN)warningsr   Zdjango.utils.htmlr   Zdjango.utils.translationr   _Zwagtail.utils.appsr   Zwagtail.utils.deprecationr   Z	shortcutsr   r	   r)   r'   r,   r5   r7   r8   r9   r6   r   r   r   r   <module>   s.   4