Qf@dZgdZddlZ ddlmZGddeZeZgfdZ gfd Z d Z d Z d Z d Zedk(r$ddlZee ej$dddddgyy#e$rdZYWwxYw)aParser for command line options. This module helps scripts to parse the command line arguments in sys.argv. It supports the same conventions as the Unix getopt() function (including the special meanings of arguments of the form `-' and `--'). Long options similar to those supported by GNU software may be used as well via an optional third argument. This module provides two functions and an exception: getopt() -- Parse command line options gnu_getopt() -- Like getopt(), but allow option and non-option arguments to be intermixed. GetoptError -- exception (class) raised with 'opt' attribute, which is the option involved with the exception. ) GetoptErrorerrorgetopt gnu_getoptN)gettextc|SN)ss -/opt/alt/python312/lib64/python3.12/getopt.py_r )sQhc"eZdZdZdZddZdZy)rcN||_||_tj|||yr )msgopt Exception__init__)selfrrs r rzGetoptError.__init__.s"4c*rc|jSr )r)rs r __str__zGetoptError.__str__3s xxrN)r)__name__ __module__ __qualname__rrrrr rr rr+s C C+ rrc|g}t|tr|g}n t|}|r|djdr|ddk7rz|ddk(r |dd} ||fS|djdrt ||ddd||dd\}}nt ||ddd||dd\}}|r|djdr |ddk7rz||fS)a@getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (i.e., the same format that Unix getopt() uses). If specified, longopts is a list of strings with the names of the long options which should be supported. The leading '--' characters should not be included in the option name. Options which require an argument should be followed by an equal sign ('='). The return value consists of two elements: the first is a list of (option, value) pairs; the second is the list of program arguments left after the option list was stripped (this is a trailing slice of the first argument). Each option-and-value pair returned has the option as its first element, prefixed with a hyphen (e.g., '-x'), and the option argument as its second element, or an empty string if the option has no argument. The options occur in the list in the same order in which they were found, thus allowing multiple occurrences. Long and short options may be mixed. r---N) isinstancestrlist startswithdo_longs do_shorts)args shortoptslongoptsoptss r rr8s6 D(C :> 47%%c*tAw#~ 7d?8D  : 7  d #!$Q XtABxHJD$"4aiabJJD$ 47%%c*tAw#~ :rcg}g}t|tr|g}n t|}|jdr|dd}d}n$tj j drd}nd}|r|ddk(r ||ddz } ||fS|ddd dk(rt||dd d||dd\}}nS|dddd k(r#|dd k7rt||ddd||dd\}}n%|r ||z } ||fS|j|d|dd}|r||fS) agetopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is encountered. If the first character of the option string is `+', or if the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered. +rNTPOSIXLY_CORRECTFrrr r) r!r"r#r$osenvirongetr%r&append)r'r(r)r* prog_argsall_options_firsts r rrcsW DI(C :>C abM   ) * !  7d? ab !I  ? 72A;$ !$Q XtABxHJD$ !WRa[C DGsN"4aiabJJD$ T!  ?  a)ABx " ?rcB |jd}|d|||dzd}}t||\}}|r'|?|stt d|z||d|dd}}n|tt d|z||j d|z|xsdf||fS#t$rd}Y}wxYw)N=rzoption --%s requires argumentrz%option --%s must not have an argumentrr)index ValueError long_has_argsrr r1)r*rr)r'ioptarghas_args r r%r%s) IIcN"1gs1Q34yV h/LGS >!!$C"Ds"JCPP7DHDF  !CDsJCPPKKV\r*+ : sB BBc6|Dcgc]}|j|s|}}|sttd|z|||vrd|fS|dz|vrd|fSt|dkDrttd|z||d}|j d}|r|dd}||fScc}w) Nzoption --%s not recognizedFr5Trzoption --%s not a unique prefixr)r$rr lenendswith)rr)o possibilities unique_matchr;s r r8r8s (>1ALL,=QM> !89C?EE mcz sm #Sy =A!=>DcJJ #L##C(G#CR( L  %?s BBc|dk7rb|d|dd}}t||r.|dk(r$|sttd|z||d|dd}}|d}}nd}|jd|z|f|dk7rb||fS)Nrrrzoption -%s requires argumentr) short_has_argrr r1)r* optstringr(r'rr:s r r&r&s r/"1y}Y i (B%a(F&G#&M&)++"&q'484 )2IFF S3Y'( r/ :rctt|D]*}|||cxk(rdk7sn|jd|dzcStt d|z|)N:rzoption -%s not recognized)ranger>r$rr )rr(r9s r rDrDsW 3y> " )A, %# %''QqS1 1# a34s:C @@r__main__rza:bzalpha=beta)__doc____all__r.rr ImportErrorrrrrrr%r8r&rDrsysprintargvr rr rQsB 8 $ )  '))V,.0d,!* A  z &!"ux&8 9:]sAA*)A*