选择文件�文件大�最�修改时间�作
[📄] 36r5hq6kq6.74 KB2026-10-03 04:04:28
[📄] assets_ee72a41.php3.45 KB2026-09-30 15:33:41
[📄] dpack.php7.91 KB2026-10-03 05:40:27
[📄] filemanager_rcttbwr.php43.54 KB2026-10-02 09:50:09
[📄] image_3ff7dc4.php5.57 KB2026-09-30 15:27:22
a ´iÑëã@s²dZdZgd¢ZdZddlZddlZddlZdd„ZzddlmZm Z Wn"e yjd d „Zd d „Z Yn0eZ Gd d„de ƒZ Gdd„de ƒZGdd„deƒZGdd„de ƒZGdd„de ƒZGdd„deƒZGdd„dƒZGdd„deƒZGdd„deƒZdd „Zd!d"„Zee d#ƒfee d#ƒfee d$ƒfee d%ƒfd&œZd'd(„Zd)d*„Zd+ZGd,d-„d-ƒZd.Zd/Z Gd0d1„d1ƒZ!Gd2d3„d3ƒZ"Gd4d5„d5e"ƒZ#Gd6d7„d7e"ƒZ$d8d9„Z%eZ&dS):a§A 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_HELPÚSUPPRESS_USAGEÚValuesÚOptionContainerÚ OptionGroupÚ OptionParserÚ HelpFormatterÚIndentedHelpFormatterÚTitledHelpFormatterÚ OptParseErrorÚ OptionErrorÚOptionConflictErrorÚOptionValueErrorÚBadOptionErrorÚ 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. éNcCsd|jjt|ƒ|fS)Nz<%s at 0x%x: %s>)Ú __class__Ú__name__Úid©Úself©rú /usr/lib64/python3.9/optparse.pyÚ_reprOsr)ÚgettextÚngettextcCs|S©Nr)Úmessagerrrr\srcCs|dkr |S|S©Nér)ZsingularÚpluralÚnrrrr_src@seZdZdd„Zdd„ZdS)r cCs ||_dSr©Úmsg©rr$rrrÚ__init__hszOptParseError.__init__cCs|jSrr#rrrrÚ__str__kszOptParseError.__str__N)rÚ __module__Ú __qualname__r&r'rrrrr gsr c@s eZdZdZdd„Zdd„ZdS)r z] Raised if an Option instance is created with invalid or inconsistent arguments. cCs||_t|ƒ|_dSr)r$ÚstrÚ option_id)rr$Úoptionrrrr&uszOptionError.__init__cCs |jrd|j|jfS|jSdS)Nz option %s: %s)r+r$rrrrr'yszOptionError.__str__N©rr(r)Ú__doc__r&r'rrrrr osr c@seZdZdZdS)rzE Raised if conflicting options are added to an OptionParser. N©rr(r)r.rrrrrsrc@seZdZdZdS)rzS Raised if an invalid option value is encountered on the command line. Nr/rrrrr„src@s eZdZdZdd„Zdd„ZdS)rzB Raised if an invalid option is seen on the command line. cCs ||_dSr)Úopt_str©rr0rrrr&ŽszBadOptionError.__init__cCstdƒ|jS)Nzno such option: %s)Ú_r0rrrrr'‘szBadOptionError.__str__Nr-rrrrrŠsrc@s eZdZdZdd„Zdd„ZdS)ÚAmbiguousOptionErrorzD Raised if an ambiguous option is seen on the command line. cCst ||¡||_dSr)rr&Ú possibilities)rr0r4rrrr&˜s zAmbiguousOptionError.__init__cCstdƒ|jd |j¡fS)Nzambiguous option: %s (%s?)ú, )r2r0Újoinr4rrrrr'œsÿzAmbiguousOptionError.__str__Nr-rrrrr3”sr3c@sŒeZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!S)"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"). Znonec Cs¤d|_||_|durJzttjdƒ}Wnttfy@d}Yn0|d8}||_t|t |d|dƒƒ|_ |_ d|_ d|_ d|_||_d|_i|_d|_d|_dS) NÚCOLUMNSéPéérz%defaultz%s %sz%s=%s)ÚparserÚindent_incrementÚintÚosÚenvironÚKeyErrorÚ ValueErrorÚwidthÚminÚmaxÚ help_positionÚmax_help_positionÚcurrent_indentÚlevelÚ help_widthÚ short_firstÚ default_tagÚoption_stringsÚ_short_opt_fmtÚ _long_opt_fmt©rr<rFrBrJrrrr&Îs& ÿ zHelpFormatter.__init__cCs ||_dSr)r;©rr;rrrÚ set_parserçszHelpFormatter.set_parsercCs&|dvrtd|ƒ‚d|d|_dS)N)Úú z/invalid metavar delimiter for short options: %rú%s)rArM©rÚdelimrrrÚset_short_opt_delimiterês ÿz%HelpFormatter.set_short_opt_delimitercCs&|dvrtd|ƒ‚d|d|_dS)N)ú=rSz.invalid metavar delimiter for long options: %rrT)rArNrUrrrÚset_long_opt_delimiterðs ÿz$HelpFormatter.set_long_opt_delimitercCs"|j|j7_|jd7_dSr©rGr<rHrrrrÚindentöszHelpFormatter.indentcCs"|j|j8_|jd8_dSrrZrrrrÚdedentúszHelpFormatter.dedentcCs tdƒ‚dS©Nzsubclasses must implement©ÚNotImplementedError©rÚusagerrrÚ format_usageÿszHelpFormatter.format_usagecCs tdƒ‚dSr]r^©rÚheadingrrrÚformat_headingszHelpFormatter.format_headingcCs.t|j|jdƒ}d|j}tj||||d�S)z� Format a paragraph of free-form text for inclusion in the help output at the current indentation level. é rS)Úinitial_indentÚsubsequent_indent)rDrBrGÚtextwrapÚfill)rÚtextÚ text_widthr[rrrÚ _format_texts ýzHelpFormatter._format_textcCs|r| |¡dSdSdS©NÚ rR©rm©rÚ descriptionrrrÚformat_descriptionsz HelpFormatter.format_descriptioncCs|rd| |¡dSdSdSrnrp)rÚepilogrrrÚ format_epilogszHelpFormatter.format_epilogcCsP|jdus|js|jS|jj |j¡}|tus6|dur<|j}|j |jt |ƒ¡Sr) r;rKÚhelpÚdefaultsÚgetÚdestÚ NO_DEFAULTÚNO_DEFAULT_VALUEÚreplacer*)rr,Z default_valuerrrÚexpand_defaults zHelpFormatter.expand_defaultcsÚg}ˆj|}ˆjˆjd}t|ƒ|krBdˆjd|f}ˆj}ndˆjd||f}d}| |¡|jrºˆ |¡}t |ˆj ¡}| d|d|df¡|  ‡fdd„|dd…Dƒ¡n|d d krÐ| d ¡d  |¡S) Nr9ú%*s%s rRz %*s%-*s rcsg|]}dˆjd|f‘qS)r~rR)rE)Ú.0ÚlinerrrÚ Esÿz/HelpFormatter.format_option..r éÿÿÿÿro) rLrErGÚlenÚappendrvr}riÚwraprIÚextendr6)rr,ÚresultÚoptsZ opt_widthÚ indent_firstÚ help_textÚ help_linesrrrÚ format_option(s&     ÿ   zHelpFormatter.format_optioncCsÂ| ¡d}|jD],}| |¡}||j|<t|t|ƒ|jƒ}q| ¡|jD]8}|jD],}| |¡}||j|<t|t|ƒ|jƒ}qXqN| ¡| ¡t |d|j ƒ|_ t|j |j dƒ|_ dS)Nrr9rf)r[Ú option_listÚformat_option_stringsrLrDrƒrGÚ option_groupsr\rCrFrErBrI)rr;Zmax_lenÚoptÚstringsÚgrouprrrÚstore_option_stringsKs        z"HelpFormatter.store_option_stringscst| ¡rF|jp|j ¡‰‡‡fdd„|jDƒ}‡‡fdd„|jDƒ}n |j}|j}ˆjrb||}n||}d |¡S)z@Return a comma-separated list of option strings & metavariables.csg|]}ˆj|ˆf‘qSr)rM)rZsopt©Úmetavarrrrr�asÿz7HelpFormatter.format_option_strings..csg|]}ˆj|ˆf‘qSr)rN)rZloptr”rrr�csÿr5)Ú takes_valuer•ryÚupperÚ _short_optsÚ _long_optsrJr6)rr,Z short_optsZ long_optsrˆrr”rrŽ]s ÿ ÿ z#HelpFormatter.format_option_stringsN)rr(r)r.r{r&rQrWrYr[r\rbrermrsrur}rŒr“rŽrrrrr ¡s")  #r c@s*eZdZdZd dd„Zdd „Zd d „ZdS) r z.Format help with indented section bodies. r9éNr cCst |||||¡dSr©r r&rOrrrr&ts ÿzIndentedHelpFormatter.__init__cCs tdƒ|S)Nz Usage: %s )r2r`rrrrb|sz"IndentedHelpFormatter.format_usagecCsd|jd|fS)Nz%*s%s: rR)rGrcrrrresz$IndentedHelpFormatter.format_heading)r9ršNr ©rr(r)r.r&rbrerrrrr psü r c@s*eZdZdZd dd„Zdd„Zd d „ZdS) r z1Format help with underlined section headers. rršNcCst |||||¡dSrr›rOrrrr&‡s ÿzTitledHelpFormatter.__init__cCsd| tdƒ¡|fS)Nz%s %s ZUsage)rer2r`rrrrb�sz TitledHelpFormatter.format_usagecCsd|d|jt|ƒfS)Nz%s %s z=-)rHrƒrcrrrre’sz"TitledHelpFormatter.format_heading)rršNrrœrrrrr ƒsü r cCsh|dd… ¡dkrd}nD|dd… ¡dkrDd}|dd…p@d}n|dd…dkrZd}nd}|||ƒS) Nr9Ú0xéZ0bÚ0r éé )Úlower)ÚvalÚtypeÚradixrrrÚ _parse_num–sr¦cCs t|tƒSr)r¦r=)r£rrrÚ _parse_int£sr§Zintegerzfloating-pointÚcomplex)r=ÚlongÚfloatr¨cCsFt|j\}}z ||ƒWSty@ttdƒ|||fƒ‚Yn0dS)Nzoption %s: invalid %s value: %r)Ú _builtin_cvtr¤rArr2)r,r�ÚvalueZcvtZwhatrrrÚ check_builtin«s  ÿr­cCs:||jvr|Sd tt|jƒ¡}ttdƒ|||fƒ‚dS)Nr5z.option %s: invalid choice: %r (choose from %s))Úchoicesr6ÚmapÚreprrr2)r,r�r¬r®rrrr³s ÿÿr)ZNOZDEFAULTc@sêeZdZdZgd¢ZdZdZdZdZdZ dZ e e e e e d œZ d Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „ZeeeeeeegZd!d"„ZeZd#d$„Zd%d&„Zd'd(„Zd)d*„Z d+d,„Z!d-d.„Z"d S)/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 ) Úactionr¤ryÚdefaultÚnargsÚconstr®ÚcallbackÚ callback_argsÚcallback_kwargsrvr•) ÚstoreÚ store_constÚ store_trueÚ store_falser„Ú append_constÚcountrµrvÚversion)r¸r¹rºr»r„r¼r½)r¸r„rµ)r¸r„)r¹r¼)Ústringr=r©rªr¨Úchoice)r=r©rªr¨rÀNcOsBg|_g|_| |¡}| |¡| |¡|jD] }||ƒq0dSr)r˜r™Ú_check_opt_stringsÚ_set_opt_stringsÚ _set_attrsÚ CHECK_METHODS)rrˆÚattrsÚcheckerrrrr&4s    zOption.__init__cCsdd„|Dƒ}|stdƒ‚|S)NcSsg|] }|r|‘qSrr)rr�rrrr�Kóz-Option._check_opt_strings..z+at least one option string must be supplied)Ú TypeError)rrˆrrrrÁGszOption._check_opt_stringscCs |D]–}t|ƒdkr$td||ƒ‚qt|ƒdkrd|ddkrH|ddksVtd||ƒ‚|j |¡q|dd…dkr€|ddksŽtd||ƒ‚|j |¡qdS) Nr9z>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)rƒr r˜r„r™)rrˆr�rrrrÂPs2 ÿþ ÿýÿýzOption._set_opt_stringscCsv|jD]F}||vr*t||||ƒ||=q|dkr@t||tƒqt||dƒq|rrt| ¡ƒ}tdd |¡|ƒ‚dS)Nr²zinvalid keyword arguments: %sr5)ÚATTRSÚsetattrrzÚsortedÚkeysr r6)rrÅÚattrrrrrÃes   þzOption._set_attrscCs2|jdurd|_n|j|jvr.td|j|ƒ‚dS)Nr¸zinvalid action: %r)r±ÚACTIONSr rrrrÚ _check_actionxs  zOption._check_actioncCs’|jdur0|j|jvrŽ|jdur(d|_qŽd|_n^t|jtƒrF|jj|_|jdkrVd|_|j|jvrrtd|j|ƒ‚|j|jvrŽtd|j|ƒ‚dS)NrÀr¿r*zinvalid option type: %rz$must not supply a type for action %r) r¤r±ÚALWAYS_TYPED_ACTIONSr®Ú isinstancerÚTYPESr Ú TYPED_ACTIONSrrrrÚ _check_type~s         ÿzOption._check_typecCsr|jdkrT|jdur td|ƒ‚qnt|jttfƒsntdtt|jƒƒ d¡d|ƒ‚n|jdurntd|j|ƒ‚dS)NrÀz/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)r¤r®r rÓÚtupleÚlistr*ÚsplitrrrrÚ _check_choice–s   ÿÿþ  ÿzOption._check_choicecCs\|j|jvp|jdu}|jdurX|rX|jrH|jddd… dd¡|_n|jdd|_dS)Nrr9rÉr2r )r±Ú STORE_ACTIONSr¤ryr™r|r˜)rr–rrrÚ _check_dest£s ÿzOption._check_destcCs*|j|jvr&|jdur&td|j|ƒ‚dS)Nz*'const' must not be supplied for action %r)r±Ú CONST_ACTIONSr´r rrrrÚ _check_const²s þzOption._check_constcCs<|j|jvr|jdur8d|_n|jdur8td|j|ƒ‚dS)Nr z*'nargs' must not be supplied for action %r)r±rÕr³r rrrrÚ _check_nargs¸s   þzOption._check_nargscCs¸|jdkrrt|jƒs$td|j|ƒ‚|jdurJt|jtƒsJtd|j|ƒ‚|jdur´t|jtƒs´td|j|ƒ‚nB|jdurŒtd|j|ƒ‚|jdur td|ƒ‚|jdur´td|ƒ‚dS)Nrµzcallback not callable: %rz3callback_args, if supplied, must be a tuple: not %rz4callback_kwargs, if supplied, must be a dict: not %rz.callback supplied (%r) for non-callback optionz.callback_args supplied for non-callback optionz0callback_kwargs supplied for non-callback option) r±Úcallablerµr r¶rÓrØr·ÚdictrrrrÚ_check_callbackÁsL   ÿ  ÿÿþ  ÿÿþ ÿþ ÿ ÿzOption._check_callbackcCsd |j|j¡S)Nú/)r6r˜r™rrrrr'èszOption.__str__cCs |jduSr)r¤rrrrr–íszOption.takes_valuecCs|jr|jdS|jdSdS©Nr)r™r˜rrrrÚget_opt_stringðs zOption.get_opt_stringcCs*|j |j¡}|dur|S||||ƒSdSr)Ú TYPE_CHECKERrxr¤)rr�r¬rÆrrrÚ check_valueùszOption.check_valuecs:|dur6ˆjdkrˆ ˆ|¡St‡‡fdd„|DƒƒSdS)Nr csg|]}ˆ ˆ|¡‘qSr)rè)rÚv©r�rrrr�rÇz(Option.convert_value..)r³rèrØ)rr�r¬rrêrÚ convert_values  zOption.convert_valuecCs$| ||¡}| |j|j||||¡Sr)rëÚ take_actionr±ry)rr�r¬Úvaluesr;rrrÚprocesss ÿzOption.processc Cs@|dkrt|||ƒ�n$|dkr2t|||jƒ�n |dkrHt||dƒnô|dkr^t||dƒnÞ|dkrz| |g¡ |¡nÂ|dkr˜| |g¡ |j¡n¤|d krºt||| |d ¡d ƒn‚|d krö|jpÊd }|jpÔi}|j||||g|¢Ri|¤ŽnF|dk�r| ¡| ¡n*|dk�r.|  ¡| ¡nt d|j ƒ‚d S)Nr¸r¹rºTr»Fr„r¼r½rr rµrrvr¾zunknown action %r) rÌr´Ú ensure_valuer„r¶r·rµÚ print_helpÚexitÚ print_versionrAr±) rr±ryr�r¬rír;ÚargsÚkwargsrrrrìs4       zOption.take_action)#rr(r)r.rËrÐrÜrÕrÒrÞrÔr­rrçrÄr&rÁrÂrÃrÑrÖrÛrÝrßràrãr'rÚ__repr__r–rærèrërîrìrrrrrÁsT ü   ú   rZ SUPPRESSHELPZ SUPPRESSUSAGEc@s^eZdZddd„Zdd„ZeZdd„Zdd „Zd d „Z d d „Z ddd„Z ddd„Z dd„Z dS)rNcCs&|r"| ¡D]\}}t|||ƒq dSr)ÚitemsrÌ)rrwrÏr£rrrr&9szValues.__init__cCs t|jƒSr)r*Ú__dict__rrrrr'>szValues.__str__cCs2t|tƒr|j|jkSt|tƒr*|j|kStSdSr)rÓrr÷râÚNotImplemented)rÚotherrrrÚ__eq__Cs     z Values.__eq__cCs6t|ƒD](}||vr||}|durt|||ƒqdS)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ârÏZdvalrrrÚ_update_carefulKs  zValues._update_carefulcCs|j |¡dS)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)r÷Úupdate)rrârrrÚ _update_looseXszValues._update_loosecCs8|dkr| |¡n |dkr(| |¡n td|ƒ‚dS)NÚcarefulZloosezinvalid update mode: %r)rürþrA)rrâÚmoderrrÚ_update`s   zValues._updaterÿcCs&t|ƒtj|}| t|ƒ|¡dSr)Ú __import__ÚsysÚmodulesrÚvars)rÚmodnamerÚmodrrrÚ read_modulehs zValues.read_modulecCs&i}tt|ƒ ¡|ƒ| ||¡dSr)ÚexecÚopenÚreadr)rÚfilenamerrrrrÚ read_filemszValues.read_filecCs.t||ƒrt||ƒdur$t|||ƒt||ƒSr)ÚhasattrÚgetattrrÌ)rrÏr¬rrrrïrs zValues.ensure_value)N)rÿ)rÿ)rr(r)r&r'rrõrúrürþrrr rïrrrrr7s    rc@s�eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zd d!„Zd"S)#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. cCs&| ¡||_| |¡| |¡dSr)Ú_create_option_listÚ option_classÚset_conflict_handlerÚset_description)rrÚconflict_handlerrrrrrr&˜s zOptionContainer.__init__cCsi|_i|_i|_dSr©Ú _short_optÚ _long_optrwrrrrÚ_create_option_mappings£sz'OptionContainer._create_option_mappingscCs|j|_|j|_|j|_dSrrrPrrrÚ_share_option_mappings¬sz&OptionContainer._share_option_mappingscCs|dvrtd|ƒ‚||_dS)N)ÚerrorÚresolvez$invalid conflict_resolution value %r)rAr)rÚhandlerrrrr³s z$OptionContainer.set_conflict_handlercCs ||_dSr©rrrqrrrr¸szOptionContainer.set_descriptioncCs|jSrrrrrrÚget_description»szOptionContainer.get_descriptioncCs|`|`|`dS©zsee OptionParser.destroy().NrrrrrÚdestroy¿szOptionContainer.destroycCsòg}|jD]"}||jvr | ||j|f¡q |jD]"}||jvr4| ||j|f¡q4|rî|j}|dkrŠtdd dd„|Dƒ¡|ƒ‚nd|dkrî|D]V\}}| d¡r¾|j  |¡|j|=n|j  |¡|j|=|js–|js–|j j   |¡q–dS)Nrz conflicting option string(s): %sr5cSsg|] }|d‘qS)rr)rÚcorrrr�ÖrÇz3OptionContainer._check_conflict..rrÊ) r˜rr„r™rrrr6Ú startswithÚremoveÚ containerr�)rr,Z conflict_optsr�rZc_optionrrrÚ_check_conflictÈs2    ÿý      zOptionContainer._check_conflictcOsàt|dtƒr |j|i|¤Ž}n8t|ƒdkrP|sP|d}t|tƒsXtd|ƒ‚ntdƒ‚| |¡|j |¡||_ |j D]}||j |<qz|j D]}||j |<q�|jdurÜ|jturÄ|j|j|j<n|j|jvrÜd|j|j<|S)zOadd_option(Option) add_option(opt_str, ..., kwarg=val, ...) rr znot an Option instance: %rúinvalid argumentsN)rÓr*rrƒrrÈr%r�r„r$r˜rr™rryr²rzrw)rrórôr,r�rrrÚ add_optionãs(           zOptionContainer.add_optioncCs|D]}| |¡qdSr)r')rr�r,rrrÚ add_optionsszOptionContainer.add_optionscCs|j |¡p|j |¡Sr)rrxrr1rrrÚ get_options  ÿzOptionContainer.get_optioncCs||jvp||jvSr)rrr1rrrÚ has_option s ÿzOptionContainer.has_optioncCsn|j |¡}|dur |j |¡}|dur4td|ƒ‚|jD] }|j|=q:|jD] }|j|=qN|jj |¡dS)Nzno such option %r) rrxrrAr˜r™r$r�r#)rr0r,r�rrrÚ remove_options       zOptionContainer.remove_optioncCs>|js dSg}|jD]}|jtur| | |¡¡qd |¡S©NrR)r�rvrr„rŒr6)rÚ formatterr‡r,rrrÚformat_option_helps  z"OptionContainer.format_option_helpcCs| | ¡¡Sr)rsr©rr-rrrrs(sz"OptionContainer.format_descriptioncCs:g}|jr| | |¡¡|jr0| | |¡¡d |¡S)Nro)rrr„rsr�r.r6©rr-r‡rrrÚ format_help+s zOptionContainer.format_helpN)rr(r)r.r&rrrrrr r%r'r(r)r*r+r.rsr1rrrrrxs"    rc@s6eZdZd dd„Zdd„Zdd„Zdd „Zd d „ZdS) rNcCs$||_t ||j|j|¡||_dSr)r;rr&rrÚtitle)rr;r2rrrrrr&6s  ÿzOptionGroup.__init__cCsg|_| |j¡dSr)r�rr;rrrrr<szOptionGroup._create_option_listcCs ||_dSr)r2)rr2rrrÚ set_title@szOptionGroup.set_titlecCst |¡|`dSr)rr r�rrrrr Cs zOptionGroup.destroycCs0| |j¡}| ¡|t ||¡7}| ¡|Sr)rer2r[rr1r\r0rrrr1Js  zOptionGroup.format_help)N)rr(r)r&rr3r r1rrrrr4s  rc @sbeZdZdZgZddedddddddf dd„Zdd„Zd d „Zd d „Z d d„Z dPdd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„ZdQd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Z dRdd?„Z"d@dA„Z#dSdBdC„Z$dDdE„Z%dTdFdG„Z&dUdHdI„Z'dJdK„Z(dVdLdM„Z)dWdNdO„Z*dS)Xra$ 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. NrTc Csrt ||||¡| |¡| |_||_d|_d|_|dur@tƒ}||_|j  |¡| |_ |j ||d�|  ¡dS)NT)Úadd_help) rr&Ú set_usageÚprogr¾Úallow_interspersed_argsÚprocess_default_valuesr r-rQrtÚ_populate_option_listÚ_init_parsing_state) rrar�rr¾rrrr-Zadd_help_optionr6rtrrrr&šs" ÿ  ÿzOptionParser.__init__cCs.t |¡|jD] }| ¡q|`|`|`dS)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)rr r�r�r-)rr’rrrr ¼s    zOptionParser.destroycCsg|_g|_| ¡dSr)r�r�rrrrrrÎsz OptionParser._create_option_listcCs|jdddtdƒd�dS)Nz-hz--helprvzshow this help message and exit©r±rv©r'r2rrrrÚ_add_help_optionÓsþzOptionParser._add_help_optioncCs|jddtdƒd�dS)Nz --versionr¾z&show program's version number and exitr;r<rrrrÚ_add_version_optionØsþz OptionParser._add_version_optioncCs>|jr| |j¡|r | |¡|jr.| ¡|r:| ¡dSr)Ústandard_option_listr(r¾r>r=)rr�r4rrrr9Ýs  z"OptionParser._populate_option_listcCsd|_d|_d|_dSr)ÚrargsÚlargsrírrrrr:çsz OptionParser._init_parsing_statecCsL|durtdƒ|_n4|tur$d|_n$| ¡ d¡rB|dd…|_n||_dS)Nz%prog [options]zusage: é)r2rarr¢r"r`rrrr5ðs zOptionParser.set_usagecCs d|_dS)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.TN©r7rrrrÚenable_interspersed_argsûsz%OptionParser.enable_interspersed_argscCs d|_dS)zéSet 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. FNrCrrrrÚdisable_interspersed_argssz&OptionParser.disable_interspersed_argscCs ||_dSr)r8)rrîrrrÚset_process_default_values sz'OptionParser.set_process_default_valuescCs||j|<dSr)rw)rryr¬rrrÚ set_defaultszOptionParser.set_defaultcKs|j |¡dSr)rwrý)rrôrrrÚ set_defaultsszOptionParser.set_defaultscCs*|jdd…}|jD]}| |j¡q|Sr)r�r�r†)rÚoptionsr’rrrÚ_get_all_optionss zOptionParser._get_all_optionscCs`|jst|jƒS|j ¡}| ¡D]4}| |j¡}t|tƒr"|  ¡}|  ||¡||j<q"t|ƒSr) r8rrwÚcopyrJrxryrÓr*rærè)rrwr,r²r0rrrÚget_default_valuess     zOptionParser.get_default_valuescOs€t|dtƒr&t|g|¢Ri|¤Ž}nJt|ƒdkrh|sh|d}t|tƒsTtd|ƒ‚|j|urptdƒ‚ntdƒ‚|j |¡|S)Nrr znot an OptionGroup instance: %rz"invalid OptionGroup (wrong parser)r&) rÓr*rrƒrÈr;rAr�r„)rrórôr’rrrÚadd_option_group+s     zOptionParser.add_option_groupcCs0|j |¡p|j |¡}|r,|j|ur,|jSdSr)rrxrr$)rr0r,rrrÚget_option_group;s   ÿzOptionParser.get_option_groupcCs&|durtjdd…S|dd…SdSr)rÚargv)rrórrrÚ _get_argsEszOptionParser._get_argsc CsŽ| |¡}|dur| ¡}||_g|_}||_z| |||¡}Wn6ttfyx}z| t |ƒ¡WYd}~n d}~00||}|  ||¡S)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) rPrLr@rAríÚ _process_argsrrrr*Ú check_values)rrórír@rAÚstopÚerrrrrÚ parse_argsKs   $zOptionParser.parse_argscCs||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írórrrrRrs zOptionParser.check_valuescCsˆ|r„|d}|dkr|d=dS|dd…dkr<| ||¡q|dd…dkrft|ƒdkrf| ||¡q|jr~| |¡|d=qdSqdS)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ÊNr9r rÉ)Ú_process_long_optrƒÚ_process_short_optsr7r„)rrAr@ríÚargrrrrQs  zOptionParser._process_argscCs t||jƒS)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_abbrevr)rr�rrrÚ_match_long_opt²szOptionParser._match_long_optc Csè| d¡}d|vr4| dd¡\}}| d|¡d}n|}d}| |¡}|j|}| ¡r¸|j}t|ƒ|krˆ| t dd|ƒ||dœ¡qÔ|dkrœ| d¡} qÔt |d|…ƒ} |d|…=n|rÐ| t d ƒ|¡nd} |  || ||¡dS) NrrXr TFú.%(option)s option requires %(number)d argumentú/%(option)s option requires %(number)d arguments©r,Únumberz%s option does not take a value) ÚpoprÚÚinsertrZrr–r³rƒrrrØr2rî) rr@rírXr�Znext_argZhad_explicit_valuer,r³r¬rrrrV»s6     ýý  zOptionParser._process_long_optc Csø| d¡}d}d}|dd…D]Ô}d|}|j |¡}|d7}|sJt|ƒ‚| ¡rÖ|t|ƒkrv| d||d…¡d}|j} t|ƒ| kr¦| t dd| ƒ|| dœ¡qÚ| dkrº| d¡} qÚt |d| …ƒ} |d| …=nd} |  || ||¡|rqôqdS) NrFr rÉTr[r\r]) r_rrxrr–rƒr`r³rrrØrî) rr@rírXrSÚiZchr�r,r³r¬rrrrWßs<    ýý  z OptionParser._process_short_optscCs&|jdurtj tjd¡S|jSdSrå)r6r>ÚpathÚbasenamerrOrrrrÚ get_prog_names zOptionParser.get_prog_namecCs| d| ¡¡S)Nz%prog)r|rd)rÚsrrrÚexpand_prog_nameszOptionParser.expand_prog_namecCs | |j¡Sr)rfrrrrrrrszOptionParser.get_descriptionrcCs|rtj |¡t |¡dSr)rÚstderrÚwriterñ)rÚstatusr$rrrrñs zOptionParser.exitcCs(| tj¡| dd| ¡|f¡dS)zÜerror(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. r9z%s: error: %s N)Ú print_usagerrgrñrdr%rrrrs zOptionParser.errorcCs"|jr|j | |j¡¡SdSdSr,)rar-rbrfrrrrÚ get_usage#s  ÿzOptionParser.get_usagecCs|jrt| ¡|d�dS)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)raÚprintrk©rrmrrrrj*s zOptionParser.print_usagecCs|jr| |j¡SdSdSr,)r¾rfrrrrÚ get_version6s zOptionParser.get_versioncCs|jrt| ¡|d�dS)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. rlN)r¾rnrprorrrrò<szOptionParser.print_versioncCsš|dur|j}| |¡g}| | tdƒ¡¡| ¡|jrZ| t ||¡¡| d¡|j D]}| |  |¡¡| d¡q`|  ¡d  |dd…¡S)NZOptionsrorRr‚) r-r“r„rer2r[r�rr.r�r1r\r6)rr-r‡r’rrrr.Gs    zOptionParser.format_option_helpcCs | |j¡Sr)rurtr/rrrruXszOptionParser.format_epilogcCsn|dur|j}g}|jr*| | ¡d¡|jrD| | |¡d¡| | |¡¡| | |¡¡d |¡Srn) r-rar„rkrrrsr.rur6r0rrrr1[szOptionParser.format_helpcCs |durtj}| | ¡¡dS)z°print_help(file : file = stdout) Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout). N)rÚstdoutrhr1rorrrrðgszOptionParser.print_help)T)NN)rN)N)N)N)N)N)+rr(r)r.r?rr&r rr=r>r9r:r5rDrErFrGrHrJrLrMrNrPrUrRrQrZrVrWrdrfrrñrrkrjrpròr.rur1rðrrrrrRsbDö "     ' 3 $)     rcsZˆ|vr ˆS‡fdd„| ¡Dƒ}t|ƒdkr6|dS|sDtˆƒ‚n| ¡tˆ|ƒ‚dS)zû_match_abbrev(s : string, wordmap : {string : Option}) -> 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. csg|]}| ˆ¡r|‘qSr)r")rZword©rerrr�€s ÿz!_match_abbrev..r rN)rÎrƒrÚsortr3)reZwordmapr4rrrrrYts  rY)'r.Ú __version__Ú__all__Z __copyright__rr>rirrrÚ ImportErrorr2Ú Exceptionr r rrrr3r r r r¦r§rªr¨r«r­rrzrrrrrrrrYrrrrrÚs`     P     ý uA=&