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rt|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 sw   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	--factoryzFull 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
--optimizezOptimize 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	
