
    )c                        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                  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        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)	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  } ddlm}  |d      j                  }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 }t1        j2                  t"        |j"                           }| r| d   }	|	j5                  d       }	n(t         j6                  j8                  j;                         }	|j<                  |j?                  |	       n|j?                  |	|j<                  !       |j@                  rA|jC                         }
tE        |j@                  d"      5 }|
jG                  |       d d d        y |[tI        jJ                  t         jL                  jO                               s|jP                  r|jS                  |jP                   #       y i }tU        |jV                  d$d       }|jX                  rU|s |d%       |jX                  |vr  ||jX                   d&t        |              ||jX                     \  }} |d(i ||d'<    |jB                  d(i |}
t         jL                  j[                          |
jG                  t         jL                  j8                         y # t.        $ r} |t        |             Y d }~Cd }~ww xY w# 1 sw Y   y xY w))N   r   )get_distributionqrcode )usageversionmsgreturnc                 (    j                  |         N)error)r   parsers    8/usr/lib/python3/dist-packages/qrcode/console_scripts.pyraise_errorzmain.<locals>.raise_error1   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_factorysurrogateescape)errors)optimizewb)ttydrawer_aliasesz+The selected factory has no drawer aliases.z$ factory drawer not found. Expected module_drawer ).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readr1   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!   s                   @r"   mainrj   (   s   |xx|.x(00G""'-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	O&N==O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   )rJ   rsplit
__import__r[   )r`   nameimps      r"   rI   rI      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@   ).0rg   	factoriess      r"   	<genexpr>z"get_drawer_help.<locals>.<genexpr>   s1      GY vi'(y9s   !)
rA   itemsrI   ImportErrorr[   
setdefaultr@   setaddjoin)r&   aliasr`   imagerg   rt   s         r"   rB   rB      s    D*002 	v	'E ,35:JD+QOOF7OSU;	e	 99 "&**,    		s   B	B! B!rv   c                     t        |       } | syt        |       dk(  r| d   S dj                  | d d        d| d| d    S )Nr   r   r   z,  )tuplelenr{   )rv   joiners     r"   r@   r@      sP    %LE
5zQQxiicr
#$AfXQuRyk::r$   __main__r   )or)r<   r:   rU   r7   typingr   r   r   r   r   r   r   qrcode.image.baser	   r
   platform
startswithcoloramainitrA   ERROR_CORRECT_LERROR_CORRECT_MERROR_CORRECT_QERROR_CORRECT_Hr-   rj   r>   rI   rB   r@   __name__r6   r$   r"   <module>r      s     	 
 @ @  6 <<,-HMMO ')&7/1  
												 c$L Y  &;(3- ; ; zF r$   