bgE dZddlZddlZddlZddlZddlmZmZddlm Z m Z dZ ej de dZ ej d e d e d Zed d ZGddZdZdejDZdZdZGddZedkrGdZdD]DZedezedeeeeCdSdS)a6distutils.fancy_getopt Wrapper around the standard getopt module that provides the following additional features: * short and long options are tied together * options have help strings, so fancy_getopt could potentially create a complete usage summary * options set attributes of a passed-in object N)AnySequence)DistutilsArgErrorDistutilsGetoptErrorz[a-zA-Z](?:[a-zA-Z0-9-]*)^$z^(z)=!(z)$-_cpeZdZdZddZdZdZddZdZdZ d Z d Z d Z d Z dd ZdZddZddZdS) FancyGetoptaWrapper around the standard 'getopt()' module that provides some handy extra functionality: * short and long options are tied together * options have help strings, and help text can be assembled from them * options set attributes of a passed-in object * boolean options can have "negative aliases" -- eg. if --quiet is the "negative alias" of --verbose, then "--quiet" on the command line sets 'verbose' to false Nc||_i|_|jr|i|_i|_g|_g|_i|_i|_i|_ g|_ dSN) option_table option_index _build_indexaliasnegative_alias short_opts long_opts short2long attr_name takes_arg option_orderselfrs Y/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/fancy_getopt.py__init__zFancyGetopt.__init__.s{)         !  cl|j|jD]}||j|d<dS)Nr)rclearr)roptions rrzFancyGetopt._build_indexVsG !!!' 2 2F+1D fQi ( ( 2 2rc<||_|dSr)rrrs rset_option_tablezFancyGetopt.set_option_table[s"( rc||jvrtd|d|||f}|j|||j|<dS)Nz$option conflict: already an option '')rrrappend)r long_option short_option help_stringr"s r add_optionzFancyGetopt.add_option_sh $+ + +&E{EEE "<=F   $ $V , , ,-3D k * * *rc||jvS)zcReturn true if the option table for this parser has an option with long name 'long_option'.)rrr(s r has_optionzFancyGetopt.has_optionisd///rc6|tS)zTranslate long option name 'long_option' to the form it has as an attribute of some object: ie., translate hyphens to underscores. translate longopt_xlater-s r get_attr_namezFancyGetopt.get_attr_namens$$]333rc t|tsJ|D]I\}}||jvrt d|d|d|d||jvrt d|d|d|dJdS)Nzinvalid z 'z ': option 'z ' not defined': aliased option ') isinstancedictitemsrr)raliaseswhatropts r_check_alias_dictzFancyGetopt._check_alias_dictts'4(((((!--//  JE3D---*MtMMuMMMMM$+++*StSSuSSSSS,   rc@||d||_dS)z'Set the aliases for this option parser.rN)r<r)rrs r set_aliaseszFancyGetopt.set_aliasess# ug... rc@||d||_dS)zSet the negative aliases for this option parser. 'negative_alias' should be a dictionary mapping option names to option names, both the key and value must already be defined in the option table.znegative aliasN)r<r)rrs rset_negative_aliasesz FancyGetopt.set_negative_aliasess) ~/?@@@,rcg|_g|_|ji|_|jD]'}t |dkr |\}}}d}n-t |dkr|\}}}}ntd|t|trt |dkrtd|d|;t|trt |d kstd |d ||j|<|j ||d d kr|r|dz}|dd }d|j |<nS|j |}|-|j |rtd|d|d||jd <d|j |<|j|}|2|j ||j |krtd|d|dt |std|d|||j|<|r*|j |||j|d<)dS)zPopulate the various data structures that keep tabs on the option table. Called by 'getopt()' before it can do anything worthwhile. rzinvalid option tuple: zinvalid long option 'z"': must be a string of length >= 2Nrzinvalid short option 'z"': must a single character or None=:Tzinvalid negative alias 'r5z' takes a valueFzinvalid alias 'z%': inconsistent with aliased option 'z/' (one of them takes a value, the other doesn'tzinvalid long option name 'z)' (must be letters, numbers, hyphens only)rrrr!repeatrlen ValueErrorr6strrr'rrgetr longopt_rematchr3r)rr"longshorthelprHalias_tos r_grok_option_tablezFancyGetopt._grok_option_tables   'E 1E 1F6{{a$*!eTV!!,2)eT66!!D&!D!DEEEdC(( CIIMM*TDTTT] 5#(>(>]3u::QR??*6U666 !'DK  N ! !$ ' ' 'Bx3(!CKEAbDz'+t$$ .22488'~h/2ItII/7III *.DN2&',t$z~~d++H#>$'4>(+CCC.,$,,+3,,,##D)) *>>>> $(#5#5d#;#;DN4  1&&u---,0a)KE 1E 1rc|tjdd}|t}d}nd}|d|j} t j|||j\}}n&#t j$r}t|d}~wwxYw|D].\}}t|dkr |ddkr|j |d}n-t|dkr|ddd ksJ|dd}|j |} | r| }|j|s3|d ks Jd |j |} | r| }d}nd}|j|} |r.|j | t%|| ddz}t'|| ||j||f0|r||fS|S) aParse command-line options in args. Store as attributes on object. If 'args' is None or not supplied, uses 'sys.argv[1:]'. If 'object' is None or not supplied, creates a new OptionDummy object, stores option values there, and returns a tuple (args, object). If 'object' is supplied, it is modified in place and 'getopt()' just returns 'args'; in both cases, the returned 'args' is a modified copy of the passed-in 'args' list, which is left untouched. NrTF rDrr z--zboolean option can't have value)sysargv OptionDummyrSjoinrgetoptrerrorrrIrrrLrrrrHgetattrsetattrrr') rargsobjectcreated_objectroptsmsgr;valrattrs rr[zFancyGetopt.getopts <8ABB ]]F!NN"N !!!XXdo..  )tZHHJD$$| ) ) )#C(( ( ) 1 1HC3xx1}}Q3oc!f-3xx!||BQB47!""gJNN3''E >#& byyy"Cyyy+//44CCCC>#&D 3t{t,,8fdA..2 FD# & & &   $ $c3Z 0 0 0 0  < KsA::B BBc<|jtd|jS)zReturns the list of (option, value) tuples processed by the previous run of 'getopt()'. Raises RuntimeError if 'getopt()' hasn't been called yet. Nz!'getopt()' hasn't been called yet)r RuntimeError)rs rget_option_orderzFancyGetopt.get_option_orders%   $BCC C$ $rcd}|jD]A}|d}|d}t|}|ddkr|dz }||dz}||kr|}B|dzdzdz}d}||z } d |z} |r|g} nd g} |jD]}|dd \}}} t| | } |ddkr |dd}|?| r"| d ||| dfzn_| d ||fznD|d|d}| r"| d ||| dfzn| d|z| ddD]}| | |z| S)zGenerate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object. rrrErFNrDNrUzOption summary:rBz --%-*s %sz --%-*s z (-)z --%-*s)rrI wrap_textr')rheadermax_optr"rOrPell opt_width line_width text_width big_indentlinesrQtext opt_namess r generate_helpzFancyGetopt.generate_help%s'  F!9D1IEd))CBx3Ag AgW}}aK!Oa' 0 )+ 9_  (HEE&'E' / /F &rr D%T:..DBx3AbDz}ALL7D$q'2J!JKKKKLL$!?@@@@ $00000 9LL7ItAw2O!OPPPPLLi!7888ABBx / / Z#-.... / rc| tj}||D]}||dzdS)N )rWstdoutrxwrite)rrnfilelines r print_helpzFancyGetopt.print_helpssN <:D&&v.. $ $D JJtd{ # # # # $ $rr)NN)__name__ __module__ __qualname____doc__rrr$r+r.r3r<r>r@rSr[rhrxrrrr r "s  &&&&P222 4444000 444    ---O1O1O1b;;;;z%%%LLLL\$$$$$$rr cvt|}|||||Sr)r r@r[)options negative_optr`r_parsers r fancy_getoptrzs7  ! !F  --- ==v & &&rc.i|]}t|dS)rU)ord).0_wschars r rs ? ? ?'CLL# ? ? ?rc|gSt||kr|gS|}|t}t jd|}d|D}g}|rg}d}|r\t|d}||z|kr$||d|d=||z}n|r|dddkr|d=n|\|rQ|dkr6||dd||d|d|d<|dddkr|d=|d|||S)zwrap_text(text : string, width : int) -> [string] Split 'text' into multiple lines of no more than 'width' characters each, and return the list of strings that results. Nz( +|-+)cg|]}||Srr)rchs r zwrap_text..s ( ( (RR (b ( ( (rrrErUrV)rI expandtabsr1WS_TRANSresplitr'rZ)rvwidthchunksrucur_linecur_lenrps rrmrms  |  4yyEv ??  D >>( # #D Xj$ ' 'F ( (6 ( ( (F E  ( fQi..C}%%q ***1I!C-% Q3 6 6     !||q !E' 2333"1Ieff-q ay|s""1I  RWWX&&'''A  (D Lrc6|tS)zXConvert a long option name to a valid Python identifier by changing "-" to "_". r0)r;s rtranslate_longoptrs == ' ''rc.eZdZdZgfdeefdZdS)rYz_Dummy class just used as a place to hold command-line option values as instance attributes.rc2|D]}t||ddS)zkCreate a new OptionDummy instance. The attributes listed in 'options' will be initialized to None.N)r^)rrr;s rrzOptionDummy.__init__s2 % %C D#t $ $ $ $ % %rN)rrrrrrrrrrrYrYsG&&13%% %%%%%%rrY__main__zTra-la-la, supercalifragilisticexpialidocious. How *do* you spell that odd word, anyways? (Someone ask Mary -- she'll know [or she'll say, "How should I know?"].)) (z width: %drz)rr[rstringrWtypingrrerrorsrr longopt_patcompilerM neg_alias_rerK maketransr2r r whitespacerrmrrYrrvwprintrZrrrrs ;;;;;;;; + RZ+[+++ , , rz?{?? ???@@  c3'' U$U$U$U$U$U$U$U$p ''' @ ?V-> ? ? ?333l(((%%%%%%%% z D  kAo dii $**++,,, r