o
    Ûähe  ã                   @   s‚   d dl Z d dl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ÚOptionalÚ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   úD/var/www/html/venv/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   r3   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_eyer4   )r8   Ú
__module__Ú__qualname__Ú__doc__r
   r   ÚstrÚ__annotations__r   ÚtupleÚneeds_contextÚneeds_processingÚneeds_drawrectr   ÚabcÚabstractmethodr!   Úintr(   r+   r-   r1   r   r   r   r5   r;   r>   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_aliasesr2   c                 C   ó   |   ¡ S r4   ©rL   r*   r   r   r   Úget_default_module_drawerr   ó   z-BaseImageWithDrawer.get_default_module_drawerc                 C   rN   r4   rO   r*   r   r   r   Úget_default_eye_draweru   rQ   z*BaseImageWithDrawer.get_default_eye_drawerTr   Úmodule_drawerÚ
eye_drawerN)rS   rT   c                   s>   |   |¡p|  ¡ | _|   |¡p|  ¡ | _tƒ j|i |¤Ž d S r4   )Ú
get_drawerrP   rS   rR   rT   Úsuperr   )r   rS   rT   r   r   ©Ú	__class__r   r   r   }   s   ÿzBaseImageWithDrawer.__init__Údrawerc                 C   s*   t |tƒs|S | j| \}}|di |¤ŽS )Nr   )Ú
isinstancerB   rM   )r   rY   Ú
drawer_clsr   r   r   r   rU   �   s   
zBaseImageWithDrawer.get_drawerc                    s&   | j j| d� | jj| d� tƒ  ¡ S )N)Úimg)rS   Ú
initializerT   rV   r   r*   rW   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 r4   )	r1   r>   rT   rS   Úneeds_neighborsÚactive_with_neighborsÚboolr   r!   )r   r   r    r#   ÚboxrY   Ú	is_activer   r   r   r(   ›   s   ÿýz$BaseImageWithDrawer.drawrect_context)r8   r?   r@   r7   r   rC   rM   ÚDrawerAliasesrP   rR   rE   r   rB   r   r   rU   r   rJ   r(   Ú__classcell__r   r   rW   r   rK   n   s,   
 üýüÿ
þrK   )rH   Útypingr   r   r   r   Ú&qrcode.image.styles.moduledrawers.baser   Úqrcode.mainr   r   ÚdictrB   rD   r7   rc   r	   rK   r   r   r   r   Ú<module>   s     a