
    Pf<                        d Z ddlZddlZddlZddlZddlmZ i Zd Zej        	                                D ]W\  Z
Z e ee                    Z	 e                     eej                             n# e$ r Y nw xY w ee          ee
<   X[d Zd ZddZd Zej        d	d         fd
Z G d de          Zedk    r e             dS dS )zCommand line script to generate (Micro) QR codes with Segno.

"QR Code" and "Micro QR Code" are registered trademarks of DENSO WAVE INCORPORATED.
    N)writersc                 r    | j         }|j        d |j                 }|t          | j                   d          S N)__code__co_varnamesco_argcountlen__defaults__)func	func_codeargss      ;/var/www/html/env/lib/python3.11/site-packages/segno/cli.py	_get_argsr      s>    I !7)"7!78DT&'''(())    c            	      
   d } t          j        dd                    t          j                            }|                    dddd	           |                    d
ddddd            |                    dddddd            |                    ddd           |                    dddd           |                    dddd            |                    d!d"d#ddt          $           |                    d%d&d'd            |                    d(d)d*d           |                    d+d,d-dt          .           |                    d/d0d1dt          .           |                    d2d3d4d5| .           |                    d6d7d8d	           |                    d9d:          }|                    d;d<=           |                    d>d?=           |                    d@dA=           |                    dBdC=           |                    dDdE=           |                    dFdG=           |                    dHdI=           |                    dJdK=           |                    dLdM=           |                    dNdOdPQ           |                    dRdSdTQ           |                    dUdV=           |                    dWdX=           |                    dYdZ=           |                    d[d\=           |                    d]d^=           |                    d_d`=           |                    dadb          }|                    dcddde           |                    dfdgdhd            |                    didjdkd            |                    dldmdnd            |                    dodp=           |                    dqdr=           |                    dsdt=           |                    dudv=           |                    dwdx=           |                    dydzd{d           |                    d|d}=           |                    d~dt                     |                    ddd           |                    ddde           |                    dd          }|                    ddt                     |                    dd          }|                    ddde           |	                                                    ddddd                    t          j                             |                    ddd           |S )z)    Returns the command line parser.
    c                 h    t          |           } | t          |           k    r| nt          |           S r   )floatint)vals    r   _convert_scalez#make_parser.<locals>._convert_scale/   s+    CjjSXXooss3s883r   segnoz5Segno QR Code and Micro QR Code generator version {0})progdescriptionz	--versionz-vz:(Micro) QR Code version: 1 .. 40 or "M1", "M2", "M3", "M4"F)helprequiredz--errorz-ez{Error correction level: "L": 7%% (default), "M": 15%%, "Q": 25%%, "H": 30%%, "-": no error correction (used for M1 symbols))LMQH-Nc                 *    |                                  S r   )upperxs    r   <lambda>zmake_parser.<locals>.<lambda><       qwwyy r   )r   choicesdefaulttypez--modez-mzNMode. If unspecified (default), an optimal mode is chosen for the given input.)numericalphanumericbytekanjihanzic                 *    |                                  S r   )lowerr#   s    r   r%   zmake_parser.<locals>.<lambda>A   r&   r   z
--encodingzSSets the encoding of the input. If not set (default), a minimal encoding is chosen.)r   r(   z--microz$Allow the creation of Micro QR Codesmicro
store_true)r   destactionz
--no-microz-Disallow creation of Micro QR Codes (default)store_falsez	--patternz-pzMask pattern to use. If unspecified (default), an optimal mask pattern is used. Valid values for QR Codes: 0 .. 7. Valid values for Micro QR Codes: 0 .. 3)r   r   r(   r)   z--no-error-boostzDisables the automatic error correction level incrementation. By default, the maximal error correction level is used (without changing the version).boost_errorz--seqzaCreates a sequence of QR Codes (Structured Append mode). Version or symbol count must be providedseqz--symbol-countz-sczNumber of symbols to create)r   r(   r)   z--borderz-bzSize of the border / quiet zone of the output. By default, the standard border (4 modules for QR Codes, 2 modules for Micro QR Codes) will be used. A value of 0 omits the borderz--scalez-szScaling factor. By default, a scaling factor of 1 is used. That may lead into too small images. Some output formats, i.e. SVG, accept a decimal value.   z--outputz-ozEOutput file. If not specified, the QR Code is printed to the terminalzModule ColorszArguments to specify the module colors. Multiple colors are supported for SVG and PNG. The module color support varies between the serialization formats. Most serializers support at least "--dark" and "--light". Unsupported arguments are ignored.z--darka@  Color of the dark modules. The color may be specified as web color name, i.e. "red" or as hexadecimal value, i.e. "#0033cc". Some serializers, i.e. SVG and PNG, support alpha channels (8-digit hexadecimal value) and some support "transparent" / "trans" as color value for alpha transparency. The standard color is black.)r   z--lightzoColor of the light modules. See "dark" for a description of possible values. The standard light color is white.z--finder-darkz)Sets the color of the dark finder modulesz--finder-lightz*Sets the color of the light finder modulesz--separatorz'Sets the color of the separator modulesz--data-darkz'Sets the color of the dark data modulesz--data-lightz(Sets the color of the light data modulesz--timing-darkz)Sets the color of the dark timing modulesz--timing-lightz*Sets the color of the light timing modulesz--align-darkz,Sets the color of the dark alignment modulesalignment_dark)r   r3   z--align-lightz-Sets the color of the light alignment modulesalignment_lightz--quiet-zonez)Sets the color of the quiet zone (border)z--dark-modulez!Sets the color of the dark modulez--format-darkz5Sets the color of the dark format information modulesz--format-lightz6Sets the color of the light format information modulesz--version-darkz6Sets the color of the dark version information modulesz--version-lightz7Sets the color of the light version information modulesSVGzSVG specific optionsz--no-classeszOmits the (default) SVG classes)r   r4   z--no-xmldeclz Omits the XML declaration headerxmldeclz--no-namespacezHIndicates that the SVG document should have no SVG namespace declarationsvgnsz--no-newlinez?Indicates that the SVG document should have no trailing newlinenlz--titlez'Specifies the title of the SVG documentz--descz-Specifies the description of the SVG documentz--svgidz&Indicates the ID of the <svg/> elementz
--svgclasszSIndicates the CSS class of the <svg/> element. An empty string omits the attribute.z--lineclasszUIndicates the CSS class of the <path/> elements. An empty string omits the attribute.z	--no-sizezOIndicates that the SVG document should not have "width" and "height" attributesomitsizez--unitz$Indicates SVG coordinate system unitz--svgversionzIndicates the SVG version)r   r)   z--svgencodingz&Specifies the encoding of the documentutf-8z--draw-transparentz0Indicates that transparent paths should be drawnPNGzPNG specific optionsz--dpiz"Sets the DPI value of the PNG fileTerminalzTerminal specific optionsz	--compactzEIndicates that the QR code should be printed in a more compact mannerz--verz-VzShows Segno's versionversionz	Segno {0})r   r4   rC   content+zThe content to encode)nargsr   )
argparseArgumentParserformatr   __version__add_argumentr   add_argument_groupr   add_mutually_exclusive_group)r   parsercolor_group	svg_group	png_groupterminal_groups         r   make_parserrS   *   s   
4 4 4 $'1h&,fU->&?&?A A AF T0l!&  ) ) )
	4 /j 9 $00	  2 2 2
 $ .6 U $00	  2 2 2
  ,a $  & & & 	(N$\  ; ; ;
+Z$]  < < <
T 1Z "' $   " " " * 2S +=  B B B  'Q"<  9 9 9 (%6S $   " " " 
D 0O !%   " " " 	4 /g !"+	  - - -
 
D/v!&  ( ( ( ++O >b c cK X -K L L L Y .R S S S _3^___-4`aaa]1Z[[[]1Z[[[^2\]]]_3^___-4`aaa^2`"2  6 6 6_3b"3  7 7 7^2]^^^_3VWWW_3jkkk-4lmmm-4lmmm.5nooo ))%1GHHI>0Q".  0 0 0>0R )"/  1 1 1 + 3@ '"/  1 1 1 >0q $"/  1 1 1 9+TUUU8*YZZZ9+STTT< /U V V V= 0V W W W; .: *".  0 0 0 8*PQQQ>0K %  ' ' '?1Y#*  , , ,/6h".  0 0 0 ))%1GHHI7)M #  % % % ..z;VWWN2y'3   5 5 5 ''))66wKb>G?J?Q?QRWRc?d?d 7 f f f 	3JKKKMr   c                    t                      }t          |           s(|                                 t          j        d           |                    |           }|j        dk    rd|_        |j        }|!t          |          	                                }|j
        s|dv rd|_
        t          t          |                    S )z5    Parses the arguments and returns the result.
    r8   r    N)M1M2M3M4)rS   r	   
print_helpsysexit
parse_argserrorrC   strr"   r1   	_AttrDictvars)r   rN   parsed_argsrC   s       r   parserb      s     ]]Ft99 ##D))KC  !Gg,,$$&& !,D!D!D T+&&'''r   c                     dD ])}                      |d          }|dv rd |<   "|r| |<   *dD ].}                     |d                                |d           /                      dd          r
d d<   d d<                         d	d
           d<   |d||                    d          dz   d                                         }|dk    rd}t                              |d           fd D               S )a      Builds a configuration and returns it.

    The config contains only keywords which are supported by the serializer.
    Unsupported values are removed.

    :param dict config: The configuration / dict returned by the :py:func:`parse` function.
    :param filename: Optional filename. If not ``None`` (default), the `filename`
                     must provide a supported extension to identify the serializer.
    :return: A (maybe) modified configuration.
    )darklightfinder_darkfinder_lightformat_darkformat_lightr9   r:   timing_darktiming_light	data_dark
data_lightversion_darkversion_light
quiet_zonedark_module	separatorN)transparenttrans)svgidsvgclass	lineclass
no_classesFrv   rw   svgencodingr@   encoding.r8   svgzsvg c                 *    i | ]}|v ||         S r~   r~   ).0kconfigsupported_argss     r   
<dictcomp>z build_config.<locals>.<dictcomp>   s)    FFF1!~2E2E!VAY2E2E2Er   )popgetrfindr0   _EXT_TO_KW_MAPPING)r   filenameclrr   nameextr   s   `     @r   build_configr      sG    : 	 	
 jjd##***F3KK 	F3K2 # #::dD!!)JJtT"""zz,&& #!z"{M7;;F:x~~c**Q.//06688&==C+//R88 GFFFFFFFMr   c           
      *   t           j        }t          |                     d          |                     d          |                     d          |                     d          |                     d          |                     d                    }|                     d          r%t           j        }|                     d	          |d	<   n|                     d
          |d
<    |d                    |                     d                    fi |S )aA      Creates the (Micro) QR Code (Sequence).

    Configuration parameters used for creating the Micro QR Code, QR Code
    or QR Code Sequence are removed from the configuration.

    :param config: Configuration, see :py:func:`build_config`
    :return: :py:class:`segno.QRCode` or :py:class:`segno.QRCodeSequence`.
    moder]   rC   patternrz   r6   )r   r]   rC   maskrz   r6   r7   symbol_countr1    rD   )r   makedictr   make_sequencejoin)r   r   kws      r   	make_coder      s     :D	6::f%%VZZ-@-@jj++&**Y2G2Gzz*-- **]33
5 
5 
5B zz% *"#ZZ77>jj))74I..//662666r   r8   c                    t          |           }	 t          |          }nc# t          $ rV}t          j                            t          |          t          j        g           t          j	        d          cY d }~S d }~ww xY w|
                    d          }|2|                    |d         |                    dd                     n |j        |fi t          ||           dS )	Nr8   outputbordercompactF)r   r   )r   r   )rb   r   
ValueErrorrZ   stderr
writelinesr^   oslinesepr[   r   terminalr   saver   )r   r   qrexr   s        r   mainr     s    4[[Fv   
s2ww
3444x{{ ZZ!!F~
6(+VZZ	55Q5QRRRR@@,v???@@@1s   ! 
BAA<6B<Bc                   "     e Zd ZdZ fdZ xZS )r_   z    Internal helper class.
    c                 V     t          t          |           j        |i | | | _        d S r   )superr_   __init____dict__)selfr   kwargs	__class__s      r   r   z_AttrDict.__init__(  s0    'i'8888r   )__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r_   r_   $  sB                 r   r_   __main__r   )r   r   rZ   rG   r   r   r   r   _VALID_SERIALIZERSitemsr   r   setkwsupdate__wrapped__AttributeError	frozensetrS   rb   r   r   argvr   r   r_   r   r~   r   r   <module>r      s   
 
			 



          * * * +1133 - -IC
#iioo

C

99T-..////   'innsM M M`( ( (,+ + + +\7 7 7. hqrrl            zDFFFFF s   #A55A=<A=