o
    ÓèFhÃ  ã                   @   sô   d Z ddlZddlZddlZddlmZmZmZmZm	Z	m
Z
 ddlZddlmZmZ ej d¡r8d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rxeƒ  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)ÚDictÚIterableÚNoReturnÚOptionalÚSetÚType)Ú	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 … } ddlm} |dƒj}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,�rD|�s"|d&ƒ |j,|v�r4||j,› d't|ƒ› �ƒ ||j, \}}|d)i |¤Ž|d(< |j!d)i |¤Ž}
t j& -¡  |
 #t j&j¡ d S )*Né   r   )Úget_distributionÚqrcodeÚ )ÚusageÚversionÚmsgÚreturnc                    s   ˆ   | ¡ ‚ ©N)Úerror)r   ©Úparser© úO/var/www/html/loop/nvenv/lib/python3.10/site-packages/qrcode/console_scripts.pyÚraise_error1   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_factoryÚsurrogateescape)Úerrors)ÚoptimizeÚwb)ÚttyÚdrawer_aliasesz+The selected factory has no drawer aliases.z$ factory drawer not found. Expected Úmodule_drawerr    ).ÚsysÚargvÚpkg_resourcesr   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   r"   ÚoptsÚmoduler,   ÚeÚqrÚdataÚimgÚoutÚkwargsÚaliasesÚ
drawer_clsÚdrawer_kwargsr    r   r!   Úmain(   s¤   
þþþý
ûÿþ€ÿþ
"ÿ$ÿÿÿ
rg   r]   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   )rG   ÚrsplitÚ
__import__rX   )r]   ÚnameÚimpr    r    r!   rF   Ž   s
   
rF   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 )Nr2   z. c                 s   s*   � | ]\}}d t |dƒ› d|› �V  qdS )zFor Úandz, use: N)r=   )Ú.0rd   Ú	factoriesr    r    r!   Ú	<genexpr>£   s
   € ÿ
ÿz"get_drawer_help.<locals>.<genexpr>)
r>   ÚitemsrF   ÚImportErrorrX   Ú
setdefaultr=   ÚsetÚaddÚjoin)r$   Úaliasr]   Úimagerd   rn   r    r    r!   r?   –   s   ÿ
þr?   Úorrp   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Úlenru   )rp   Újoinerr    r    r!   r=   ©   s   &r=   Ú__main__r   )rx   )r9   r7   rR   r4   Útypingr   r   r   r   r   r   r   Úqrcode.image.baser   r	   ÚplatformÚ
startswithÚcoloramaÚinitr>   ÚERROR_CORRECT_LÚERROR_CORRECT_MÚERROR_CORRECT_QÚERROR_CORRECT_Hr+   rg   r;   rF   r?   r=   Ú__name__r    r    r    r!   Ú<module>   s:    ùü
f	
ÿ