Ij+BdZddlZddlZddlmZddlmZddlmZm Z ddl m Z m Z m Z ddlmZmZdd lmZd ed efd Zd ejfd Zdeed eefdZdededed efdZdde eed efdZedkrejedSdS)z{Command-line interface for the :mod:`idna` package. Invoked via ``python -m idna``. See :func:`main` for the entry point. N)Iterable)chain)IOOptional) IDNAErrordecodeencode)_alabel_prefix_unicode_dots_re) __version__sreturnctjdtfdtj|DS)zBReturn True if any label in ``s`` carries the ``xn--`` ACE prefix.asciic3fK|]+}|V,dSN)lower startswith).0labelprefixs `/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/idna/cli.py z%_looks_like_alabel..s9WWEu{{}}''//WWWWWW)r r anyr split)rrs @r_looks_like_alabelrsC  "7 + +F WWWW=M=STU=V=VWWW W WWrcftjdd}|}|dddddd |d d ddd d |ddd|dddt|ddd|S)Nzpython -m idnauConvert a domain name between its Unicode (U-label) and ASCII-compatible (A-label) forms. With no mode flag, the direction is chosen from the first input — if it contains an xn-- label the stream is decoded, otherwise it is encoded — and the same mode is applied to every remaining input. UTS #46 mapping is applied by default; pass --strict to disable it. When no domains are given on the command line and stdin is piped, one domain per line is read from stdin.)prog descriptionz-ez--encodemode store_constr z+Encode the input to its ASCII A-label form.)destactionconsthelpz-dz--decoder z-Decode the input from its ASCII A-label form.z--strict store_truezGDisable the default UTS #46 mapping and apply IDNA 2008 rules verbatim.)r%r'z --versionversionzidna )r%r)domain*z=One or more domain names to convert. Omit to read from stdin.)nargsr')argparseArgumentParseradd_mutually_exclusive_group add_argumentr )parserr"s r _build_parserr2s  $     F  . . 0 0D   :     <   V  % %%   L Mrstreamc#HK|D]}|}|r|VdS)z@Yield non-empty stripped lines from ``stream``, ignoring blanks.N)strip)r3linestrippeds r _iter_stdinr8Is>::<<  NNNrr*r"uts46c . |dkrtt||n1tt||dn<#t$r/}td|d|d|tjYd}~d Sd}~wwxYwd S) zEConvert ``domain`` and write the result; return ``False`` on failure.r )r9rzidna: z failed for z: )fileNFT)printr r rsysstderr)r*r"r9errs r _convert_oner@Qs 8   &u--- . . . . &u---44W== > > >  :t::::S::LLLLuuuuu 4sAA B#$B  Bargvct}||}|j |jr|j}nMtjsttj}n|dt|}t|d}|dS|j pt|rdndfdt|g|D}t|rdndS)aEntry point for ``python -m idna``. When more than one domain is supplied (via positional arguments or piped stdin) and no mode flag is given, the first input determines the direction and that mode is applied uniformly to the rest. :param argv: Argument list excluding the program name. Defaults to :data:`sys.argv` when ``None``. :returns: ``0`` on success, ``1`` if any conversion fails. z6a domain argument is required when stdin is a terminalNrr r c2g|]}t|S)r@)rr*r"r9s r zmain..{s%XXXV|FD%00XXXrr)r2 parse_argsstrictr*r=stdinisattyr8erroriternextr"rrall) rAr1argsdomainsiteratorfirstresultsr"r9s @@rmainrS^s__F   T " "D OE {O!% Y    Oci(( MNNNG}}H 4 E }q 9 M%7%>%>LHDXXXXXueWh?W?WXXXGG #11!#r__main__r)__doc__r-r=collections.abcr itertoolsrtypingrrrr r corer r package_datar strboolrr.r2r8r@listintrS__name__exitrDrrrbs  $$$$$$''''''''''22222222%%%%%%X#X$XXXX /x.////d3HSM  C      $$xS "$c$$$$B z CHTTVVr