HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/qrcode/__pycache__/main.cpython-39.opt-1.pyc
a

��;\ 7�@shddlmZmZmZddlmZddlZddlmZddd�Z	dd�Z
d	d
�Zdd�ZGd
d�d�Z
dS)�)�	constants�
exceptions�util)�	BaseImageN)�bisect_leftcKs tfi|��}|�|�|��S�N)�QRCode�add_data�
make_image)�data�kwargsZqr�r
�//usr/lib/python3.9/site-packages/qrcode/main.py�makes
rcCs |dks|dkrtd|��dS)N��(z*Invalid version (was %s, expected 1 to 40))�
ValueError)�versionr
r
r�_check_versions�rcCst|�dkrtd|��dS)Nrz1Invalid box size (was %s, expected larger than 0))�intr)�sizer
r
r�_check_box_sizes�rcCsF|durdSt|t�s&tdt|���|dks6|dkrBtd|��dS)Nz+Invalid mask pattern (was %s, expected int)r�z+Mask pattern should be in range(8) (got %s))�
isinstancer�	TypeError�typer)�mask_patternr
r
r�_check_mask_patterns

��rc@s�eZdZdejddddfdd�Zdd�Zd)d	d
�Zd*dd
�Zdd�Z	dd�Z
d+dd�Zdd�Zd,dd�Z
d-dd�Zd.dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�ZdS)/rN�
�cCs\t|�|ot|�|_t|�|_t|�|_t|�|_t|�||_||_|durP|�	�dSr)
rrr�error_correction�box_size�borderrr�
image_factory�clear)�selfrr r!r"r#rr
r
r�__init__'s


zQRCode.__init__cCsd|_d|_d|_g|_dS)z*
        Reset the internal data.
        Nr)�modules�
modules_count�
data_cache�	data_list)r%r
r
rr$:szQRCode.clear�cCsRt|tj�r|j�|�n.|r6|j�tj||d��n|j�t�|��d|_dS)a
        Add data to this QR Code.

        :param optimize: Data will be split into multiple chunks to optimize
            the QR size by finding to more compressed modes of at least this
            length. Set to ``0`` to avoid optimizing at all.
        )ZminimumN)rrZQRDatar*�append�extendZoptimal_data_chunksr))r%r�optimizer
r
rr	Cs�zQRCode.add_dataTcCsJ|s|jdur|j|jd�|jdur8|�d|���n|�d|j�dS)z�
        Compile the data into a QR Code array.

        :param fit: If ``True`` (or if a size has not been provided), find the
            best fit for the data to avoid data overflow errors.
        N��startF)r�best_fitr�makeImpl�best_mask_pattern)r%Zfitr
r
rrUs

zQRCode.makecCs�t|j�|jdd|_dg|j|_t|j�D]4}dg|j|j|<t|j�D]}d|j||<qRq2|�dd�|�|jdd�|�d|jd�|��|��|�||�|jdkr�|�	|�|j
dur�t�|j|j
|j�|_
|�|j
|�dS)Nr�rr)rrr(r'�range�setup_position_probe_pattern�setup_position_adjust_pattern�setup_timing_pattern�setup_type_info�setup_type_numberr)rZcreate_datar r*�map_data)r%�testr�row�colr
r
rr2cs(



�zQRCode.makeImplcCs�tdd�D]�}||dks
|j||kr*q
tdd�D]�}||dks4|j||krTq4d|krt|dkrt|dks�|dks�d|kr�|dkr�|dks�|dks�d|kr�|dkr�d|kr�|dkr�d|j||||<q4d|j||||<q4q
dS)	N����r��rTF�r5r(r')r%r=r>�r�cr
r
rr6~s2 ��������z#QRCode.setup_position_probe_patterncCs�|durd}t|�t�|�}t��}|jD]2}|�|jd�|�t|�||j�|�|�q,t|�}t	tj
|j||�|_|jdkr�t
���|t�|j�ur�|j|jd�|jS)zD
        Find the minimum size required to fit in the data.
        Nrr�)r/)rrZmode_sizes_for_versionZ	BitBufferr*Zput�mode�len�writerZBIT_LIMIT_TABLEr rrZDataOverflowErrorr1)r%r0Z
mode_sizes�bufferrZneeded_bitsr
r
rr1�s$

�
zQRCode.best_fitcCsJd}d}td�D]4}|�d|�t�|j�}|dks<||kr|}|}q|S)z7
        Find the most efficient mask pattern.
        rr@T)r5r2r�
lost_pointr')r%Zmin_lost_point�pattern�irKr
r
rr3�szQRCode.best_mask_patterncCs�|durddl}|j}|��s&td��|jdur8|��|j}|�dd|ddd�t|�D]J}|�d	�t|�D](}|j	||r�|�d
�qz|�d	�qz|�d�qd|�dd|ddd�|�
�dS)zz
        Output the QR Code only using TTY colors.

        If the data has not been compiled yet, make it first.
        Nr�	Not a ttyz� rBrz
z  z  z  
)�sys�stdout�isatty�OSErrorr)rr(rIr5r'�flush)r%�outrP�modcountrDrEr
r
r�	print_tty�s$

zQRCode.print_ttyFcsP|dur>ddl}|jdkr8ddl}|�|jj�|j�}n|j}|rR|��sRtd���jdurd��	��j
�dd�dD�}|r�d��r�|�����fd	d
�}t�j
��j
d�D]�}|r�r�|��j
dkr�|�d
�|�d�t�j
��j
�D].}	|||	�||d|	�d>}
|�||
�q�|�r8|�d�|�d�q�|��dS)z�
        Output the QR Code using ASCII characters.

        :param tty: use fixed TTY color codes (forces invert=True)
        :param invert: invert the ASCII characters (solid <-> transparent)
        Nr)rBrrNcSsg|]}t�|��d��qS)�cp437)�sixZint2byte�decode)�.0�coder
r
r�
<listcomp>�s�z&QRCode.print_ascii.<locals>.<listcomp>)�������TcsP�r"�jr"t||���jkr"dSt||�dks>t||��krBdS�j||S)Nrr)r"�max�minr')�x�y��invertrVr%r
r�
get_module�s
�z&QRCode.print_ascii.<locals>.get_modulerBrzzz�
)rP�version_info�codecs�	getwriterrQ�encodingrRrSr)rr(�reverser5r"rIrT)r%rUZttyrgrPrkZcodesrhrDrE�posr
rfr�print_ascii�s>

�


zQRCode.print_asciicKs�t|j�|jdur|��|dur&n|j}|durDddlm}|}||j|j|jfi|��}t	|j�D].}t	|j�D]}|j
||rv|�||�qvqh|S)zu
        Make an image from the QR Code data.

        If the data has not been compiled yet, make it first.
        Nr)�PilImage)rr!r)rr#Zqrcode.image.pilrqr"r(r5r'Zdrawrect)r%r#rrqZimrDrEr
r
rr
s&

��zQRCode.make_imagecCs�td|jd�D].}|j|ddur(q|ddk|j|d<qtd|jd�D].}|jd|durhqP|ddk|jd|<qPdS)Nr@rArBrrC)r%rDrEr
r
rr8,szQRCode.setup_timing_patterncCs�t�|j�}tt|��D]�}tt|��D]�}||}||}|j||durPq(tdd�D]r}tdd�D]b}|dks�|dks�|dks�|dks�|dkr�|dkr�d|j||||<qhd|j||||<qhqZq(qdS)N����rBrTF)rZpattern_positionrr5rHr')r%rorM�jr=r>rDrEr
r
rr77s  ��z$QRCode.setup_position_adjust_patterncCs�t�|j�}td�D]>}|o,||?d@dk}||j|d|d|jdd<qtd�D]>}|ot||?d@dk}||j|d|jdd|d<q\dS)N�rrsr@)rZBCH_type_numberrr5r'r()r%r<�bitsrM�modr
r
rr:Ns&zQRCode.setup_type_numbercCs"|jd>|B}t�|�}td�D]f}|o8||?d@dk}|dkrR||j|d<q |dkrn||j|dd<q ||j|jd|d<q td�D]v}|o�||?d@dk}|dkr�||jd|j|d<q�|dkr�||jdd|dd<q�||jdd|d<q�||j|jdd<dS)Nrs�rrAr@�	)r rZ
BCH_type_infor5r'r()r%r<rrrvrMrwr
r
rr9Ys"
zQRCode.setup_type_infoc
Csd}|jd}d}d}t�|�}t|�}tj�|jddd�D]�}	|	dkrR|	d8}	|	|	df}
|
D]p}|j||durbd}||kr�|||?d@dk}|||�r�|}||j||<|d8}|dkrb|d7}d}qb||7}|dks�|j|kr^||8}|}q>q^q>dS)Nr?rrrrrrAF)r(r�	mask_funcrHrYZmovesZxranger')
r%rrZincr=ZbitIndexZ	byteIndexrzZdata_lenr>Z	col_rangerEZdarkr
r
rr;xs6


zQRCode.map_datacCs�|jdur|��|js|jSt|j�|jd}dg|g|j}dg|j}|jD]}|�|||�qV|dg|g|j7}|S)z�
        Return the QR Code as a multidimensonal array, including the border.

        To return the array without a border, set ``self.border`` to 0 first.
        NrBF)r)rr"r'rHr,)r%�widthr\Zx_border�moduler
r
r�
get_matrix�s

zQRCode.get_matrix)r+)T)N)N)NFF)N)�__name__�
__module__�__qualname__rZERROR_CORRECT_Mr&r$r	rr2r6r1r3rWrpr
r8r7r:r9r;r}r
r
r
rr%s,�
	




5
-r)N)ZqrcoderrrZqrcode.image.baserrYZbisectrrrrrrr
r
r
r�<module>s