o
    Ûäh¶  ã                   @   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¡r<d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dedee fdd„Zdefdd„Zddee defdd„Zedkr|eƒ  dS 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)ÚpilÚpngÚsvgzsvg-fragmentzsvg-pathÚpymaging)ÚLÚMÚQÚHc              
      s¦  | d u rt jdd … } t d¡}tjtpd ¡ |d�‰ dtdt	f‡ 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 n ty” } z|t|ƒƒ W Y d }~nd }~ww d }tjt|j |d�}| r®| d }|jdd �}nt jj ¡ }|jd u r¿| |¡ n|j||jd!� |jrì|  ¡ }	t!|jd"ƒ�}
|	 "|
¡ W d   ƒ d S 1 såw   Y  d S |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�r-||j+› d&t|ƒ› �ƒ ||j+ \}}|d(i |¤Ž|d'< |j d(i |¤Ž}	t j% ,¡  |	 "t j%j¡ d S ))Né   ÚqrcodeÚ )ÚusageÚversionÚmsgÚreturnc                    s   ˆ   | ¡ ‚ ©N)Úerror)r   ©Úparser© úI/var/www/html/venv/lib/python3.10/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 Úmodule_drawerr   )-Ú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   ÚQRCodeÚencodeÚstdinÚbufferÚreadr,   Úadd_dataÚoutputÚ
make_imageÚopenÚsaveÚosÚisattyÚstdoutÚfilenoÚasciiÚprint_asciiÚgetattrr)   Úfactory_drawerÚflush)Úargsr   r   ÚoptsÚmoduler)   ÚeÚqrÚdataÚimgÚoutÚkwargsÚaliasesÚ
drawer_clsÚdrawer_kwargsr   r   r   Úmain+   s¢   
þþþý
ûÿþ€ÿþ
"ÿ"ÿÿÿ
rc   rY   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   )rC   ÚrsplitÚ
__import__rT   )rY   ÚnameÚimpr   r   r   rB   �   s
   
rB   c               	   C   s|   i } t  ¡ D ]+\}}zt|ƒ}W n	 ty   Y qw t|dd ƒ}|s#q|  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)r9   )Ú.0r`   Ú	factoriesr   r   r   Ú	<genexpr>¥   s
   € ÿ
ÿz"get_drawer_help.<locals>.<genexpr>)
r:   ÚitemsrB   ÚImportErrorrT   Ú
setdefaultr9   ÚsetÚaddÚjoin)r!   ÚaliasrY   Úimager`   rj   r   r   r   r;   ˜   s   ÿ
þr;   Úorrl   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Úlenrq   )rl   Újoinerr   r   r   r9   «   s   &r9   Ú__main__r   )rt   ) r5   r3   rN   r1   Útypingr   r   Úcollections.abcr   Ú	importlibr   r   Úqrcode.image.baser   r   ÚplatformÚ
startswithÚcoloramaÚinitr:   ÚERROR_CORRECT_LÚERROR_CORRECT_MÚERROR_CORRECT_QÚERROR_CORRECT_Hr(   rc   r7   r"   rB   r;   r9   Ú__name__r   r   r   r   Ú<module>   s>   ùü
e	
ÿ