
    
g                     z   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mZ ddlZddlmZmZ ej                            d          rddlZ ej                     ddd	d
dddZej        ej        ej        ej        dZddZdede
e         fdZdefdZddee         def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)DictIterableNoReturnOptionalSetType)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                    | t           j        dd          } t          j        d          }t	          j        t          pd                                |          dt          dt          ffd}
                    dd	t          t                     d
           
                    ddt                       d
           
                    dt          d           
                    ddt          t                                                     dd           
                    ddd           
                    dd                               |           \  }} |j        ret                              |j        |j                  }	 t+          |          }n1# t,          $ r"} |t          |                     Y d }~n
d }~ww xY wd }t/          j        t           |j                 |          }| r| d         }|                    d          }n#t           j        j                                        }|j        |                    |           n|                    ||j                    |j        rY|                                 }	tC          |j        d!          5 }
|	"                    |
           d d d            d S # 1 swxY w Y   d S |UtG          j$        t           j%        &                                          s|j'        r|(                    |j'         "           d S i }tS          |j*        d#d           }|j+        rS|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                 0                         |             N)error)r   parsers    H/var/www/api/venv/lib/python3.11/site-packages/qrcode/console_scripts.pyraise_errorzmain.<locals>.raise_error2   s    S    z	--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_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   QRCodeencodestdinbufferreadr1   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!   s                  @r"   mainri   *   s   |x|x((G"'-R)>)>)@)@'RRRF        H+12C+D+DH H H     =):):===     A     ',,..//2     A,          ""4((JD$| "&&t|T\BB	 '//MM 	  	  	 KA	  	)$*?@#
 
 
B
  'Aw{{"3{44y$$&&}
D
D4=111{ $mmoo$+t$$ 	HHSMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  bi
0A0A0C0C&D&D 
 NN4:~N...F+2.,
 ,
  		B KIJJJ"'11* 3 3!'3 3   )00C(D%J&0j&A&A=&A&AF?#bm%%f%%
"#####s*   F" "
G,G		G&K		KKr_   r   c                     d| vrt          d          |                     dd          \  } }t          | i i |g          }t          ||          S )Nr%   z+The image factory is not a full python pathr   )rI   rsplit
__import__rZ   )r_   nameimps      r"   rH   rH      sX    
&FGGG==a((LFD
VRdV
,
,C3r$   c                     i } t                                           D ]~\  }}	 t          |          }n# t          $ r Y "w xY wt	          |dd           }|s:|                     t          |          t                                }|                    |           d	                    d |                                 D                       S )Nr4   z. c              3   H   K   | ]\  }}d t          |d           d| V  dS )zFor andz, use: N)r?   ).0rf   	factoriess      r"   	<genexpr>z"get_drawer_help.<locals>.<genexpr>   sT        GY 	:vi''9999     r$   )
r@   itemsrH   ImportErrorrZ   
setdefaultr?   setaddjoin)r&   aliasr_   imagerf   rs   s         r"   rA   rA      s    D*0022 	 	v	''EE 	 	 	H	+25:JD+Q+Q 	OOF7OOSUU;;	e99  "&**,,     s   2
??orru   c                     t          |           } | sdS t          |           dk    r| d         S d                    | d d                    d| d| d          S )Nr   r   r   z,  )tuplelenrz   )ru   joiners     r"   r?   r?      sf    %LLE r
5zzQQxiicrc
##::f::uRy:::r$   __main__r   )r}   )!r;   r9   rT   r7   typingr   r   r   r   r   r   	importlibr	   r   qrcode.image.baser
   r   platform
startswithcoloramainitr@   ERROR_CORRECT_LERROR_CORRECT_MERROR_CORRECT_QERROR_CORRECT_Hr-   ri   r=   rH   rA   r?   __name__r6   r$   r"   <module>r      s     				 



 @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @        6 6 6 6 6 6 6 6 <,-- OOOHMOOO ')&7/1   
								  b$ b$ b$ b$J Y        &; ;(3- ; ; ; ; ; zDFFFFF r$   