a
    ç´«je  ã                   @   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eeddœdd„Zdd„ Zejd!dd„ƒZdd„ Zejedœdd„ƒZdd„ Zdd„ Zd"dd„Zeedœdd „ZdS )#Ú	BaseImagez)
    Base QRCode image output class.
    NÚkindÚallowed_kindsFTc                 O   sT   || _ || _|| _| j| j d  | j | _| d¡| _| jf i |¤Ž| _|  ¡  d S )Né   Zqrcode_modules)	ÚborderÚwidthÚbox_sizeZ
pixel_sizeÚpopÚmodulesÚ	new_imageÚ_imgÚinit_new_image)Úselfr   r   r   ÚargsÚkwargs© r   úP/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/qrcode/image/base.pyÚ__init__   s    zBaseImage.__init__c                 C   s   dS )z9
        Draw a single rectangle of the QR code.
        Nr   ©r   ÚrowÚcolr   r   r   Údrawrect!   s    zBaseImage.drawrectr   ©r   r   Úqrc                 C   s   t dƒ‚dS )zV
        Draw a single rectangle of the QR code given the surrounding context
        úBaseImage.drawrect_contextN©ÚNotImplementedError)r   r   r   r    r   r   r   Údrawrect_context'   s    r!   c                 C   s   t dƒ‚dS )z4
        Processes QR code after completion
        zBaseImage.drawimageNr"   ©r   r   r   r   Úprocess-   s    zBaseImage.processc                 C   s   dS )z&
        Save the image file.
        Nr   )r   Ústreamr
   r   r   r   Úsave3   s    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   s   dS )zT
        Build the image class. Subclasses should return the class created.
        Nr   ©r   r   r   r   r   r   E   s    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   r/   r   r   r   Ú	get_imageN   s    zBaseImage.get_imagec                 C   s\   |du r| j }| j p|| jv }|r:||ƒ}|s:|| jv }|sXtdt| ƒj› d|› �ƒ‚|S )z%
        Get the image type.
        NzCannot set z	 type to )r
   r   Ú
ValueErrorÚtypeÚ__name__)r   r
   Z	transformÚallowedr   r   r   Ú
check_kindT   s    
zBaseImage.check_kind)r   r   c                 C   s<   |dk r|dk p:|dk r&| 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_eye)N)N)r4   Ú
__module__Ú__qualname__Ú__doc__r
   r   ÚstrÚ__annotations__r   ÚtupleÚneeds_contextZneeds_processingZneeds_drawrectr   ÚabcÚabstractmethodr   Úintr$   r&   r(   r,   r   r   r   r1   r6   r9   r   r   r   r   r	      s(   
	

r	   c                       sÆ   e Zd ZU ee ed< i Zeed< edœdd„Zedœdd„Z	dZ
d	ed
< d	ed< dddœeeedf eeedf dœ‡ fdd„Zeeedf ee dœdd„Z‡ fdd„Zeeddœdd„Z‡  ZS )ÚBaseImageWithDrawerÚdefault_drawer_classÚdrawer_aliasesr-   c                 C   s   |   ¡ S r0   ©rE   r%   r   r   r   Úget_default_module_drawerr   s    z-BaseImageWithDrawer.get_default_module_drawerc                 C   s   |   ¡ S r0   rG   r%   r   r   r   Úget_default_eye_draweru   s    z*BaseImageWithDrawer.get_default_eye_drawerTr   Úmodule_drawerÚ
eye_drawerN)rJ   rK   c                   s>   |   |¡p|  ¡ | _|   |¡p$|  ¡ | _tƒ j|i |¤Ž d S r0   )Ú
get_drawerrH   rJ   rI   rK   Úsuperr   )r   rJ   rK   r   r   ©Ú	__class__r   r   r   }   s    ÿzBaseImageWithDrawer.__init__)Údrawerr.   c                 C   s*   t |tƒs|S | j| \}}|f i |¤ŽS r0   )Ú
isinstancer=   rF   )r   rP   Z
drawer_clsr   r   r   r   rL   �   s    
zBaseImageWithDrawer.get_drawerc                    s&   | j j| d� | jj| d� tƒ  ¡ S )N)Úimg)rJ   Z
initializerK   rM   r   r%   rN   r   r   r   •   s    z"BaseImageWithDrawer.init_new_imager   r   c                 C   sX   |   ||¡}|  ||¡r| jn| j}|jr6| ||¡nt|j| | ƒ}| ||¡ d S r0   )	r,   r9   rK   rJ   Zneeds_neighborsZactive_with_neighborsÚboolr   r   )r   r   r   r    ÚboxrP   Ú	is_activer   r   r   r$   ›   s    ÿýz$BaseImageWithDrawer.drawrect_context)r4   r:   r;   r3   r   r>   rF   ÚDrawerAliasesrH   rI   r@   r   r=   r   r   rL   r   rC   r$   Ú__classcell__r   r   rN   r   rD   n   s$   
üüþrD   )rA   Útypingr   r   r   r   Z&qrcode.image.styles.moduledrawers.baser   Zqrcode.mainr   r   Údictr=   r?   r3   rV   r	   rD   r   r   r   r   Ú<module>   s    a