
    tg                        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"                  j%                  d      rddlZ ej(                          ddd	d
dddZej,                  ej.                  ej0                  ej2                  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        yy)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        xs dj                         |      dt        dt        ffd}j                  dd	t        t               d
       j                  ddt                d
       j                  dt        d       j                  ddt        t         j#                               dd       j                  ddd       j                  dd       j%                  |       \  }} |j&                  r7t        j)                  |j&                  |j&                        }	 t+        |      }nd }t/        j0                  t         |j                            }| r| d   }|j3                  d      }n(t         j4                  j6                  j9                         }|j:                  |j=                  |       n|j=                  ||j:                          |j>                  rA|jA                         }	tC        |j>                  d!      5 }
|	jE                  |
       d d d        y |[tG        jH                  t         jJ                  jM                               s|jN                  r|jQ                  |jN                   "       y i }tS        |jT                  d#d       }|jV                  rU|s |d$       |jV                  |vr  ||jV                   d%t        |              ||jV                     \  }} |d'i ||d&<    |j@                  d'i |}	t         jJ                  jY                          |	jE                  t         jJ                  j6                         y # t,        $ r} |t        |             Y d }~Cd }~ww xY w# 1 sw Y   y xY w)(N   qrcode )usageversionmsgreturnc                 (    j                  |         N)error)r   parsers    S/var/www/django_project/virt/lib/python3.12/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   |xx|x(G""'-R)>)>)@'RF   ++12C+D*EQH   ():(;1=   A   ',,./2   A,      ""4(JD$||"&&t||T\\B	 '/M 	)$*?*?@#
B
 Aw{{"3{4yy$$&}}
D
D4==1{{mmo$++t$ 	HHSM	 	  bii

0A0A0C&D

NN4::~N.+2.,
 IJ""'1**+ ,!!' 13 )00C0C(D%J&0&A=&AF?#bmm%f%

""#]  	 A	 ,	 	s$   )N O	N?#N::N?Or_   r   c                     d| vrt        d      | j                  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      sI    
&FGG==a(LFD
VRdV
,C3r$   c                  H   i } t         j                         D ]U  \  }}	 t        |      }t	        |dd       }|s"| j                  t        |      t                     }|j                  |       W dj                  d | j                         D              S # t        $ r Y w xY w)Nr4   z. c              3   F   K   | ]  \  }}d t        |d       d|   yw)zFor andz, use: N)r?   ).0rf   	factoriess      r"   	<genexpr>z"get_drawer_help.<locals>.<genexpr>   s1      GY vi'(y9s   !)
r@   itemsrH   ImportErrorrZ   
setdefaultr?   setaddjoin)r&   aliasr_   imagerf   rs   s         r"   rA   rA      s    D*002 	v	'E ,35:JD+QOOF7OSU;	e	 99 "&**,    		s   B	B! B!ru   c                     t        |       } | syt        |       dk(  r| d   S dj                  | d d        d| d| d    S )Nr   r   r   z,  )tuplelenrz   )ru   joiners     r"   r?   r?      sP    %LE
5zQQxiicr
#$AfXQuRyk::r$   __main__r   )or)!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 <<,-HMMO ')&7/1  
												 b$J Y  &;(3- ; ; zF r$   