o
    h                     @   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   V/var/www/html/ndineBlogger/venv/lib/python3.10/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 )Naltz%sclass)r   r   r   r   img_tag)r   r   r   extra_attributes	renditionr   r   r   r    4   s   
zFormat.image_to_htmlr
   )__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   

r0   c                    sX   z j  W n	 ty   Y nw zt =  fddtD aW d S  ty+   td  w )Nc                    s   g | ]	}|j  kr|qS r   r   ).0fmtformat_namer   r   
<listcomp>U   s    z+unregister_image_format.<locals>.<listcomp>z#Image format '%s' is not registered)r   AttributeErrorr+   r-   r,   r4   r   r4   r   unregister_image_formatK   s   
r8   c                   C   s
   t   tS r
   )search_for_image_formatsr-   r   r   r   r   get_image_formatsZ   s   r:   c                 C   s   t   t|  S r
   )r9   r+   r1   r   r   r   get_image_format_   s   r;   Fc                   C   s   t sttd da d S d S )Nimage_formatsT)_searched_for_image_formatslistr   r   r   r   r   r9   g   s   r9   	fullwidthz
Full widthzrichtext-image full-widthz	width-800leftzLeft-alignedzrichtext-image leftz	width-500rightzRight-alignedzrichtext-image rightN)warningsr   django.utils.htmlr   django.utils.translationr   _wagtail.utils.appsr   wagtail.utils.deprecationr   	shortcutsr   r	   r-   r+   r0   r8   r:   r;   r=   r9   r   r   r   r   <module>   s0    4