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