o
    >e                     @   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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,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 W/var/www/html/humari/django-venv/lib/python3.10/site-packages/qrcode/console_scripts.pyraise_error1   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_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	
