o
    ÓèFhx  ã                   @   sŽ   d dl Z d dlmZmZmZmZmZmZmZ d dl	m
Z
 er&d dlmZmZ eeeee
 eeef f f ZG dd„ dƒZG dd„ deƒZdS )	é    N)ÚTYPE_CHECKINGÚAnyÚDictÚOptionalÚTupleÚTypeÚUnion)ÚQRModuleDrawer)ÚActiveWithNeighborsÚQRCodec                   @   sÎ   e Zd ZU dZdZee ed< dZee	e  ed< dZ
dZdZdd„ Zejd	d
„ ƒZdededdfdd„Zdd„ Zejd"dd„ƒZdd„ Zejdefdd„ƒZdd„ Zdd„ Zd"dd„Zdedefd d!„ZdS )#Ú	BaseImagez)
    Base QRCode image output class.
    NÚkindÚallowed_kindsFTc                 O   sT   || _ || _|| _| j| j d  | j | _| d¡| _| jdi |¤Ž| _|  ¡  d S )Né   Úqrcode_modules© )	ÚborderÚwidthÚbox_sizeÚ
pixel_sizeÚpopÚmodulesÚ	new_imageÚ_imgÚinit_new_image)Úselfr   r   r   ÚargsÚkwargsr   r   úJ/var/www/html/loop/nvenv/lib/python3.10/site-packages/qrcode/image/base.pyÚ__init__   s   zBaseImage.__init__c                 C   ó   dS )z9
        Draw a single rectangle of the QR code.
        Nr   ©r   ÚrowÚcolr   r   r   Údrawrect!   ó    zBaseImage.drawrectr"   r#   Úqrr   c                 C   ó   t dƒ‚)zV
        Draw a single rectangle of the QR code given the surrounding context
        úBaseImage.drawrect_context©ÚNotImplementedError)r   r"   r#   r&   r   r   r   Údrawrect_context'   ó   r(   c                 C   r'   )z4
        Processes QR code after completion
        zBaseImage.drawimager)   ©r   r   r   r   Úprocess-   r,   zBaseImage.processc                 C   r    )z&
        Save the image file.
        Nr   )r   Ústreamr   r   r   r   Úsave3   r%   zBaseImage.savec                 C   sD   || j  | j }|| j  | j }||f|| j d || j d ffS )z‡
        A helper method for pixel-based image generators that specifies the
        four pixel coordinates for a single rect.
        é   )r   r   )r   r"   r#   ÚxÚyr   r   r   Ú	pixel_box9   s
   þzBaseImage.pixel_boxÚreturnc                 K   r    )zT
        Build the image class. Subclasses should return the class created.
        Nr   ©r   r   r   r   r   r   E   r%   zBaseImage.new_imagec                 C   s   d S ©Nr   r-   r   r   r   r   K   s   zBaseImage.init_new_imagec                 K   s   | j S )z@
        Return the image class for further processing.
        )r   r6   r   r   r   Ú	get_imageN   s   zBaseImage.get_imagec                 C   s\   |du r| j }| j p|| jv }|r||ƒ}|s|| jv }|s,tdt| ƒj› d|› �ƒ‚|S )z%
        Get the image type.
        NzCannot set z	 type to )r   r   Ú
ValueErrorÚtypeÚ__name__)r   r   Ú	transformÚallowedr   r   r   Ú
check_kindT   s   
zBaseImage.check_kindc                 C   s<   |dk r|dk p|dk o| j | dk p| j | dk o|dk S )zB
        Find whether the referenced module is in an eye.
        é   é   )r   r!   r   r   r   Úis_eyec   s
   ÿýzBaseImage.is_eyer7   )r;   Ú
__module__Ú__qualname__Ú__doc__r   r   ÚstrÚ__annotations__r   r   Úneeds_contextÚneeds_processingÚneeds_drawrectr   ÚabcÚabstractmethodr$   Úintr+   r.   r0   r4   r   r   r   r8   r>   rA   r   r   r   r   r      s*   
 	

r   c                       sÎ   e Zd ZU ee ed< i Zeed< defdd„Zdefdd„Z	dZ
d	ed
< d	ed< dddœd
eeedf deeedf f‡ fdd„Zdeeedf dee fdd„Z‡ fdd„Zdededdfdd„Z‡  ZS )ÚBaseImageWithDrawerÚdefault_drawer_classÚdrawer_aliasesr5   c                 C   ó   |   ¡ S r7   ©rN   r-   r   r   r   Úget_default_module_drawerr   ó   z-BaseImageWithDrawer.get_default_module_drawerc                 C   rP   r7   rQ   r-   r   r   r   Úget_default_eye_draweru   rS   z*BaseImageWithDrawer.get_default_eye_drawerTr	   Úmodule_drawerÚ
eye_drawerN)rU   rV   c                   s>   |   |¡p|  ¡ | _|   |¡p|  ¡ | _tƒ j|i |¤Ž d S r7   )Ú
get_drawerrR   rU   rT   rV   Úsuperr   )r   rU   rV   r   r   ©Ú	__class__r   r   r   }   s   ÿzBaseImageWithDrawer.__init__Údrawerc                 C   s*   t |tƒs|S | j| \}}|di |¤ŽS )Nr   )Ú
isinstancerE   rO   )r   r[   Ú
drawer_clsr   r   r   r   rW   �   s   
zBaseImageWithDrawer.get_drawerc                    s&   | j j| d� | jj| d� tƒ  ¡ S )N)Úimg)rU   Ú
initializerV   rX   r   r-   rY   r   r   r   •   s   
z"BaseImageWithDrawer.init_new_imager"   r#   r&   r   c                 C   sX   |   ||¡}|  ||¡r| jn| j}|jr| ||¡nt|j| | ƒ}| ||¡ d S r7   )	r4   rA   rV   rU   Úneeds_neighborsÚactive_with_neighborsÚboolr   r$   )r   r"   r#   r&   Úboxr[   Ú	is_activer   r   r   r+   ›   s   ÿýz$BaseImageWithDrawer.drawrect_context)r;   rB   rC   r   r	   rF   rO   ÚDrawerAliasesrR   rT   rG   r   rE   r   r   rW   r   rL   r+   Ú__classcell__r   r   rY   r   rM   n   s,   
 üýüÿ
þrM   )rJ   Útypingr   r   r   r   r   r   r   Ú&qrcode.image.styles.moduledrawers.baser	   Úqrcode.mainr
   r   rE   re   r   rM   r   r   r   r   Ú<module>   s    $ a