K iE dZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z dZejd ed Zejd ed ed Zej'ddZGddZddZej.Dcic] }e|d c}ZdZdZGddZedk(r:dZdD]2Ze dee djCeeee 4yycc}w)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 ) annotationsN)Sequence)Any)DistutilsArgErrorDistutilsGetoptErrorz[a-zA-Z](?:[a-zA-Z0-9-]*)^$z^(z)=!(z)$-_cpeZdZdZddZdZdZddZdZdZ d Z d Z d Z d Z ddd ZdZddZddZy) 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|ji|_i|_g|_g|_i|_i|_i|_ g|_ yN) option_table option_index _build_indexaliasnegative_alias short_opts long_opts short2long attr_name takes_arg option_orderselfrs h/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/setuptools/_distutils/fancy_getopt.py__init__zFancyGetopt.__init__1sm)        !  c~|jj|jD]}||j|d<y)Nr)rclearr)roptions rrzFancyGetopt._build_indexYs= !'' 2F+1D  fQi ( 2r c2||_|jyr)rrrs rset_option_tablezFancyGetopt.set_option_table^s( r c||jvrtd|d|||f}|jj|||j|<y)Nz$option conflict: already an option '')rrrappend)r long_option short_option help_stringr#s r add_optionzFancyGetopt.add_optionbs[ $++ +&6{m1E "<=F    $ $V ,-3D  k *r c||jvS)zcReturn true if the option table for this parser has an option with long name 'long_option'.)rrr)s r has_optionzFancyGetopt.has_optionlsd////r c,|jtS)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_nameqs$$]33r c t|tsJ|jD]K\}}||jvrt d|d|d|d||jvs8t d|d|d|dy)Nzinvalid z 'z ': option 'z ' not defined': aliased option ') isinstancedictitemsrr)raliaseswhatropts r_check_alias_dictzFancyGetopt._check_alias_dictws'4(((!--/ JE3D---*tfBug[}M$+++*tfBug-@]S  r c6|j|d||_y)z'Set the aliases for this option parser.rN)r=r)rrs r set_aliaseszFancyGetopt.set_aliasess ug. r c6|j|d||_y)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 ~/?@,r cg|_g|_|jji|_|j D]}t |dk(r |\}}}d}n$t |dk(r|\}}}}ntd|t|trt |dkrtd|d|-t|trt |d k(std |d ||j|<|jj||d d k(r|r|dz}|dd }d|j|<n\|jj|}|0|j|rtd|d|d||jd <d|j|<|jj|}|1|j||j|k7rtd|d|dt j#|std|d|j%||j&|<|s|jj|||j|d<y)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 'r6z' 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 ValueErrorr7strrr(rrgetr longopt_rematchr4r)rr#longshorthelprIalias_tos r_grok_option_tablezFancyGetopt._grok_option_tables~   ''D 1F6{a$*!eTV!,2)eT6!#9&!DEEdC(CIM*+D61ST] 5#(>3u:QR?*,UG3UV!'DKK  NN ! !$ 'Bx3!CKEAbz'+t$ ..2248'~~h/26tf=//7jI *.DNN2&',t$zz~~d+H#>>$'4>>(+CC.)$0++3*5,,##D)*07>> $(#5#5d#;DNN4 &&u-,0a)ID 1r cv|tjdd}| t}d}nd}|jdj |j } t j |||j\}}|D]\}}t|dk(r|ddk(r|j|d}nt|dkDr|ddd k(sJ|dd}|jj|} | r| }|j|s0|d k(sJd |jj|} | r| }d}nd}|j |} |r+|j"j| t%|| ddz}t'|| ||j(j+||f|r||fS|S#t j$r}t|d}~wwxYw) 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 rErr z--zboolean option can't have value)sysargv OptionDummyrTjoinrgetoptrerrorrrJrrrMrrrrIgetattrsetattrrr() rargsobjectcreated_objectroptsmsgr<valrattrs rr\zFancyGetopt.getopts <88AB ]F!N"N !XXdoo.  )tZHJD$ 1HC3x1}Q3ooc!f-3x!|BQ477!"gJJNN3'E>>#&byC"CCy++//4CCC>>#&Dt{{t,8fdA.2 FD# &    $ $c3Z 05 1: < KG|| )#C( ( )s$FF8( F33F8cH|j td|jS)zReturns the list of (option, value) tuples processed by the previous run of 'getopt()'. Raises RuntimeError if 'getopt()' hasn't been called yet. z!'getopt()' hasn't been called yet)r RuntimeError)rs rget_option_orderzFancyGetopt.get_option_orders(    $BC C$$ $r crd}|jD]3}|d}|d}t|}|ddk(r|dz }||dz}||kDs2|}5|dzdzdz}d}||z } d |z} |r|g} nd g} |jD]}|dd \}}} t| | } |ddk(r|dd}|<| r | jd |d |dd| dn]| jd |d |dnC|d|d}| r | jd |d |dd| dn| jd |d |d| ddD]}| j| |z| S)zGenerate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object. rrrFrGNrENrVzOption summary:rCz --?ABx / Z#-. /- /0 r c||tj}|j|D]}|j|dzy)N )rXstdoutrzwrite)rrpfilelines r print_helpzFancyGetopt.print_helpus: <::D&&v. $D JJtd{ # $r r)NNr`zSequence[str] | None)__name__ __module__ __qualname____doc__rrr%r,r/r4r=r?rArTr\rirzrr rrr%sS &P2 40 4  -N1`;z%L\$r rc^t|}|j||j||Sr)rrAr\)options negative_optrar`parsers r fancy_getoptr|s+  !F  - ==v &&r rVc*|gSt||kr|gS|j}|jt}t j d|}|Dcgc]}|s| }}g}|rg}d}|rGt|d}||z|kr|j |d|d=||z}n|r|dddk(r|d=n|rG|r5|dk(r"|j |dd||d|d|d<|dddk(r|d=|j dj||r|Scc}w)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( +|-+)rrFrVrW)rJ expandtabsr2WS_TRANSresplitr(r[)rxwidthchunkschrwcur_linecur_lenrrs rrorosN  |  4yEv ?? D >>( #D XXj$ 'F! (RRb (F ( E fQi.C}%q *1I!C- Q3 6   !|q !E 23"1Ief-q ay|s"1I  RWWX&'A D LK)s DDc,|jtS)zXConvert a long option name to a valid Python identifier by changing "-" to "_". r1)r<s rtranslate_longoptrs == ''r ceZdZdZgfddZy)rZz_Dummy class just used as a place to hold command-line option values as instance attributes.c,|D]}t||dy)zkCreate a new OptionDummy instance. The attributes listed in 'options' will be initialized to None.N)r_)rrr<s rrzOptionDummy.__init__s %C D#t $ %r N)rz Sequence[Any])rrrrrrr rrZrZs&13%r rZ__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?"].)) (zwidth: r|r)"r __future__rr\rstringrXcollections.abcrtypingrerrorsrr longopt_patcompilerN neg_alias_rerL maketransr3rr whitespaceordrrorrZrrxwprintr[)_wschars0rrs# $; + RZZ1[M+ , rzzB{m4 }B?@  c3' T$T$n ' .4->-> ?'CL#  ?3l(%% z D  sm dii $*+, W @s C/