a
    ç´«j¶  ã                   @   sô   d Z ddlZddlZddlZddlmZmZ ddlmZ ddl	m
Z
 ddlZddlmZmZ ej d¡rxddlZe ¡  dd	d
ddddœZejejejejdœZddd„Zeee dœdd„Zedœdd„Zdee edœdd„Zedkrðeƒ  dS )zÑ
qr - Convert stdin (or the first argument) to a QR Code.

When stdout is a tty the QR Code is printed to the terminal and when stdout is
a pipe to a file an image is written. The default image format is PNG.
é    N)ÚNoReturnÚOptional)ÚIterable)Úmetadata)Ú	BaseImageÚDrawerAliases)ÚwinÚcygwinzqrcode.image.pil.PilImagezqrcode.image.pure.PyPNGImagezqrcode.image.svg.SvgImagez!qrcode.image.svg.SvgFragmentImagezqrcode.image.svg.SvgPathImagezqrcode.image.pure.PymagingImage)ZpilZpngÚsvgzsvg-fragmentzsvg-pathZpymaging)ÚLÚMÚQÚHc              
      s°  | d u rt jdd … } t d¡}tjtp*d ¡ |d�‰ tt	dœ‡ fdd„}ˆ j
dd	ttƒ› d
�d� ˆ j
ddtƒ › d
�d� ˆ j
dtdd� ˆ j
ddtt ¡ ƒddd� ˆ j
dddd� ˆ j
ddd� ˆ  | ¡\}} |j�r.t |j|j¡}zt|ƒ}W n2 t�y* } z|t|ƒƒ W Y d }~n
d }~0 0 nd }tjt|j |d�}| �rb| d }|jdd�}nt jj ¡ }|jd u �r†| |¡ n|j||jd � |j�rà|  ¡ }	t!|jd!ƒ�}
|	 "|
¡ W d   ƒ n1 �sÔ0    Y  nÌ|d u �rt# $t j% &¡ ¡�s|j'�r|j(|j' d"� d S i }t)|j*d#d ƒ}|j+�r„|�s@|d$ƒ |j+|v�rd||j+› d%t|ƒ› �ƒ ||j+ \}}|f i |¤Ž|d&< |j f i |¤Ž}	t j% ,¡  |	 "t j%j¡ d S )'Né   ÚqrcodeÚ )ÚusageÚversion)ÚmsgÚreturnc                    s   ˆ   | ¡ ‚ d S )N)Úerror)r   ©Úparser© úU/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/qrcode/console_scripts.pyÚraise_error3   s    
zmain.<locals>.raise_errorz	--factoryz‘Full python path to the image factory class to create the image with. You can use the following shortcuts to the built-in image factory classes: Ú.)Úhelpz--factory-drawerzUse an alternate drawer. z
--optimizezŸOptimize the data by looking for chunks of at least this many characters that could use a more efficient encoding method. Use 0 to turn off chunk optimization.)Útyper   z--error-correctionÚchoicer   z^The error correction level to use. Choices are L (7%), M (15%, default), Q (25%), and H (30%).)r   ÚchoicesÚdefaultr   z--asciiz'Print as ascii even if stdout is piped.Ú
store_true)r   Úactionz--outputzLThe output file. If not specified, the image is sent to the standard output.)Úerror_correctionÚimage_factoryr   Úsurrogateescape)Úerrors)ÚoptimizeÚwb)ÚttyÚdrawer_aliasesz+The selected factory has no drawer aliases.z$ factory drawer not found. Expected Zmodule_drawer)-ÚsysÚargvr   r   ÚoptparseÚOptionParserÚ__doc__ÚstripÚstrr   Ú
add_optionÚcommasÚdefault_factoriesÚget_drawer_helpÚintÚsortedr$   ÚkeysÚ
parse_argsÚfactoryÚgetÚget_factoryÚ
ValueErrorr   ZQRCodeÚencodeÚstdinÚbufferÚreadr(   Zadd_dataÚoutputZ
make_imageÚopenÚsaveÚosÚisattyÚstdoutÚfilenoÚasciiZprint_asciiÚgetattrr%   Zfactory_drawerÚflush)Úargsr   r   ÚoptsÚmoduler%   ÚeZqrÚdataÚimgÚoutÚkwargsÚaliasesZ
drawer_clsZdrawer_kwargsr   r   r   Úmain+   sœ    
þþþý
ûÿþ$þ,$ÿÿÿ
rV   )rO   r   c                 C   s:   d| vrt dƒ‚|  dd¡\} }t| i i |gƒ}t||ƒS )Nr   z+The image factory is not a full python pathr   )r>   ÚrsplitÚ
__import__rK   )rO   ÚnameÚimpr   r   r   r=   �   s
    r=   )r   c               	   C   s€   i } t  ¡ D ]Z\}}zt|ƒ}W n ty6   Y qY n0 t|dd ƒ}|sJq|  t|ƒtƒ ¡}| |¡ qd 	dd„ |  ¡ D ƒ¡S )Nr+   z. c                 s   s(   | ] \}}d t |dƒ› d|› �V  qdS )zFor Úandz, use: N)r4   )Ú.0rU   Ú	factoriesr   r   r   Ú	<genexpr>¥   s   ÿz"get_drawer_help.<locals>.<genexpr>)
r5   Úitemsr=   ÚImportErrorrK   Ú
setdefaultr4   ÚsetÚaddÚjoin)r   ÚaliasrO   ÚimagerU   r]   r   r   r   r6   ˜   s    

þr6   Úor)r_   r   c                 C   sJ   t | ƒ} | sdS t| ƒdkr$| d S d | d d… ¡› d|› d| d › �S )Nr   r   r   z, éÿÿÿÿú )ÚtupleÚlenrd   )r_   Újoinerr   r   r   r4   «   s    r4   Ú__main__)N)rg   ) r0   r.   rF   r,   Útypingr   r   Úcollections.abcr   Ú	importlibr   r   Zqrcode.image.baser   r   ÚplatformÚ
startswithÚcoloramaÚinitr5   ZERROR_CORRECT_LZERROR_CORRECT_MZERROR_CORRECT_QZERROR_CORRECT_Hr$   rV   r2   r   r=   r6   r4   Ú__name__r   r   r   r   Ú<module>   s:   ùü
e	