QfdZdZgdZdZddlZddlZddlZdZ ddlmZm Z eZ Gd d e Z Gd d e ZGddeZGdde ZGdde ZGddeZGddZGddeZGddeZdZdZee dfee dfee dfee d fd!Zd"Zd#Zd$ZGd%d&Zd'Zd(Z Gd)d*Z!Gd+d,Z"Gd-d.e"Z#Gd/d0e"Z$d1Z%eZ&y#e $r dZd Z YwxYw)2aA powerful, extensible, and easy-to-use option parser. By Greg Ward Originally distributed as Optik. For support, use the optik-users@lists.sourceforge.net mailing list (http://lists.sourceforge.net/lists/listinfo/optik-users). Simple usage example: from optparse import OptionParser parser = OptionParser() parser.add_option("-f", "--file", dest="filename", help="write report to FILE", metavar="FILE") parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status messages to stdout") (options, args) = parser.parse_args() z1.5.3)Option make_option SUPPRESS_HELPSUPPRESS_USAGEValuesOptionContainer OptionGroup OptionParser HelpFormatterIndentedHelpFormatterTitledHelpFormatter OptParseError OptionErrorOptionConflictErrorOptionValueErrorBadOptionError check_choicea" Copyright (c) 2001-2006 Gregory P. Ward. All rights reserved. Copyright (c) 2002-2006 Python Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NcLd|jjt||fzS)Nz<%s at 0x%x: %s>) __class____name__idselfs //opt/alt/python312/lib64/python3.12/optparse.py_reprrOs" !8!8"T(D I II)gettextngettextc|SN)messages rrr\src|dk(r|S|SNr!)singularpluralns rrr_s 6O rceZdZdZdZy)r c||_yr msgrr,s r__init__zOptParseError.__init__hs rc|jSr r+rs r__str__zOptParseError.__str__ks xxrN)r __module__ __qualname__r.r0r!rrr r gs rr ceZdZdZdZdZy)rz] Raised if an Option instance is created with invalid or inconsistent arguments. c2||_t||_yr )r,str option_id)rr,options rr.zOptionError.__init__usVrcj|jrd|jd|jS|jS)Nzoption z: )r6r,rs rr0zOptionError.__str__ys% >>&*nndhh? ?88OrNrr1r2__doc__r.r0r!rrrros %rrceZdZdZy)rzE Raised if conflicting options are added to an OptionParser. Nrr1r2r:r!rrrrsrrceZdZdZy)rzS Raised if an invalid option value is encountered on the command line. Nr<r!rrrrsrrceZdZdZdZdZy)rzB Raised if an invalid option is seen on the command line. c||_yr )opt_strrr@s rr.zBadOptionError.__init__s  rc2td|jzS)Nzno such option: %s)_r@rs rr0zBadOptionError.__str__s%&55rNr9r!rrrrs6rrceZdZdZdZdZy)AmbiguousOptionErrorzD Raised if an ambiguous option is seen on the command line. c>tj||||_yr )rr. possibilities)rr@rGs rr.zAmbiguousOptionError.__init__sg.*rchtd|jdj|jfzS)Nzambiguous option: %s (%s?), )rCr@joinrGrs rr0zAmbiguousOptionError.__str__s2./<<4+=+=!>?@ ArNr9r!rrrErEs+ArrEcneZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZy)r a Abstract base class for formatting option help. OptionParser instances should use one of the HelpFormatter subclasses for formatting help; by default IndentedHelpFormatter is used. Instance attributes: parser : OptionParser the controlling OptionParser instance indent_increment : int the number of columns to indent per nesting level max_help_position : int the maximum starting column for option help text help_position : int the calculated starting column for option help text; initially the same as the maximum width : int total number of columns for output (pass None to constructor for this value to be taken from the $COLUMNS environment variable) level : int current indentation level current_indent : int current indentation level (in columns) help_width : int number of columns available for option help text (calculated) default_tag : str text to replace with each option's default value, "%default" by default. Set to false value to disable default value expansion. option_strings : { Option : str } maps Option instances to the snippet of help text explaining the syntax of that option, e.g. "-h, --help" or "-fFILE, --file=FILE" _short_opt_fmt : str format string controlling how short options with values are printed in help text. Must be either "%s%s" ("-fFILE") or "%s %s" ("-f FILE"), because those are the two syntaxes that Optik supports. _long_opt_fmt : str similar but for long options; must be either "%s %s" ("--file FILE") or "%s=%s" ("--file=FILE"). nonecdd|_||_|" ttjd}|dz}||_t|t|dz |dzx|_ |_ d|_ d|_ d|_||_d|_i|_d|_d|_y#t t f$rd}YwxYw) NCOLUMNSPrz%defaultz%s %sz%s=%s)parserindent_incrementintosenvironKeyError ValueErrorwidthminmax help_positionmax_help_positioncurrent_indentlevel help_width short_first default_tagoption_strings_short_opt_fmt _long_opt_fmtrrSr]rYras rr.zHelpFormatter.__init__s  0 = BJJy12 QJE %s52:7G!7K'LM NT3 &% %$j)  sBB/.B/c||_yr )rRrrRs r set_parserzHelpFormatter.set_parsers  rcB|dvrtd|zd|zdz|_y)N) z/invalid metavar delimiter for short options: %r%s)rXrdrdelims rset_short_opt_delimiterz%HelpFormatter.set_short_opt_delimiters2  !AEIK K"UlT1rcB|dvrtd|zd|zdz|_y)N)=rlz.invalid metavar delimiter for long options: %rrm)rXrerns rset_long_opt_delimiterz$HelpFormatter.set_long_opt_delimiters2  "@5HJ J!E\D0rcl|xj|jz c_|xjdz c_yr$r^rSr_rs rindentzHelpFormatter.indents& t444 a rc|xj|jzc_|jdk\sJd|xjdzc_y)NrzIndent decreased below 0.r%rurs rdedentzHelpFormatter.dedents@ t444""a'D)DD' a rctdNzsubclasses must implementNotImplementedErrorrusages r format_usagezHelpFormatter.format_usage!"=>>rctdrzr{rheadings rformat_headingzHelpFormatter.format_headingrrct|j|jz d}d|jz}tj||||S)z Format a paragraph of free-form text for inclusion in the help output at the current indentation level. rl)initial_indentsubsequent_indent)r[rYr^textwrapfill)rtext text_widthrvs r _format_textzHelpFormatter._format_textsK d&9&992> T(((}}T',2/57 7rc0|r|j|dzSyN rkrr descriptions rformat_descriptionz HelpFormatter.format_descriptions $$[1D8 8rc6|rd|j|zdzSyrr)repilogs r format_epilogzHelpFormatter.format_epilogs# $++F33d: :rc2|j |js |jS|jjj |j }|t us| |j}|jj|jt|Sr ) rRrbhelpdefaultsgetdest NO_DEFAULTNO_DEFAULT_VALUEreplacer5)rr7 default_values rexpand_defaultzHelpFormatter.expand_defaultsv ;; d&6&6;;  ,,00= J &-*? 11M{{""4#3#3S5GHHrc tg}|j|}|j|jz dz }t||kDrd|jd|fz}|j}nd|jd||fz}d}|j ||j r~|j |}tj||j}|j d|d|dfz|j|ddDcgc]}d|jd|fzc}n|ddk7r|j ddj|Scc}w) NrPz%*s%s rkz %*s%-*s rr%r) rcr\r^lenappendrrrwrapr`extendrJ) rr7resultopts opt_width indent_first help_text help_lineslines r format_optionzHelpFormatter.format_option(s=""6*&&)<)<>D--L$"5"5r9d!KKDL d ;;++F3I!y$//BJ MM)|RA&GG H MM'1!"~7'5t%(:(:B'EE'57 8 "X  MM$ wwv 7s*D5c|jd}|jD]D}|j|}||j|<t |t ||j z}F|j|jD]U}|jD]D}|j|}||j|<t |t ||j z}FW|j|jt|dz|j|_ t |j|jz d|_ y)NrrPr)rv option_listformat_option_stringsrcr[rr^ option_groupsrxrZr]r\rYr`)rrRmax_lenoptstringsgroups rstore_option_stringsz"HelpFormatter.store_option_stringsKs  %%C005G'.D   $'3w<$2E2E#EFG& ))E((44S9+2##C(gs7|d6I6I'IJ)*   1d.D.DEdjj4+=+==rBrc|jry|jxs|jj}|jDcgc]}|j ||fz}}|j Dcgc]}|j||fz}}n|j}|j }|jr||z}n||z}dj|Scc}wcc}w)z@Return a comma-separated list of option strings & metavariables.rI) takes_valuemetavarrupper _short_optsrd _long_optsrerarJ)rr7rsopt short_optslopt long_optsrs rrz#HelpFormatter.format_option_strings]s    nn; (9(9(;G&,&8&8:&8d--w?&8 :&,%6%68%6T++tWo=%6 8 ++J))I    )Dz)Dyy:8s C /CN)rr1r2r:rr.rirprsrvrxrrrrrrrrrr!rrr r s^'R%22 1  ?? 7 I!FC$rr c,eZdZdZ ddZdZdZy)r z.Format help with indented section bodies. Nc6tj|||||yr r r.rfs rr.zIndentedHelpFormatter.__init__t  "$5uk Krctd|zS)Nz Usage: %s )rCr}s rrz"IndentedHelpFormatter.format_usage|s%''rc&d|jd|fzS)Nz%*s%s: rk)r^rs rrz$IndentedHelpFormatter.format_headingsT00"g>>>r)rPNr%rr1r2r:r.rrr!rrr r ps%#$#% K(?rr c,eZdZdZ ddZdZdZy)r z1Format help with underlined section headers. Nc6tj|||||yr rrfs rr.zTitledHelpFormatter.__init__rrcB|jtdd|dS)NUsagez r)rrCr}s rrz TitledHelpFormatter.format_usages!007 ?E7# $% %r)NODEFAULTceZdZdZgdZdZdZdZdZdZ dZ e e e e e d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZeeeeeeegZdZeZdZdZdZdZ dZ!dZ"y )rar Instance attributes: _short_opts : [string] _long_opts : [string] action : string type : string dest : string default : any nargs : int const : any choices : [string] callback : function callback_args : (any*) callback_kwargs : { string : any } help : string metavar : string ) actionrrdefaultnargsconstrcallback callback_argscallback_kwargsrr) store store_const store_true store_falser append_constcountrrversion)rrrrrrr)rrr)rr)rr)stringrTrrrchoice)rTrrrrNcg|_g|_|j|}|j||j ||j D] }|| yr )rr_check_opt_strings_set_opt_strings _set_attrs CHECK_METHODS)rrattrscheckers rr.zOption.__init__4sX&&t, d# ))G DM*rcN|Dcgc]}|s| }}|s td|Scc}w)Nz+at least one option string must be supplied) TypeErrorrrrs rrzOption._check_opt_stringsGs3 $+tst+IJ J ,s""cR|D]}t|dkrtd|z|t|dk(r;|ddk(r|ddk7std|z||jj|i|dddk(r|ddk7std|z||jj|y) NrPz>invalid option string %r: must be at least two characters longr-r%zMinvalid short option string %r: must be of the form -x, (x any non-dash char)--zGinvalid long option string %r: must start with --, followed by non-dash)rrrrrrs rrzOption._set_opt_stringsPsC3x!|!;=@ABFHHSQA# #a&C-%HJMN  '',AaD(SVs]%CEHI&&s+%rc|jD]>}||vrt||||||=|dk(rt||t2t||d@|r7t|j }t ddj |z|y)Nrzinvalid keyword arguments: %srI)ATTRSsetattrrsortedkeysrrJ)rrattrs rrzOption._set_attrsesJJDu}dE$K0$K9$D$ 3D$- 5::<(E/$))E2BB  rc|jd|_y|j|jvrtd|jz|y)Nrzinvalid action: %r)rACTIONSrrs r _check_actionzOption._check_actionxs? ;; !DK [[ ,2T[[@$G G-rc|j5|j|jvr|jd|_yd|_yyt |jtr|jj |_|jdk(rd|_|j|j vrtd|jz||j|jvrtd|jz|y)Nrrr5zinvalid option type: %rz$must not supply a type for action %r) rrALWAYS_TYPED_ACTIONSr isinstancerTYPESr TYPED_ACTIONSrs r _check_typezOption._check_type~s 99 {{d777<<+ (DI!)DI 8$))T* II.. yyE!$ yy *!";dii"GNN{{$"4"44!:T[[H$PP5rcX|jdk(rv|j td|t|jtt fs=tdt t|jjddz|y|jtd|jz|y)Nrz/must supply a list of choices for type 'choice'z1choices must be a list of strings ('%s' supplied)'r%z#must not supply choices for type %r)rrrrtuplelistr5splitrs r _check_choicezOption._check_choices 99 ||#!EtMM udm<!G$t||,-33C8;<=ACC=\\ %5 A4I I&rc |j|jvxs|jdu}|jO|rL|jr(|jdddj dd|_y|j dd|_yyy)NrrPr rCr%)r STORE_ACTIONSrrrrr)rrs r _check_destzOption._check_dests{{d&8&88-yy,  99  OOA.qr2::3D  ,,Q/2 "- rc|j|jvr&|jtd|jz|yy)Nz*'const' must not be supplied for action %r)r CONST_ACTIONSrrrs r _check_constzOption._check_constsB ;;d00 0TZZ5K"B Cz !%%+D))/RF DMM$UF DT DV Dv      KKM y  " KKM04;;>? ?r)#rr1r2r:r rr"rrr%rrrr4rr.rrrrrr r#r&r(r,r0r__repr__rr2r5r8r<r:r!rrrrs* E GM!M &%M DE$!. - - - , L M &,*&H P0 I 3 N8# " !!$ &M<H%'-H @rr SUPPRESSHELP SUPPRESSUSAGEcLeZdZd dZdZeZdZdZdZ dZ d dZ d d Z d Z y) rNcT|r&|jD]\}}t|||yyr )itemsr)rrrrs rr.zValues.__init__9s+ '~~/ sdC( 0 rc,t|jSr )r5__dict__rs rr0zValues.__str__>s4==!!rct|tr|j|jk(St|tr|j|k(StSr )rrrKr+NotImplemented)rothers r__eq__z Values.__eq__Cs> eV $==ENN2 2 t $==E) )! !rcXt|D]}||vs||}|t|||y)z Update the option values from an arbitrary dictionary, but only use keys from dict that already have a corresponding attribute in self. Any keys in dict without a corresponding attribute are silently ignored. N)dirr)rr+rdvals r_update_carefulzValues._update_carefulKs4IDt|Dz#D$- rc:|jj|y)z Update the option values from an arbitrary dictionary, using all keys from the dictionary regardless of whether they have a corresponding attribute in self or not. N)rKupdate)rr+s r _update_loosezValues._update_looseXs T"rcz|dk(r|j|y|dk(r|j|ytd|z)Ncarefulloosezinvalid update mode: %r)rSrVrX)rr+modes r_updatezValues._update`s> 9    & W_   t $6=> >rcvt|tj|}|jt ||yr ) __import__sysmodulesr[vars)rmodnamerZmods r read_modulezValues.read_modulehs*7kk'" T#Y%rcri}tt|j||j||yr )execopenreadr[)rfilenamerZr`s r read_filezValues.read_filems, T(^ "D) T4 rcdt||r t|| t|||t||Sr )hasattrgetattrr)rrrs rr>zValues.ensure_valuers1tT"gdD&9&A D$ &tT""rr )rX)rr1r2r.r0rrDrOrSrVr[rcrir>r!rrrr7s6) "H" .#?& ! #rrcpeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZy)ra Abstract base class. Class attributes: standard_option_list : [Option] list of standard options that will be accepted by all instances of this parser class (intended to be overridden by subclasses). Instance attributes: option_list : [Option] the list of Option objects contained by this OptionContainer _short_opt : { string : Option } dictionary mapping short option strings, eg. "-f" or "-X", to the Option instances that implement them. If an Option has multiple short option strings, it will appear in this dictionary multiple times. [1] _long_opt : { string : Option } dictionary mapping long option strings, eg. "--file" or "--exclude", to the Option instances that implement them. Again, a given Option can occur multiple times in this dictionary. [1] defaults : { string : any } dictionary mapping option destination names to default values for each destination [1] [1] These mappings are common to (shared by) all components of the controlling OptionParser, where they are initially created. cv|j||_|j||j|yr )_create_option_list option_classset_conflict_handlerset_description)rrpconflict_handlerrs rr.zOptionContainer.__init__s5   "( !!"23 [)rc.i|_i|_i|_yr  _short_opt _long_optrrs r_create_option_mappingsz'OptionContainer._create_option_mappingss rcj|j|_|j|_|j|_yr rurhs r_share_option_mappingsz&OptionContainer._share_option_mappingss)!++)) rc6|dvrtd|z||_y)N)errorresolvez$invalid conflict_resolution value %r)rXrs)rhandlers rrqz$OptionContainer.set_conflict_handlers$ . .CgMN N 'rc||_yr rrs rrrzOptionContainer.set_descriptions &rc|jSr rrs rget_descriptionzOptionContainer.get_descriptionsrc|`|`|`yzsee OptionParser.destroy().Nrurs rdestroyzOptionContainer.destroys O N Mrc g}|jD]1}||jvs|j||j|f3|jD]1}||jvs|j||j|f3|r|j }|dk(r/t ddj|Dcgc]}|d c}z||dk(r|D]\}}|jdr)|jj||j|=n(|jj||j|=|jru|jr|jjj|yyycc}w)Nr|z conflicting option string(s): %srIrr}r ) rrvrrrwrsrrJ startswithremove containerr)rr7 conflict_optsrr~coc_options r_check_conflictzOptionContainer._check_conflictsh %%Cdoo%$$c4??3+?%@A&$$Cdnn$$$c4>>#+>%?@% ++G'!)6ii ?2A ?@AI%'4OS(~~d+ ++2237 NN3/ ,,33C8 OOC0$00H4G4G **66==hG(5&  !@s+ E8ct|dtr|j|i|}n>t|dk(r%|s#|d}t|tst d|zt d|j ||jj|||_ |jD]}||j|<|jD]}||j|<|jh|jt ur%|j|j"|j<|S|j|j"vrd|j"|j<|S)zOadd_option(Option) add_option(opt_str, ..., kwarg=val, ...) rr%znot an Option instance: %rinvalid argumentsN)rr5rprrrrrrrrrvrrwrrrr)rrBrCr7rs r add_optionzOptionContainer.add_options* d1gs #&T&&77F Y!^F!WFff- ||jvxs||jvSr )rvrwrAs r has_optionzOptionContainer.has_option s$4??**4>>) +rcV|jj|}||jj|}|td|z|jD]}|j|=|j D]}|j|=|j jj|y)Nzno such option %r) rvrrwrXrrrrr)rr@r7rs r remove_optionzOptionContainer.remove_options$$W- >^^''0F >07:; ;%%C$&$$Cs#%$$++F3rc|jsyg}|jD]5}|jtus|j|j |7dj |SNrk)rrrrrrJ)r formatterrr7s rformat_option_helpz"OptionContainer.format_option_helpsV&&F;;-/ i55f=>'wwvrc@|j|jSr )rrrrs rrz"OptionContainer.format_description(s++D,@,@,BCCrcg}|jr |j|j||jr |j|j |dj |S)Nr)rrrrrrJrrrs r format_helpzOptionContainer.format_help+sV    MM$11)< =    MM$11)< =yy  rN)rr1r2r:r.rxrzrqrrrrrrrrrrrrrr!rrrrxsY< *(( ' H6<$ -+ 4 D!rrc,eZdZddZdZdZdZdZy)rNcx||_tj||j|j|||_yr )rRrr.rprstitle)rrRrrs rr.zOptionGroup.__init__6s4   &%%v'>'>  M rcHg|_|j|jyr )rrzrRrs rrozOptionGroup._create_option_list<s ##DKK0rc||_yr )r)rrs r set_titlezOptionGroup.set_title@s  rc2tj||`yr)rrrrs rrzOptionGroup.destroyCs%  rc|j|j}|j|tj ||z }|j |Sr )rrrvrrrxrs rrzOptionGroup.format_helpJsJ))$**5/--dI>> rr )rr1r2r.rorrrr!rrrr4s 1rrc eZdZdZgZddedddddddf dZdZdZdZ d Z d*d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZd+dZdZdZdZdZdZdZdZdZ d,d Z!d!Z"d"Z#d-d#Z$d$Z%d-d%Z&d-d&Z'd'Z(d-d(Z)d-d)Z*y).r a$ Class attributes: standard_option_list : [Option] list of standard options that will be accepted by all instances of this parser class (intended to be overridden by subclasses). Instance attributes: usage : string a usage string for your program. Before it is displayed to the user, "%prog" will be expanded to the name of your program (self.prog or os.path.basename(sys.argv[0])). prog : string the name of the current program (to override os.path.basename(sys.argv[0])). description : string A paragraph of text giving a brief overview of your program. optparse reformats this paragraph to fit the current terminal width and prints it when the user requests help (after usage, but before the list of options). epilog : string paragraph of help text to print after option help option_groups : [OptionGroup] list of option groups in this parser (option groups are irrelevant for parsing the command-line, but very useful for generating help) allow_interspersed_args : bool = true if true, positional arguments may be interspersed with options. Assuming -a and -b each take a single argument, the command-line -ablah foo bar -bboo baz will be interpreted the same as -ablah -bboo -- foo bar baz If this flag were false, that command line would be interpreted as -ablah -- foo bar -bboo baz -- ie. we stop processing options as soon as we see the first non-option argument. (This is the tradition followed by Python's getopt module, Perl's Getopt::Std, and other argument- parsing libraries, but it is generally annoying to users.) process_default_values : bool = true if true, option default values are processed similarly to option values from the command line: that is, they are passed to the type-checking function for the option's type (as long as the default value is a string). (This really only matters if you have defined custom types; see SF bug #955889.) Set it to false to restore the behaviour of Optik 1.4.1 and earlier. rargs : [string] the argument list currently being parsed. Only set when parse_args() is active, and continually trimmed down as we consume arguments. Mainly there for the benefit of callback options. largs : [string] the list of leftover arguments that we have skipped while parsing options. If allow_interspersed_args is false, this list is always empty. values : Values the set of option values currently being accumulated. Only set when parse_args() is active. Also mainly for callbacks. Because of the 'rargs', 'largs', and 'values' attributes, OptionParser is not thread-safe. If, for some perverse reason, you need to parse command-line arguments simultaneously in different threads, use different OptionParser instances. Nr|Tc >tj|||||j|| |_||_d|_d|_| t}||_|jj|| |_ |j|||jy)NT)add_help) rr. set_usageprograllow_interspersed_argsprocess_default_valuesr rrir_populate_option_list_init_parsing_state) rr~rrprrsrradd_help_optionrrs rr.zOptionParser.__init__s   , 0+ ? u  '+$&*#  -/I" !!$' "";,; # =   "rc|tj||jD]}|j|`|`|`y)a Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable. N)rrrrr)rrs rrzOptionParser.destroys< %''E MMO(     Nrc@g|_g|_|jyr )rrrxrs rroz OptionParser._create_option_lists $$&rc@|jdddtdy)Nz-hz--helprzshow this help message and exitrrrrCrs r_add_help_optionzOptionParser._add_help_options$ h%@A  Crc>|jddtdy)Nz --versionrz&show program's version number and exitrrrs r_add_version_optionz OptionParser._add_version_options"  (GH  Jrc|jr|j|j|r|j||jr|j|r|j yyr )standard_option_listrrrr)rrrs rrz"OptionParser._populate_option_listsW  $ $   T66 7    [ ) <<  $ $ &   ! ! # rc.d|_d|_d|_yr )rargslargsr;rs rrz OptionParser._init_parsing_states   rc|td|_y|turd|_y|jj dr |dd|_y||_y)Nz%prog [options]zusage: )rCr~rrrr}s rrzOptionParser.set_usagesK =,-DJ n $DJ [[] % %i 0qrDJDJrcd|_y)aSet parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.TNrrs renable_interspersed_argsz%OptionParser.enable_interspersed_argss (,$rcd|_y)zSet parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don't get confused. FNrrs rdisable_interspersed_argsz&OptionParser.disable_interspersed_argss (-$rc||_yr )r)rr<s rset_process_default_valuesz'OptionParser.set_process_default_values s &-#rc"||j|<yr )r)rrrs r set_defaultzOptionParser.set_defaults# drc :|jj|yr )rrU)rrCs r set_defaultszOptionParser.set_defaultss V$rc||jdd}|jD]}|j|j|Sr )rrr)roptionsrs r_get_all_optionszOptionParser._get_all_optionss9""1%''E NN5,, -(rcn|jst|jS|jj}|j D]]}|j |j }t|ts/|j}|j||||j <_t|Sr ) rrrcopyrrrrr5r2r5)rrr7rr@s rget_default_valueszOptionParser.get_default_valuess**$--( (==%%'++-Fll6;;/G'3' //1(.(:(:7G(L% . hrc0t|dtrt|g|i|}nWt|dk(r>|s<|d}t|tst d|z|j |urt dt d|jj||S)Nrr%znot an OptionGroup instance: %rz"invalid OptionGroup (wrong parser)r) rr5rrrrRrXrr)rrBrCrs radd_option_groupzOptionParser.add_option_group+s d1gs #6t6v6E Y!^FGEe[1 AE IJJ||4' !EFF/0 0 !!%( rc|jj|xs|jj|}|r|j|ur |jSyr )rvrrwr)rr@r7s rget_option_groupzOptionParser.get_option_group;sO//%%g....$$W-  f&&d2## #rc6|tjddS|ddSr$)r^argv)rrBs r _get_argszOptionParser._get_argsEs <88AB< 7Nrc8|j|}||j}||_gx|_}||_ |j |||}||z}|j||S#t tf$r$}|jt|Yd}~Ed}~wwxYw)aR parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]). Any errors result in a call to 'error()', which by default prints the usage message to stderr and calls sys.exit() with an error message. On success returns a pair (values, args) where 'values' is a Values instance (with all your option values) and 'args' is the list of arguments left over after parsing options. N) rrrrr; _process_argsrrr|r5 check_values)rrBr;rrstoperrs r parse_argszOptionParser.parse_argsKst$ >,,.F  U  !%%eUF;Du}  ..  01 ! JJs3x  !sA&&B5BBc ||fS)a check_values(values : Values, args : [string]) -> (values : Values, args : [string]) Check that the supplied option values and leftover arguments are valid. Returns the option values and leftover arguments (possibly adjusted, possibly completely new -- whatever you like). Default implementation just returns the passed-in values; subclasses may override as desired. r!)rr;rBs rrzOptionParser.check_valuesrs~rc|rx|d}|dk(r|d=y|dddk(r|j||nK|dddk(r!t|dkDr|j||n"|jr|j ||d=ny|rwyy)a_process_args(largs : [string], rargs : [string], values : Values) Process command-line arguments and populate 'values', consuming options and arguments from 'rargs'. If 'allow_interspersed_args' is false, stop at the first non-option argument. If true, accumulate any interspersed non-option arguments in 'largs'. rr NrPr%r )_process_long_optr_process_short_optsrr)rrrr;args rrzOptionParser._process_argss(Cd{!HQqT!&&uf5RaCCHqL((7-- S!!H'rc.t||jS)a_match_long_opt(opt : string) -> string Determine which long option string 'opt' matches, ie. which one it is an unambiguous abbreviation for. Raises BadOptionError if 'opt' doesn't unambiguously match any long option string. ) _match_abbrevrw)rrs r_match_long_optzOptionParser._match_long_optsS$..11rc&|jd}d|vr*|jdd\}}|jd|d}n|}d}|j|}|j|}|j rh|j }t||kr#|jtdd|||dznM|dk(r|jd} n6t|d|} |d|=n"|r|jtd |znd} |j| ||y) Nrrrr%TF.%(option)s option requires %(number)d argument/%(option)s option requires %(number)d argumentsr7numberz%s option does not take a value) poprinsertrrwrrrr|rrrCr<) rrr;rrnext_arghad_explicit_valuer7rrs rrzOptionParser._process_long_optsiil #:!iiQ/OS( LLH %!% C!& ""3'$    LLE5zE! 8DE),u=>?! ! eAen-!E'N  JJq:;cA BEsE640rc|jd}d}d}|ddD]}d|z}|jj|}|dz }|s t||j r|t |kr|j d||dd}|j} t || kr#|jtdd| || dzn-| dk(r|jd} nt|d| } |d| =nd} |j| |||syy) NrFr%r Trrr) rrvrrrrrrr|rrr<) rrr;rrichrr7rrs rrz OptionParser._process_short_optss"iil ab'B(C__((-F FA$S))!!#s3x<LLCG,D u:%JJxHI -05!A BCaZ!IIaLE!%%.1Eag NN3vt 4Arc|j0tjjtj dS|jSr1)rrUpathbasenamer^rrs r get_prog_namezOptionParser.get_prog_names3 99 77##CHHQK0 099 rcB|jd|jS)Nz%prog)rr)rss rexpand_prog_namezOptionParser.expand_prog_namesyy$"4"4"677rc8|j|jSr )rrrs rrzOptionParser.get_descriptions$$T%5%566rcp|rtjj|tj|yr )r^stderrwriter@)rstatusr,s rr@zOptionParser.exits#  JJ  S ! rc|jtj|jd|j d|dy)zerror(msg : string) Print a usage message incorporating 'msg' to stderr and exit. If you override this in a subclass, it should not return -- it should either exit or raise an exception. rPz : error: rN) print_usager^rr@rr-s rr|zOptionParser.errors2 $ !$*<*<*>DErc|jr4|jj|j|jSyr)r~rrrrs r get_usagezOptionParser.get_usage#s7 ::>>..%%djj13 3rcT|jrt|j|yy)aaprint_usage(file : file = stdout) Print the usage message for the current program (self.usage) to 'file' (default stdout). Any occurrence of the string "%prog" in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined. fileN)r~printrrrs rrzOptionParser.print_usage*s! :: $.." . rcR|jr|j|jSyr)rrrs r get_versionzOptionParser.get_version6s! <<((6 6rcT|jrt|j|yy)aEprint_version(file : file = stdout) Print the version message for this program (self.version) to 'file' (default stdout). As with print_usage(), any occurrence of "%prog" in self.version is replaced by the current program's name. Does nothing if self.version is empty or undefined. rN)rrr r s rrAzOptionParser.print_version<s# << $""$4 0 rc| |j}|j|g}|j|jt d|j |j r6|jtj|||jd|jD]3}|j|j||jd5|jdj|ddS)NOptionsrrkr) rrrrrCrvrrrrrrxrJ)rrrrs rrzOptionParser.format_option_helpGs  I&&t, i..q|<=    MM/< string Return the string key in 'wordmap' for which 's' is an unambiguous abbreviation. If 's' is found to be ambiguous or doesn't match any of 'words', raise BadOptionError. r%r)rrrrsortrE)rwordmapwordrGs rrrts G|+2,,.0.$ OOA.. 0 }  " # # # #    &q-8 80sA1)'r: __version____all__ __copyright__r^rUrrrr ImportErrorrC Exceptionr rrrrrEr r r rrrrrrrrrrrrrrr rrr!rrrsy.  $ @J ) Y= ;   6m6 AN AMM^?]?&G=G&  %a l3%q|4!1%5#67%q|47 G% nnf " #>#>#By!y!x?<]'O]'D9: m1 sC:: DD