fvdZdZgdZddlZddlZddlZddl Z ddl m Z m Z dZd Zd Zd Zd Zd ZdZGddeZdZGddeZGddeZGddeZGddeZGddeZdZGddeZGdd eZ Gd!d"eZ!eZ"Gd#d$e!Z#Gd%d&e!Z$Gd'd(e!Z%Gd)d*e%Z&Gd+d,e%Z'Gd-d.e!Z(Gd/d0e!Z)Gd1d2e!Z*Gd3d4e!Z+Gd5d6e!Z,Gd7d8e!Z-Gd9d:e(Z.Gd;deZ0Gd?d@eZ1GdAdBe1Z2GdCdDe2Z3GdEdFee1Z4y#e $r dZ dZ YTwxYw)Ga Command-line parsing library This module is an optparse-inspired command-line parsing library that: - handles both optional and positional arguments - produces highly informative usage messages - supports parsers that dispatch to sub-parsers The following is a simple usage example that sums integers from the command-line and writes the result to a file:: parser = argparse.ArgumentParser( description='sum the integers at the command line') parser.add_argument( 'integers', metavar='int', nargs='+', type=int, help='an integer to be summed') parser.add_argument( '--log', default=sys.stdout, type=argparse.FileType('w'), help='the file where the sum should be written') args = parser.parse_args() args.log.write('%s' % sum(args.integers)) args.log.close() The module contains the following public classes: - ArgumentParser -- The main entry point for command-line parsing. As the example above shows, the add_argument() method is used to populate the parser with actions for optional and positional arguments. Then the parse_args() method is invoked to convert the args at the command-line into an object with attributes. - ArgumentError -- The exception raised by ArgumentParser objects when there are errors with the parser's actions. Errors raised while parsing the command-line are caught by ArgumentParser and emitted as command-line messages. - FileType -- A factory for defining types of files to be created. As the example above shows, instances of FileType are typically passed as the type= argument of add_argument() calls. - Action -- The base class for parser actions. Typically actions are selected by passing strings like 'store_true' or 'append_const' to the action= argument of add_argument(). However, for greater customization of ArgumentParser actions, subclasses of Action may be defined and passed as the action= argument. - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter, ArgumentDefaultsHelpFormatter -- Formatter classes which may be passed as the formatter_class= argument to the ArgumentParser constructor. HelpFormatter is the default, RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser not to change the formatting for help text, and ArgumentDefaultsHelpFormatter adds information about argument defaults to the help. All other classes in this module are considered implementation details. (Also note that HelpFormatter and RawDescriptionHelpFormatter are only considered public as object names -- the API of the formatter objects is still considered an implementation detail.) z1.1)ArgumentParser ArgumentErrorArgumentTypeErrorBooleanOptionalActionFileType HelpFormatterArgumentDefaultsHelpFormatterRawDescriptionHelpFormatterRawTextHelpFormatterMetavarTypeHelpFormatter NamespaceAction ONE_OR_MOREOPTIONALPARSER REMAINDERSUPPRESS ZERO_OR_MOREN)gettextngettextc|SN)messages /usr/lib/python3.12/argparse.py_rasc|dk(r|S|SNr)singularpluralns rrrcs 6OMrz ==SUPPRESS==?*+zA......_unrecognized_argsc"eZdZdZdZdZdZy)_AttributeHolderaAbstract base class that provides __repr__. The __repr__ method returns a string in the format:: ClassName(attr=name, attr=name, ...) The attributes are determined either by a class-level attribute, '_kwarg_names', or by inspecting the instance __dict__. ct|j}g}i}|jD]}|jt ||j D]1\}}|j r|j|d|-|||<3|r|jdt |z|ddj|dS)N=z**%s(, ))type__name__ _get_argsappendrepr _get_kwargs isidentifierjoin)self type_name arg_strings star_argsargnamevalues r__repr__z_AttributeHolder.__repr__sJ''   >># *C   tCy ) *++- (KD%  """dE#:;"' $  (    vY7 8$dii &<==rcHt|jjSr)list__dict__itemsr8s rr5z_AttributeHolder._get_kwargssDMM'')**rcgSrrrDs rr2z_AttributeHolder._get_argss rN)r1 __module__ __qualname____doc__r?r5r2rrrr*r*vs >+rr*c`|gSt|tur|ddSddl}|j|SNr)r0rAcopy)rCrKs r _copy_itemsrLs5 }  E{dQx 99U rceZdZdZ ddZdZdZGddeZdZ d Z d Z d Z d d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy)!rzFormatter for generating usage messages and argument help strings. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. Nc|$ ddl}|jj}|dz}||_||_t |t|dz |dz|_||_ d|_ d|_ d|_ |j|d|_|j|_t!j"dt j$|_t!j"d|_y#t$rd}YwxYw)NrFz\s+z\n\n\n+)shutilget_terminal_sizecolumns ImportError_prog_indent_incrementminmax_max_help_position_width_current_indent_level_action_max_length_Section _root_section_current_section_recompileASCII_whitespace_matcher_long_break_matcher)r8progindent_incrementmax_help_positionwidth_shutils r__init__zHelpFormatter.__init__s = (113;;  !1"%&7&)%"*6F6J&K#M   "#!]]46 $ 2 2#&;;vsyy#A #&;;z#: #  s#C C,+C,cl|xj|jz c_|xjdz c_yrr\rWr]rDs r_indentzHelpFormatter._indents'  6 66 q rc|xj|jzc_|jdk\sJd|xjdzc_y)NrzIndent decreased below 0.r rnrDs r_dedentzHelpFormatter._dedentsA  6 66##q(E*EE( q rceZdZddZdZy)HelpFormatter._SectionNc<||_||_||_g|_yr) formatterparentheadingrC)r8rurvrws rrlzHelpFormatter._Section.__init__s&DN DK"DLDJrc |j|jj|jj}||jDcgc] \}}|| c}}}|j|jj |sy|j turM|j A|jj}tdt|j z}d|d|fz}nd}|d||dgScc}}w)Nz %(heading)s:)rw%*s%s  ) rvruro _join_partsrCrqrwrr\rdict)r8r7funcargs item_helpcurrent_indent heading_textrws r format_helpz"HelpFormatter._Section.format_helps{{&&&(>>--DDJJGjdDdDkGHI{{&&&(||8+ 0H!%!?!? 04 3MM #~r<&HHw 489 9#HsC; r)r1rFrGrlrrrrr_rss    :rr_cR|jjj||fyr)rarCr3)r8r~rs r _add_itemzHelpFormatter._add_items  ##**D$<8rc|j|j||j|}|j|jg||_yr)ror_rarr)r8rwsections r start_sectionzHelpFormatter.start_sections? --d&;&;WE w**B/ 'rcZ|jj|_|jyr)rarvrqrDs r end_sectionzHelpFormatter.end_sections $ 5 5 < < rcV|tur!||j|j|gyyyr)rr _format_text)r8texts radd_textzHelpFormatter.add_texts- x D$4 NN4,,tf 5%5 rcZ|tur#||||f}|j|j|yyr)rr _format_usage)r8usageactionsgroupsprefixrs r add_usagezHelpFormatter.add_usage s1  '661D NN4--t 4 !rcn|jtur|j}||g}|j|D]}|j ||t t t|}||jz}t |j||_ |j|j|gyyr) helpr_format_action_invocation_iter_indented_subactionsr3rYmaplenr\r^r_format_action)r8actionget_invocation invocations subactioninvocation_length action_lengths r add_argumentzHelpFormatter.add_arguments ;;h &";;N)&12K!;;FC > "">)#<= >!$C[$9 : -0D0DDM&)$*A*A*7'9D # NN4.. 9 'rc4|D]}|j|yr)r)r8rrs r add_argumentszHelpFormatter.add_arguments#s &F   f % &rc|jj}|r0|jjd|}|j ddz}|S)N r{)r`rrfsubstrip)r8rs rrzHelpFormatter.format_help*sI!!--/ ++//=D::d#d*D rc^dj|Dcgc]}|r |tur|c}Scc}w)Nry)r7r)r8 part_stringsparts rr|zHelpFormatter._join_parts1s8ww$0: D$8:; ;:s*c| td}||t|jz}nB||sdt|jz}n#| dt|jz}g}g}|D]1}|jr|j |!|j |3|j } | ||z|} dj || fD cgc]} | s|  c} }|j|jz t|t|zkDr]d} | ||} | ||}tj| | }tj| |}dj || k(sJdj ||k(sJd fd }t|t|zdzkr[dt|t|zdzz}|r'||g|z||}|j|||nw|r||g|z||}nf|g}nbdt|z}||z}|||}t|dkDr2g}|j||||j||||g|z}d j |}||d Scc} w) Nzusage: rgz%(prog)s z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+cg}g}t|}|t|dz }n|dz }|D]d}|dzt|zkDr,|r*|j|dj|zg}|dz }|j||t|dzz }f|r#|j|dj|z| |d|d|d<|S)Nr rr)rr3r7) partsindentrlinesline indent_lengthline_lenr text_widths r get_linesz.HelpFormatter._format_usage..get_linesfsED$'KM)#&v;?#01#4 %2#a<#d)3j@T!LL#((4.)@A#%D'4q'8H D) CIM1 2 Vchhtn%<=)#(8MN#;a Lrg?r r{rr) rr}rVoption_stringsr3_format_actions_usager7r[r\rrbfindallextend)r8rrrrrg optionals positionalsrformat action_usages part_regexp opt_usage pos_usage opt_parts pos_partsrrrrrs @rrzHelpFormatter._format_usage6s >y\F  Ddjj11E]74::!66E]$** 55DIK! /(($$V,&&v.  ///F!)k"96BLHH$ )=CAaCDEt';';;J6{SZ'*4 #9f5 ";7 KK Y? KK Y? xx *i777xx *i777!,v;T*dZ.?? CK#d)$;a$?@F )4&9*&))=)=%>"005%)=)==/0,"'"6"6:%))&1!;;(2494: -?AY,Y)0  >> G+#ENd2N-0GEN'>#CLC/L+.GCL.2 G+#ENd2N-0GEN'>#CLC/L+.GCL"519c2)%( )S* )Z"7+- #IAv{{h& T";;q>S(KKN[[Q'3.KKA&**BB6J((9]*Aw#~$r(c/#Abz T"!' 5 5a 8 <<1$!..0D #DDVLG"&"3"3FG"DK&3[AD6+F!D=D T"[- #`. &A!!*E!AJ &xx%D$43CDEwwx$t4wwx%'5wwD%0#t<zz| O  xEsMM M  MMcd|vr|t|jz}t|j|jz d}d|jz}|j |||dzS)Nz%(prog)r rr)r}rVrYr[r\ _fill_text)r8rrrs rrzHelpFormatter._format_text s`  $DJJ//Dt';';;R@ t+++tZ86AArc`t|jdz|j}t|j|z d}||j z dz }|j |}|js|j d|f}d|z}n {{&&M9C%OM < /&&L-GC'#-ML&&M9C%OM(L ;;6;;,,.))&1I!..y*E  Y,JqM)JJK&qrNHDLLmR-F!FGH''- LL 77? 9I LL,,Y7 8 9&&rc|js-|j|}|j||d\}|Sg}|jdk(r|j |jnJ|j |}|j ||}|jD]}|j|d|dj|S)Nr rrr.) rr_metavar_formatterrrrrr3r7)r8rrmetavarrrrs rrz'HelpFormatter._format_action_invocationAs$$>>vFG?t..vw?BHGNE||q  V223 @@H"//@ %+%:%:IMLLM;!GHI99U# #rc|j |jnE|j7|jDcgc] }t|}}ddj|zn|fd}|Scc}w)Nz{%s},c4ttrSf|zSr) isinstancetuple) tuple_sizeresults rrz0HelpFormatter._metavar_formatter..formatbs&%( zJ..r)rchoicesstrr7)r8rdefault_metavarchoice choice_strsrrs @rrz HelpFormatter._metavar_formatterYse >> %^^F ^^ '5;^^D63v;DKDchh{33F$F /  EsA'c|j||}|j d|dz}|S|jtk(r d|dz}|S|jtk(r$|d}t |dk(rd|z}|Sd|z}|S|jt k(r d|dz}|S|jt k(rd}|S|jtk(r d |dz}|S|jtk(rd }|S t|jDcgc]}d}}d j|||jz}|Scc}w#t$r td dwxYw) Nz%sr rrOz [%s [%s ...]]z[%s ...]z %s [%s ...]r'z%s ...ryzinvalid nargs valuer) rrrrrrrrrr TypeErrorrr7)r8rr  get_metavarrrrformatss rrzHelpFormatter._format_argsis--foF << KN*F. -\\X %k!n,F* )\\\ )!!nG7|q (72" $g- \\[ ("[^3F \\Y &F \\V # A.F \\X %F  B).v||)<=A4==XXg&V\\)BBF > B !67TA Bs2D? D:D?:D??Ectt||j}t|D]}||tus||=t|D]$}t ||ds||j ||<&|jd0dj|dDcgc] }t|c}}||d<|j||zScc}w)Nrr1rr.) r}varsrVrArhasattrr1rr7r_get_help_string)r8rparamsr=c choices_strs rrzHelpFormatter._expand_helpsd6l4L !Dd|x'4L !L 5Dvd|Z0%d|44t  5 ::i ,))VI5F$GSV$GHK +F9 $$V,v55%HsCc#K |j}|j|Ed{|jy7#t$rYywxYwwr)_get_subactionsrorqAttributeError)r8rget_subactionss rrz'HelpFormatter._iter_indented_subactionssN #33N LLN%' ' ' LLN (    s1A AAAA A A AAc|jjd|j}ddl}|j ||S)Nrr)rerrtextwrapwrap)r8rrjrs rrzHelpFormatter._split_liness9''++C6<<> }}T5))rc|jjd|j}ddl}|j ||||S)Nrr)initial_indentsubsequent_indent)rerrrfill)r8rrjrrs rrzHelpFormatter._fill_textsF''++C6<<>}}T5,2/57 7rc|jSr)rr8rs rrzHelpFormatter._get_help_string {{rc6|jjSr)destupperr#s rrz/HelpFormatter._get_default_metavar_for_optionals{{  ""rc|jSr)r&r#s rrz1HelpFormatter._get_default_metavar_for_positionalr$r)rONr) r1rFrGrHrlrorqobjectr_rrrrrrrrr|rrrrrrrrrrrrrrrrrrrs#$#% ;D :6:@9 ( 65 :$&; _,BqfB.'`$0 8 6*7#rrceZdZdZdZy)r zHelp message formatter which retains any formatting in descriptions. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cXdjfd|jdDS)Nryc3(K|] }|z ywrr).0rrs r z9RawDescriptionHelpFormatter._fill_text..sPv}PsT)keepends)r7 splitlines)r8rrjrs `rrz&RawDescriptionHelpFormatter._fill_texts#wwP$1OPPPrN)r1rFrGrHrrrrr r s  Qrr ceZdZdZdZy)r zHelp message formatter which retains formatting of all help text. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. c"|jSr)r1)r8rrjs rrz!RawTextHelpFormatter._split_liness  rN)r1rFrGrHrrrrr r s  !rr ceZdZdZdZy)rzHelp message formatter which adds default values to argument help. Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. c|j}|d}d|vrF|jtur4ttg}|j s|j |vr|tdz }|S)a6 Add the default value to the option help message. ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't already present. This code will do that, detecting cornercases to prevent duplicates or cases where it wouldn't make sense to the end user. ryz %(default)z (default: %(default)s))rrrrrrrr)r8rrdefaulting_nargss rrz.ArgumentDefaultsHelpFormatter._get_help_strings`{{ <D t #~~X-$,l#; ((FLL>wtT*+>>>!c |jdSrJ)rrDs rrzAction.format_usage~s""1%%rc*ttd)Nz.__call__() not defined)NotImplementedErrorrr8parser namespacevaluesrs r__call__zAction.__call__s!!$=">??rNNNNNFNNr)r1rFrGrHrlr5rrYrrrr r &s70j, ?&@rr c:eZdZdeeddeffd ZddZdZxZS)rNFc bg} |D]>} | j| | jds&d| ddz} | j| @dD].} t| tust j | dd0|turd}|turd}|turd}t || |d|||||| y) N----no-rO)r0rrzP{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.))remover) rr&rrr0rrrr)r3 startswithlocals_deprecated_defaultwarnings _deprecatedsuperrl) r8rr&rr0rrrr_option_stringsr field_name __class__s rrlzBooleanOptionalAction.__init__s+ 6M  " "= 1''- '-*; ; &&}5  69 $Jx #+>>$$2" $ $ & &D ) )G ) )G *  rcp||jvr(t||j|jd yy)Nr^)rsetattrr&rbrUs rrYzBooleanOptionalAction.__call__s3 D// / Ityym.F.Fw.O*O P 0rc8dj|jS)Nz | )r7rrDs rrz"BooleanOptionalAction.format_usageszz$--..rr)r1rFrGrdrlrYr __classcell__rjs@rrrs(),,-`Q/rrc8eZdZ dfd ZddZxZS) _StoreActionc |dk(r td||tk7rtdtztt|||||||||| |  y)Nrznargs for store actions must be != 0; if you have nothing to store, actions such as store true or store const may be more appropriate nargs must be %r to supply constrJ)rrrgrqrl r8rr&rrKrr0rrrrrjs rrlz_StoreAction.__init__ss A:KL L  (!2?(JK K lD*) + rc2t||j|yr)rlr&rUs rrYz_StoreAction.__call__s 499f-rrZrr1rFrGrlrYrnros@rrqrqs' :.rrqc2eZdZ dfd ZddZxZS)_StoreConstActionc :tt| ||d||||y)Nr)rr&rrKrrr)rgrxrl r8rr&rKrrrrrjs rrlz_StoreConstAction.__init__s/ /) 0 rcFt||j|jyr)rlr&rKrUs rrYz_StoreConstAction.__call__s 499djj1rNNFNNrrvros@rrxrxs "2rrxc&eZdZ dfd ZxZS)_StoreTrueActionc8tt| ||d|||y)NTrr&rKrrr)rgr~rlr8rr&rrrrjs rrlz_StoreTrueAction.__init__s, .) / r)FFNr1rFrGrlrnros@rr~r~s   rr~c&eZdZ dfd ZxZS)_StoreFalseActionc8tt| ||d|||y)NFr)rgrrlrs rrlz_StoreFalseAction.__init__s, /) 0 r)TFNrros@rrr s   rrc8eZdZ dfd ZddZxZS) _AppendActionc |dk(r td||tk7rtdtztt|||||||||| |  y)Nrznargs for append actions must be != 0; if arg strings are not supplying the value to append, the append const action may be more appropriatersrJ)rrrgrrlrts rrlz_AppendAction.__init__ss A:OP P  (!2?(JK K mT+) , rct||jd}t|}|j|t ||j|yr)rNr&rLr3rlr8rVrWrXrrCs rrYz_AppendAction.__call__<: 499d3E" V 499e,rrZrrvros@rrrs' :-rrc2eZdZ dfd ZddZxZS)_AppendConstActionc <tt| ||d|||||y)Nr)rr&rrKrrrr)rgrrlrzs rrlz_AppendConstAction.__init__Es2  $0) 1 rct||jd}t|}|j|jt ||j|yr)rNr&rLr3rKrlrs rrYz_AppendConstAction.__call__Ws> 499d3E" TZZ  499e,rr|rrvros@rrrCs $-rrc.eZdZ dfd ZddZxZS) _CountActionc8tt| ||d|||y)Nr)rr&rrrr)rgrrlrs rrlz_CountAction.__init__`s+ lD*) + rcnt||jd}|d}t||j|dzy)Nrr )rNr&rl)r8rVrWrXrcounts rrYz_CountAction.__call__ns2 499d3 =E 499eai0r)NFNrrvros@rrr^s  1rrc.eZdZeedffd ZddZxZS) _HelpActionNc6tt| |||d|y)Nrrr&rrr)rgrrl)r8rr&rrrjs rrlz_HelpAction.__init__ws( k4)) * rcD|j|jyr) print_helpexitrUs rrYz_HelpAction.__call__s rrr1rFrGrrlrYrnros@rrrus! rrc0eZdZdeedffd ZddZxZS)_VersionActionNc^| td}tt||||d|||_y)Nz&show program's version number and exitrr)rrgrrlversion)r8rrr&rrrjs rrlz_VersionAction.__init__sA <=>D nd,) -   rc|j}| |j}|j}|j||j|j t j |jyr)r_get_formatterr_print_messager_sysstdoutr)r8rVrWrXrrrus rrYz_VersionAction.__call__s[,, ?nnG))+ 7#i335t{{C rrrros@rrrs!  rrcReZdZGddeZedddffd ZdZdZd dZ xZ S) _SubParsersActionceZdZfdZxZS)&_SubParsersAction._ChoicesPseudoActionc|x}}|r|ddj|zz }ttj|}|j g|||y)Nrr.)rr&rr)r7rgr_ChoicesPseudoActionrl)r8r=aliasesrrr&suprjs rrlz/_SubParsersAction._ChoicesPseudoAction.__init__sU! !Gd7TYYw%777)>>EC LLD!(  *rrros@rrrs  * *rrFNc ||_||_i|_g|_tt |||t|j|||y)N)rr&rrrrr) _prog_prefix _parser_class_name_parser_map_choices_actionsrgrrlr) r8rrg parser_classr&rrrrjs rrlz_SubParsersAction.__init__sU!) " " /))) 0 rc |jd|jd||d<|jdd}||jvrt |t d|z|D](}||jvst |t d|zd|vr?|jd}|j |||}|jj||jdi|}||j|<|D]}||j|<|S)Nrgrrrzconflicting subparser: %szconflicting subparser alias: %sr) rrrrrrrrr3r)r8r=kwargsraliasr choice_actionrVs r add_parserz_SubParsersAction.add_parsers( ::f  %(,(9(94@F6N**Y+ 4(( (a(C&Dt&KL L HE---#!=>FHH H V ::f%D 55dGTJM  ! ! ( ( 7$##-f-&,d# 2E+1D ! !% ( 2 rc|jSr)rrDs rrz!_SubParsersAction._get_subactionss$$$rc|d}|dd}|jturt||j| |j|}|j|d\} }t| jD]\} } t|| | |r?t|jtgt|tj|yy#t$r9|dj |jd}t d|z}t||wxYw)Nrr r.) parser_namerz5unknown parser %(parser_name)r (choices: %(choices)s))r&rrlrKeyErrorr7rrparse_known_argsrrC setdefault_UNRECOGNIZED_ARGS_ATTRrNr) r8rVrWrXrrr:rmsg subnamespacekeyr>s rrYz_SubParsersAction.__call__sQi QRj  99H $ Ityy+ 6 +**;7F%+$;$;K$N! k|,224 +JC IsE * +  O & &'> C I6 7 > >{ K # +#.#yy)>)>?ADKLtSCc* *  +s C AD r) r1rFrGr rrrlrrrYrnros@rrrs2*v*.<%LrrceZdZddZy) _ExtendActionNct||jd}t|}|j|t ||j|yr)rNr&rLrrlrs rrYz_ExtendAction.__call__ rrr)r1rFrGrYrrrrrs-rrc$eZdZdZddZdZdZy)raFactory for creating file object types Instances of FileType are typically passed as type= arguments to the ArgumentParser add_argument() method. Keyword Arguments: - mode -- A string indicating how the file is to be opened. Accepts the same values as the builtin open() function. - bufsize -- The file's desired buffer size. Accepts the same values as the builtin open() function. - encoding -- The file's encoding. Accepts the same values as the builtin open() function. - errors -- A string indicating how encoding and decoding errors are to be handled. Accepts the same value as the builtin open() function. Nc<||_||_||_||_yr)_mode_bufsize _encoding_errors)r8modebufsizeencodingerrorss rrlzFileType.__init__$s  ! rcF|dk(rdjvr8djvrtjjStjSt fddDr8djvrtj jStj St djz}t| t|jjjjS#t$r#}||d}t d}t||zd}~wwxYw) N-rbc3:K|]}|jvywr)r)r.rr8s rr/z$FileType.__call__../s4Q$**_4swaxzargument "-" with mode %r)filenameerrorz$can't open '%(filename)s': %(error)s)rrstdinbufferanyrrrrrrrOSErrorr)r8stringrerrs` rrYzFileType.__call__*s S=djj ,/4::,=tzz((M4::M4e44-0DJJ->t{{))ODKKO34tzzA o% 4 DMM4>> & & 4 &3D>?G#GdN3 3 4s=6C44 D =DD c L|j|jf}d|jfd|jfg}dj |Dcgc]}|dk7s t |c}|Dcgc]\}}||d|c}}z}t |jd|dScc}wcc}}w)Nrrr.rr,r-r/)rrrrr7r4r0r1)r8rrr<kwargs_strs rr?zFileType.__repr__>szz4==(t~~.4<<0HI994EC3"9d3iEAG2gb#!$*,S1223 :..99F2s B B#B )rrNN)r1rFrGrHrlrYr?rrrrrs  4(:rrc"eZdZdZdZdZdZy)r zSimple object for storing attributes. Implements equality by attribute names and values, and provides a simple string representation. c 2|D]}t||||yr)rl)r8rr=s rrlzNamespace.__init__Qs! .D D$t - .rc\t|tstSt|t|k(Sr)rr NotImplementedr)r8others r__eq__zNamespace.__eq__Us%%+! !DzT%[((rc||jvSr)rB)r8rs r __contains__zNamespace.__contains__Zsdmm##rN)r1rFrGrHrlrrrrrr r Js .) $rr ceZdZfdZdZddZdZdZdZdZ dZ d Z d Z d Z d Zd ZddZdZdZdZdZxZS)_ActionsContainerc@tt| ||_||_||_||_i|_|jddt|jddt|jddt|jddt|jddt|jddt|jddt|jddt|jdd t |jdd t"|jdd t$|jdd t&|j)g|_i|_g|_g|_i|_t5j6d |_g|_y)Nrstore store_const store_true store_falser3 append_constrrrparsersrz^-\d+$|^-\d*\.\d+$)rgrrl descriptionargument_default prefix_charsconflict_handler _registriesregisterrqrxr~rrrrrrrr _get_handler_actions_option_string_actions_action_groups_mutually_exclusive_groups _defaultsrbrc_negative_number_matcher_has_negative_number_optionals)r8rrrrrjs rrlz_ActionsContainer.__init__`s\ /1& 0( 0 hl3 h6 h /@A h .>? h /@A h-8 h0BC h6 h 4 h >: h +<= h-8  &(#!*,'), 4I(J%/1+rcF|jj|i}|||<yr)rr)r8 registry_namer>r*registrys rrz_ActionsContainer.registers###..}bA rc@|j|j||Sr)rr)r8rr>rs r _registry_getz_ActionsContainer._registry_gets  .225'BBrc |jj||jD]%}|j|vs||j|_'yr)rupdaterr&r)r8rrs r set_defaultsz_ActionsContainer.set_defaultssE f%mm 5F{{f$!' !4 5rc|jD],}|j|k(s|j |jcS|jj |dSr)rr&rrr)r8r&rs r get_defaultz_ActionsContainer.get_defaultsMmm &F{{d"v~~'A~~% &~~!!$--rc|j}|rt|dk(r.|dd|vr$|rd|vr td|j|i|}n|j|i|}d|vrA|d}||j vr|j ||d<n|j |j |d<|j|}t|std|d|di|}|jd |j|j}t|st|d |turt|d t|d r! |jj|d|j!|S#t$r td wxYw)z add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...) r rr&z+dest supplied twice for positional argumentrNzunknown action ""r0z is not callablez: is a FileType class object, instance of it must be passedrz,length of metavar tuple does not match nargsr)rrr_get_positional_kwargs_get_optional_kwargsrr_pop_action_classcallablerr0rrrrr  _add_action)r8rrcharsr& action_classr type_funcs rrz_ActionsContainer.add_arguments!!s4yA~$q'!*E*A&( !NOO0T00$A&AF/T..??F F "&>Dt~~%$(NN4$8y!&&2$($9$9y!--f5  %lDE E''&&vv{{FKKH  "Y@A A  2;>? ? 4) * Q##%2264@'' Q !OPP Qs 8 E))E>cZt|g|i|}|jj||Sr)_ArgumentGrouprr3)r8rrrs radd_argument_groupz$_ActionsContainer.add_argument_groups/t5d5f5 ""5) rc Tt|fi|}|jj||Sr)_MutuallyExclusiveGrouprr3)r8rrs radd_mutually_exclusive_groupz._ActionsContainer.add_mutually_exclusive_groups*'77 ''..u5 rcV|j||jj|||_|jD]}||j |<|jD]F}|j j|s|jr,|jjdH|S)NT) _check_conflictrr3 containerrrrmatchr)r8rrs rrz_ActionsContainer._add_actions V$ V$$22 @M9?D ' ' 6 @$22 EM,,22=A::77>>tD E  rc:|jj|yr)rrar#s r_remove_actionz _ActionsContainer._remove_actions V$rci}|jD]B}|j|vr#td}t||jz|||j<Di}|jD]r}|j|vr?|j |j|j |j ||j<|jD]}||j||<t|jD]4}|j|j}|jD]}|||< 6|jD]#}|j||j|%y)Nz.cannot merge actions - two groups are named %r)titlerr)r)rr!rrrrrrrrrrrr)r8rtitle_group_maprr group_mapr mutex_groups r_add_container_actionsz(_ActionsContainer._add_container_actionssi(( 1E{{o-HI  !455+0OEKK (  1 -- AE{{/1/3/F/F++ % 1 1%*%;%;0G0= ,  .. A$3EKK$@ &! A A"99 0E;;<)K .. 0$/ &! 0  0 (( >!%F:  ::g , .9F3J!%F: Fb99rcg}g}|D]~}|d|jvr(||jd}td}t||z|j|t |dkDs\|d|jvsn|j||j dd}|U|r|d}n|d}|j |j}|std}t|z|jdd}t||| S) Nr)optionrzNinvalid option string %(option)r: must start with a character %(prefix_chars)rr r&z%dest= is required for options like %rrrr') rrrr3rrlstripreplacer}) r8rrrlong_option_stringsrrr&dest_option_strings rr z&_ActionsContainer._get_optional_kwargs?s$ ! :M #t'8'88"/(,(9(9;GH t,,  ! !- 0=!A%-*:d>O>O*O#**=9 :zz&$' <"%8%;"%3A%6"%,,T->->?D?@ }!455<<S)DFnEErcL|jd|}|jd||S)Nr)rr)r8rrrs rrz#_ActionsContainer._pop_action_classas'Hg.!!(FF;;rcd|jz} t||S#t$r$td}t ||jzwxYw)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rrNrrr)r8handler_func_namers rrz_ActionsContainer._get_handleresV1D4I4II :4!23 3 :;&3%=>FGo$=>>%=s A c|D]d\}}|jj||jj|d|jrJ|jj |fyr)rrarrrr)r8rr5rs r_handle_conflict_resolvez*_ActionsContainer._handle_conflict_resolvesc&9 8 !M6  ! ! ( ( 7  ' ' + +M4 @((  //7 8rr)r1rFrGrlrrrr rrrrrr%r r rrrr7r9rnros@rrr^sc01j!C 5.1(f  *%&eZdZdfd ZfdZfdZfdZxZS)rc |j}|d|j|d|j|d|jtt |}|dd|i|||_g|_|j|_ |j|_ |j|_ |j|_ |j|_ |j|_y)Nrrrrr)rrrrrgrrlr!rrrrrrr)r8rr!rrr super_initrjs rrlz_ArgumentGroup.__init__s""!9#=#=>~y556!9#=#=>>49 5{5f5  %00!** &/&F&F#",,  4 4 +*3*N*N'rcdtt| |}|jj ||Sr)rgrrrr3r8rrjs rrz_ArgumentGroup._add_actions-~t8@ ""6* rcbtt| ||jj |yr)rgrrrrar>s rrz_ArgumentGroup._remove_actions& nd26: ""6*rcZtjdtdt||i|S)Nz&Nesting argument groups is deprecated.rOcategory stacklevel)rewarnDeprecationWarningrgrr8rrrjs rrz!_ArgumentGroup.add_argument_groups/ 4' w)4:6::rNN)r1rFrGrlrrrrnros@rrrsO, +;;rrc6eZdZdfd ZdZdZfdZxZS)rcHtt| |||_||_yr)rgrrlr _container)r8rrrjs rrlz _MutuallyExclusiveGroup.__init__s! %t5i@  #rc|jrtd}t||jj |}|j j ||S)Nz-mutually exclusive arguments must be optional)rrrrJrrr3)r8rrs rrz#_MutuallyExclusiveGroup._add_actionsK ??CDCS/ !,,V4 ""6* rcp|jj||jj|yr)rJrrrar#s rrz&_MutuallyExclusiveGroup._remove_actions( &&v. ""6*rcZtjdtdt||i|S)Nz0Nesting mutually exclusive groups is deprecated.rOrA)rerDrErgrrFs rrz4_MutuallyExclusiveGroup.add_mutually_exclusive_groups/ >' w3TDVDDr)F)r1rFrGrlrrrrnros@rrrs$ +EErrc eZdZdZddddgedddddddf fd ZdZdZd Zd Z d Z d#d Z d#d Z dZ dZdZdZdZdZdZdZd#dZd#dZdZdZdZdZdZdZd$dZd$dZd$d Zd%d!Z d"Z!xZ"S)&raKObject for parsing command line strings into Python objects. Keyword Arguments: - prog -- The name of the program (default: ``os.path.basename(sys.argv[0])``) - usage -- A usage message (default: auto-generated from arguments) - description -- A description of what the program does - epilog -- Text following the argument descriptions - parents -- Parsers whose arguments should be copied into this one - formatter_class -- HelpFormatter class for printing help messages - prefix_chars -- Characters that prefix optional arguments - fromfile_prefix_chars -- Characters that prefix files containing additional arguments - argument_default -- The default value for all arguments - conflict_handler -- String indicating how to handle conflicts - add_help -- Add a -h/-help option - allow_abbrev -- Allow long options to be abbreviated unambiguously - exit_on_error -- Determines whether or not ArgumentParser exits with error info when an error occurs NrrTc tt| }|||| | |0tjj t jd}||_||_ ||_ ||_ ||_ | |_ | |_| |_|j }|t#d|_|t#d|_d|_d}|j+dd|d|vrdn|d}|jr,|j-|dz|d zd zd t.t#d  |D];}|j1| |j2}|j2j5|=y#t6$rYJwxYw) N)rrrrrzpositional argumentsoptionsc|Srr)rs ridentityz)ArgumentParser.__init__..identitysMrr0rhrOrzshow this help message and exit)rrr)rgrrl_ospathbasenamerargvrgrepilogformatter_classfromfile_prefix_charsadd_help allow_abbrev exit_on_errorrr _positionals _optionals _subparsersrrrr%rrr)r8rgrrrXparentsrYrrZrrr[r\r] superinit add_grouprRdefault_prefixrvdefaultsrjs rrlzArgumentParser.__init__su.$8 k+#3#3 5 <88$$TYYq\2D   .%:"  (*++ %a(>&?@#AiL1  fdH-!$| 3a ==   s"N1$4V$;x89  ;  0F  ' ' / 0!++%%h/ 0"  s5 E E+*E+cLgd}|Dcgc]}|t||fc}Scc}w)N)rgrrrYrr[rMrOs rr5zArgumentParser._get_kwargs2s+ 9>>wtT*+>>>rQc |j|jtd|jdt |d|vsd|vrNt|j dd}t|j dd}|j |||_n|j|_|jdk|j}|j}|j}|j|j||d|jj|d<|j!|d}|d d gi|}|jj#||S) Nz(cannot have multiple subparser argumentsrr!r subcommandsrgryrrr)r`rrrr0rrr^rr_get_positional_actionsrrrrrrr) r8rr!rrurr parsers_classrs radd_subparserszArgumentParser.add_subparsers@s>    ' JJqCD E .$t*5 f   7fjj-89EFJJ}d; ?    %"&"8"8y"I 4#44T9EOIt 95 6 KK +BC D I6 7$! % 3s8$$ %s"E E=E88E=c X !"jjijD]h}|j}t |jD]B\}}j |g}|j |d||j ||dzdDjig}t} t | D]b\}} | dk(r*|jd| D]} |jd5j| } | d} n| |<d} |j| ddj|t t!d !fd ""fd} j"fd }gd }r t}nd }||kr_tDcgc] }||k\r| c}}||k7r||}||kDr|}8|}|vr||}j ||}| |}||kr_||}j |dg}jD]}| vs|j r|jt#|/|j$.take_actions   V $"..v7GHO fnn4(,,V4'7';';FB'GGO&*BB >?&6&G +FC+4EFF Gh.tYG/rc|}|\}}}}j}g} |j||dzS|||d}j} |dk(r|d| vr|dk7r|s|d| vrtd} t || |z|j|g|f|d} | |dz}j } || vr$| |}|dd}|sdx}}n|ddk(rd}|dd}nd}nj| |z|dz} np|dk(r|dz} |g}|j|||fnNtd} t || |z|dz}|d}|||}||z} || }|j|||fnE|sJ|D]\}}}|||| S)Nr r{rryzignored explicit argument %rr,)_match_argumentr3rrrr) start_index option_tuplerrsep explicit_argmatch_argument action_tuples arg_countrrchar optionals_mapstoprrselected_patternsr:arg_strings_patternextrasoption_string_indicesr8rs rconsume_optionalz:ArgumentParser._parse_known_args..consume_optionals91=L7C 4FM3 "11NM>MM+k":;&?* + .vs ;I !--E!Q)!,E9(B.,q/U":"#$B"CC"/l8J"KK%,,fb--HI,Q/(,|A(> (,(C(C (M9%2=%AF+7+;L#/59 9l!-aC!7&)/;AB/? &("MM$*=>#.?D!#a*Q ,~%,,fdM-JK  >?+FC,4FGG (!OE(;EF(C% .v7H II 9,D&uT2D!((&$ )FGEL! =/< 9+mFD-8 9Krc j}|d}| |}t |D]\}}|||z}||z } || t|d dd|Sr)_match_arguments_partialzipr) r match_partialselected_pattern arg_countsrrrr:rrr8rs rconsume_positionalsz=ArgumentParser._parse_known_args..consume_positionals>s 99M2;<@ &{4DEJ&)j%A *! "; i0GHy( FD) *)Z)9:KN rrrz(the following arguments are required: %sr.z#one of the arguments %s is requiredrr)rZ_read_args_from_filesrrrrriterr3_parse_optionalr7rrirYrXrrrArrrrr&rNrl _get_valuerrrr)#r8r:rWr$rr mutex_action conflictsarg_string_pattern_partsarg_strings_iter arg_stringrpatternrrrmax_option_string_indexrnext_option_string_indexpositionals_end_indexstrings stop_indexrequired_actionsrrrPrrrrrrrrrs#``` @@@@@@@@rrwz ArgumentParser._parse_known_argss  % % 144[AK:: 8K'66M#,[-G-G#H 8<,77 bI   r!23  q1uv!67 8 8!##%  ,&'78 9MAzT!(//4"29J,33C89 $33J? '!G/;)!,!G(//8# 9(!gg&>?u #&5  H H*S S n224   ( &)*?&@ #&( #44(+2,)K',)(* $66(;K(H%);6"7K"7K"77%k2JK g&6 +;7K544:)5   k*+./mm IF\)??$++,>37 6;;7')V[[*II 6;; $ GI I  JJqCDyy!123 444 6E~~#22 6F!99 6,1+?+?=!' & 8 ;.f5=E=ABCJJsSXXe_45 6&  M,)~=s N"$N'c6g}|D]}|r|d|jvr|j|( t|ddtjtj 5}g}|j jD])}|j|D]}|j|+|j|}|j|ddd|S#1swY xYw#t$r%}|jt|Yd}~d}~wwxYw)Nrr )rr)rZr3rrgetfilesystemencodinggetfilesystemencodeerrorsreadr1convert_arg_line_to_argsrrrrr)r8r:new_arg_stringsr args_filearg_liner<rys rrz$ArgumentParser._read_args_from_filess% )JAd6P6P!P&&z2 )jn'+'A'A'C%)%C%C%EG""rc \g}tt|ddD]}|d|}dj|Dcgc]}|j|c}}t j ||}|O|j |jD cgc] } t| c} |S|Scc}wcc} w)Nrrry)rrr7rrbrrr) r8rrrr actions_slicerrrrs rrz'ArgumentParser._match_arguments_partialss7|Q+ A#BQKMgg-:<#) $66v><=GIIg':;E  Hvs6{HI   <Is B$ B) c ~|sy|d|jvry||jvr|j|}||ddfSt|dk(ry|jd\}}}|r#||jvr|j|}||||fS|j |}t|dkDrOdj |Dcgc] \}}}}| c}}}}}||d}t d} |j| |znt|dk(r|\} | S|jj|r |jsyd|vryd|ddfScc}}}}w)Nrr r,r.)r)matchesz4ambiguous option: %(option)s could match %(matches)sr) rrr partition_get_option_tuplesr7rrrrr) r8rrrrr option_tuplesrPrrrs rrzArgumentParser._parse_optionals!} 1 11 44 400!%!)8F 6;;7 ' 6;; ? C1iPQ 6;;7 8*9F#)#4#4FL%+%8%8FN9224I 9(,F+1??F(&+FO,"<<+E*/..E'%*EN+%)$9$9.:C%E! 6(;F&,&:&:FO;!<<9E%*%8%8EN9$DJ&  u 5  I:*9F#)#4#4FL%+%8%8FN9"(;F&,&:&:FO;!<<9E%*%8%8EN9$DJsU!I,$(I1 K$)BI7=I76I7:K$ AJ%&:K$7+J""K$%|jdt fvr*|\}|j||}|j|||S|jtk(r!|Dcgc]}|j||}}|S|jtk(r6|Dcgc]}|j||}}|j||d|S|jtk(rt}|S|Dcgc]}|j||}}|D]}|j|||S#t $rYwxYwcc}wcc}wcc}w)Nr]r r)rrrrrarrrKrrrr _check_valuerrr)r8rr:r>rvs rr~zArgumentParser._get_values s-$$fi=P)P ""4( v||x7$$ %%6!!&%0P I&,,,">''~~)!!&%0@ 9$8 3  "v||h7G'G%KJOOFJ7E   fe ,, '\\Y &9DEAT__VQ/EEE$ \\V #9DEAT__VQ/EEE   feAh / \\X %E :EEAT__VQ/EEE -!!&!, - g  BFFFs#HH&H+ H0 H#"H#c|jd|j|j}t|std}t |||z ||}|S#t $r}t |}t ||d}~wttf$rJt|jdt|j}||d}td}t |||zwxYw)Nr0z%r is not callabler1)r0r>z!invalid %(type)s value: %(value)r) rr0rrrrrr rrNr4) r8rrrrrryr=rs rrzArgumentParser._get_value s&&vv{{FKKH  "()Ci8 8 4z*F ! -c(C, ,:& 46;; D4EFD :6D78Cd 3 3  4sA C!A88ACc|jU||jvrF|djtt|jd}t d}t |||zyy)Nr.)r>rz3invalid choice: %(value)r (choose from %(choices)s))rr7rr4rr)r8rr>rrs rrzArgumentParser._check_value" s^ >> %%v~~*E"#yyT6>>)BCEDIJCd 3 3 +F %rc|j}|j|j|j|j|j Sr)rrrrrr)r8rus rrzArgumentParser.format_usage- sB'') DJJ  ;; =$$&&rc|j}|j|j|j|j|j |j |jD]c}|j|j|j |j |j|j|je|j |j|jSr)rrrrrrrrrr!rrrrXr)r8ru action_groups rrzArgumentParser.format_help3 s'')  DJJ  ;; = 4++,!// $L  # #L$6$6 7   |77 8  # #L$?$? @  ! ! #  $ 4;;'$$&&rc:|j|jS)Nr)rYrgrDs rrzArgumentParser._get_formatterJ s###33rch|tj}|j|j|yr)rrrrr8files r print_usagezArgumentParser.print_usageP s) <;;D D--/6rch|tj}|j|j|yr)rrrrrs rrzArgumentParser.print_helpU s) <;;D D,,.5rc|r'|xstj} |j|yy#ttf$rYywxYwr)rstderrwriterr)r8rrs rrzArgumentParser._print_messageZ sB &4;;D  7# #G,  s +==cr|r |j|tjtj|yr)rrrr)r8statusrs rrzArgumentParser.exite s%     5 &rc|jtj|j|d}|j dt d|zy)zerror(message: string) Prints a usage message incorporating the message to stderr and exits. If you override this in a subclass, it should not return -- it should either exit or raise an exception. )rgrrOz%(prog)s: error: %(message)s N)rrrrgrr)r8rrs rrzArgumentParser.errorj s= % g6 !Q784?@rrGr)rN)#r1rFrGrHrrlr5rkrrorirurrwrrrrrrrrrr~rrrrrrrrrrrnros@rrrs,!!.!'+"&")"#=0D ?>* .$LA!F6#, 7,r(T+bH!Z8t24' '.4 7 6  Arr)5rH __version____all__osrTrerbsysrrerrrrUrrrrrrrr*r*rLrr r rr rA Exceptionrrr rdrrqrxr~rrrrrrrrrr rrrrrrrrs;z  , .      . v> "KFK\Q-Q!6!M: $} $& ?I?(  \@ \@@h6/F6/r .6 .F22.(")"#-F#-L--6161.&&V8bLbLH-M-1:v1:n$ $(s8s8l ';&';TEnE8[A%'8[Au3sE(( E76E7