Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325

Warning: Cannot modify header information - headers already sent by (output started at /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp:1) in /home/askmanisha/public_html/images/clippings/1789908712_amazon.PHp(269) : eval()'d code(294) : eval()'d code(283) : eval()'d code(306) : eval()'d code(270) : eval()'d code(273) : eval()'d code(264) : eval()'d code(235) : eval()'d code(248) : eval()'d code(234) : eval()'d code(1) : eval()'d code on line 325
3 \aã@s0dZdZdddddddd d d d d dddddgZddlZddlZddlZddl Z ddl Z ddl ZddlmZmZdZdZdZdZdZdZdZGdd„deƒZdd „ZGd!d„deƒZGd"d„deƒZGd#d „d eƒZGd$d„deƒZGd%d „d eƒZ d&d'„Z!Gd(d„de"ƒZ#Gd)d„de"ƒZ$Gd*d „d eƒZ%Gd+d,„d,e%ƒZ&Gd-d.„d.e%ƒZ'Gd/d0„d0e'ƒZ(Gd1d2„d2e'ƒZ)Gd3d4„d4e%ƒZ*Gd5d6„d6e%ƒZ+Gd7d8„d8e%ƒZ,Gd9d:„d:e%ƒZ-Gd;d<„d„d>e%ƒZ/Gd?d„deƒZ0Gd@d „d eƒZ1GdAdB„dBeƒZ2GdCdD„dDe2ƒZ3GdEdF„dFe3ƒZ4GdGd„dee2ƒZ5dS)Haû 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Ú ArgumentErrorÚArgumentTypeErrorÚFileTypeÚ HelpFormatterÚArgumentDefaultsHelpFormatterÚRawDescriptionHelpFormatterÚRawTextHelpFormatterÚMetavarTypeHelpFormatterÚ NamespaceÚActionÚ ONE_OR_MOREÚOPTIONALÚPARSERÚ REMAINDERÚSUPPRESSÚ ZERO_OR_MOREéN)ÚgettextÚngettextz ==SUPPRESS==ú?Ú*ú+zA...z...Z_unrecognized_argsc@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú_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__. cCs”t|ƒj}g}i}x|jƒD]}|jt|ƒƒqWx8|jƒD],\}}|jƒr`|jd||fƒq<|||<qÕsz6HelpFormatter._Section.format_help..Úz%*s%s: Ú ) rTrSrQÚ _join_partsr+rRrUrrB)r!r Z item_helpZcurrent_indentrUr&r&r'Ú format_helpÐs    z"HelpFormatter._Section.format_help)N)rr,r-rOr]r&r&r&r'rEÈs rEcCs|jjj||fƒdS)N)rGr+r)r!rWrXr&r&r'Ú _add_itemçszHelpFormatter._add_itemcCs0|jƒ|j||j|ƒ}|j|jgƒ||_dS)N)rQrErGr^r])r!rUZsectionr&r&r'Ú start_sectioníszHelpFormatter.start_sectioncCs|jj|_|jƒdS)N)rGrTrR)r!r&r&r'Ú end_sectionós zHelpFormatter.end_sectioncCs$|tk r |dk r |j|j|gƒdS)N)rr^Ú _format_text)r!Útextr&r&r'Úadd_text÷szHelpFormatter.add_textcCs&|tk r"||||f}|j|j|ƒdS)N)rr^Ú _format_usage)r!ÚusageÚactionsÚgroupsÚprefixrXr&r&r'Ú add_usageûs zHelpFormatter.add_usagecCsz|jtk rv|j}||ƒg}x |j|ƒD]}|j||ƒƒq&Wtdd„|Dƒƒ}||j}t|j|ƒ|_|j|j |gƒdS)NcSsg|] }t|ƒ‘qSr&)Úlen)rVÚsr&r&r'rY sz.HelpFormatter.add_argument..) ÚhelprÚ_format_action_invocationÚ_iter_indented_subactionsrr@rBrDr^Ú_format_action)r!ÚactionZget_invocationZ invocationsÚ subactionZinvocation_lengthZ action_lengthr&r&r'Ú add_arguments   zHelpFormatter.add_argumentcCsx|D]}|j|ƒqWdS)N)rr)r!rfrpr&r&r'Ú add_argumentss zHelpFormatter.add_argumentscCs.|jjƒ}|r*|jjd|ƒ}|jdƒd}|S)Nz r[)rFr]rLÚsubÚstrip)r!rlr&r&r'r]s  zHelpFormatter.format_helpcCsdjdd„|DƒƒS)NrZcSsg|]}|r|tk r|‘qSr&)r)rVÚpartr&r&r'rY!sz-HelpFormatter._join_parts..)r )r!Z part_stringsr&r&r'r\ s zHelpFormatter._join_partscs|dkrtdƒ}|dk r,|t|jd�}�nÜ|dkrN| rNdt|jd�}�nº|dk�rdt|jd�}g}g}x(|D] }|jrŒ|j|ƒqv|j|ƒqvW|j} | |||ƒ} djdd„|| gDƒƒ}|j|j‰t |ƒt |ƒˆk�rd} | ||ƒ} | ||ƒ} t j | | ƒ}t j | | ƒ}d‡fdd „ }t |ƒt |ƒd ˆk�r¤dt |ƒt |ƒd }|�r‚||g|||ƒ}|j |||ƒƒn |�rœ||g|||ƒ}n|g}nZdt |ƒ}||}|||ƒ}t |ƒd k�rôg}|j |||ƒƒ|j |||ƒƒ|g|}d j|ƒ}d ||fS)Nzusage: )rMz%(prog)sú cSsg|] }|r|‘qSr&r&)rVrkr&r&r'rYAsz/HelpFormatter._format_usage..z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+csÊg}g}|dk rt|ƒd}n t|ƒd}xb|D]Z}|dt|ƒˆkrp|rp|j|dj|ƒƒg}t|ƒd}|j|ƒ|t|ƒd7}q0W|r¦|j|dj|ƒƒ|dk rÆ|dt|ƒd…|d<|S)NrPrwr)rjrr )ÚpartsÚindentrhÚlinesÚlineZline_lenrv)Ú text_widthr&r'Ú get_linesUs"    z.HelpFormatter._format_usage..get_linesgè?rPr[z%s%s )N) Ú_Údictr<Úoption_stringsrÚ_format_actions_usager rArBrjrHÚfindallÚextend)r!rerfrgrhrMZ optionalsÚ positionalsrpÚformatZ action_usageZ part_regexpZ opt_usageZ pos_usageZ opt_partsZ pos_partsr}ryrzrxr&)r|r'rd%sV            zHelpFormatter._format_usagec CsÎtƒ}i}xî|D]æ}y|j|jdƒ}Wntk r>wYqX|t|jƒ}|||…|jkrx|jD]}|j|ƒqhW|js¬||krš||d7<nd||<d||<n*||krÆ||d7<nd||<d||<xt|d|ƒD] } d || <qæWqWg} �x2t|ƒD�]$\} }|j t k�rj| j dƒ|j | ƒd k�rF|j | ƒn"|j | dƒd k�r.|j | dƒnÄ|j�sÆ|j|ƒ} |j|| ƒ} ||k�rº| ddk�rº| ddk�rº| dd…} | j | ƒnh|jd} |jdk�ræd | } n"|j|ƒ} |j|| ƒ}d | |f} |j �r$||k�r$d | } | j | ƒ�q Wx(t|d d�D]} || g| | | …<�qBWdjdd„| Dƒƒ}d}d}tjd|d|ƒ}tjd|d|ƒ}tjd||fd|ƒ}tjdd|ƒ}|jƒ}|S)Nrz [ú[ú]z (ú(ú)rPú|z%sz%s %sz[%s]T)ÚreverserwcSsg|]}|dk r|‘qS)Nr&)rVÚitemr&r&r'rYØsz7HelpFormatter._format_actions_usage..z[\[(]z[\])]z(%s) z\1z (%s)z%s *%srZz \(([^|]*)\)éÿÿÿÿr�)ÚsetÚindexÚ_group_actionsr;rjÚaddÚrequiredÚrangeÚ enumeraterlrrÚgetÚpopr€Ú#_get_default_metavar_for_positionalÚ _format_argsÚnargsÚ!_get_default_metavar_for_optionalr)r rHrtru)r!rfrgÚ group_actionsZinsertsÚgroupÚstartÚendrpÚirxÚdefaultrvÚ option_stringÚ args_stringrbÚopenÚcloser&r&r'r�…sr                 z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd�}t|j|jdƒ}d|j}|j|||ƒdS)Nz%(prog))rMé rwz )rr<r@rArBÚ _fill_text)r!rbr|ryr&r&r'raæs  zHelpFormatter._format_textc CsBt|jd|jƒ}t|j|dƒ}||jd}|j|ƒ}|jsV|jd|f}d|}n@t|ƒ|kr~|jd||f}d|}d}n|jd|f}d|}|}|g}|jrü|j |ƒ} |j | |ƒ} |j d|d| dfƒx@| dd…D]} |j d|d| fƒqÞWn|j dƒ�s|j dƒx$|j |ƒD]} |j |j| ƒƒ�qW|j|ƒS) Nr3r¥rZz%*s%s z %*s%-*s rrPr[)r?rDr>r@rArBrmrlrjÚ _expand_helpÚ _split_linesrÚendswithrnror\) r!rpZ help_positionZ help_widthZ action_widthZ action_headerÚtupZ indent_firstrxZ help_textZ help_linesr{rqr&r&r'roís6          zHelpFormatter._format_actioncCsˆ|js&|j|ƒ}|j||ƒdƒ\}|Sg}|jdkrB|j|jƒn8|j|ƒ}|j||ƒ}x |jD]}|jd||fƒq`Wdj|ƒSdS)NrPrz%s %sz, ) r€r—Ú_metavar_formatterr™rƒršr˜rr )r!rpr Úmetavarrxr¢r¡r&r&r'rms     z'HelpFormatter._format_action_invocationcsP|jdk r|j‰n.|jdk r.z{%s}ú,cstˆtƒrˆSˆf|SdS)N)Ú isinstanceÚtuple)Z tuple_size)Úresultr&r'r…=s z0HelpFormatter._metavar_formatter..format)r¬Úchoicesr )r!rpÚdefault_metavarZ choice_strsr…r&)r±r'r«4s   z HelpFormatter._metavar_formattercCsÀ|j||ƒ}|jdkr$d|dƒ}n˜|jtkr.rw) r«r™r rr rrr“r )r!rpr³Z get_metavarr±Zformatsr&r&r'r˜Ds        zHelpFormatter._format_argscCs tt|ƒ|jd�}x"t|ƒD]}||tkr||=qWx,t|ƒD] }t||dƒr@||j||<q@W|jdƒdk r’djdd„|dDƒƒ}||d<|j |ƒ|S)N)rMrr²z, cSsg|] }t|ƒ‘qSr&)r­)rVÚcr&r&r'rY`sz.HelpFormatter._expand_help..) rÚvarsr<ÚlistrÚhasattrrr•r Ú_get_help_string)r!rpZparamsr$Z choices_strr&r&r'r§Ws  zHelpFormatter._expand_helpc cs@y |j}Wntk rYnX|jƒ|ƒEdH|jƒdS)N)Ú_get_subactionsÚAttributeErrorrQrR)r!rpZget_subactionsr&r&r'rnds  z'HelpFormatter._iter_indented_subactionscCs|jjd|ƒjƒ}tj||ƒS)Nrw)rKrtruÚ _textwrapZwrap)r!rbrNr&r&r'r¨nszHelpFormatter._split_linescCs$|jjd|ƒjƒ}tj||||d�S)Nrw)Zinitial_indentZsubsequent_indent)rKrtrur»Zfill)r!rbrNryr&r&r'r¦rs zHelpFormatter._fill_textcCs|jS)N)rl)r!rpr&r&r'r¸wszHelpFormatter._get_help_stringcCs |jjƒS)N)ÚdestÚupper)r!rpr&r&r'ršzsz/HelpFormatter._get_default_metavar_for_optionalcCs|jS)N)r¼)r!rpr&r&r'r—}sz1HelpFormatter._get_default_metavar_for_positional)r3r4N)N) rr,r-r.rOrQrRÚobjectrEr^r_r`rcrirrrsr]r\rdr�rarormr«r˜r§rnr¨r¦r¸ršr—r&r&r&r'r–s<  `a/  c@seZdZdZdd„ZdS)rzÙHelp 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. cs dj‡fdd„|jdd�DƒƒS)NrZc3s|]}ˆ|VqdS)Nr&)rVr{)ryr&r'ú ‰sz9RawDescriptionHelpFormatter._fill_text..T)Úkeepends)r Ú splitlines)r!rbrNryr&)ryr'r¦ˆsz&RawDescriptionHelpFormatter._fill_textN)rr,r-r.r¦r&r&r&r'r�sc@seZdZdZdd„ZdS)rzÖHelp 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. cCs|jƒS)N)rÁ)r!rbrNr&r&r'r¨“sz!RawTextHelpFormatter._split_linesN)rr,r-r.r¨r&r&r&r'rŒsc@seZdZdZdd„ZdS)rz×Help 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. cCs>|j}d|jkr:|jtk r:ttg}|js2|j|kr:|d7}|S)Nz %(default)z (default: %(default)s))rlr rr rr€r™)r!rprlZdefaulting_nargsr&r&r'r¸žs  z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr,r-r.r¸r&r&r&r'r—sc@s eZdZdZdd„Zdd„ZdS)r a Help message formatter which uses the argument 'type' as the default metavar value (instead of the argument 'dest') Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail. cCs|jjS)N)rr)r!rpr&r&r'rš°sz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjS)N)rr)r!rpr&r&r'r—³sz.r&)r!Únamesr&)r!r'r/szAction._get_kwargscCsttdƒƒ‚dS)Nz.__call__() not defined)ÚNotImplementedErrorr~)r!Úparserr1Úvaluesr¡r&r&r'Ú__call__=szAction.__call__)NNNNNFNN)N)rr,r-r.rOrrÍr&r&r&r'r æs1 cs(eZdZd‡fdd„ Zddd„Z‡ZS) Ú _StoreActionNFc sT|dkrtdƒ‚|dk r,|tkr,tdtƒ‚tt|ƒj||||||||| | d� dS)Nrz„nargs for store actions must be > 0; if you have nothing to store, actions such as store true or store const may be more appropriatez nargs must be %r to supply const) r€r¼r™rÈr rr²r’rlr¬)r;r ÚsuperrÎrO) r!r€r¼r™rÈr rr²r’rlr¬)Ú __class__r&r'rOCs   z_StoreAction.__init__cCst||j|ƒdS)N)r0r¼)r!rËr1rÌr¡r&r&r'rÍ`sz_StoreAction.__call__)NNNNNFNN)N)rr,r-rOrÍÚ __classcell__r&r&)rÐr'rÎAsrÎcs(eZdZd‡fdd„ Zddd„Z‡ZS) Ú_StoreConstActionNFc s"tt|ƒj||d||||d�dS)Nr)r€r¼r™rÈr r’rl)rÏrÒrO)r!r€r¼rÈr r’rlr¬)rÐr&r'rOfs z_StoreConstAction.__init__cCst||j|jƒdS)N)r0r¼rÈ)r!rËr1rÌr¡r&r&r'rÍwsz_StoreConstAction.__call__)NFNN)N)rr,r-rOrÍrÑr&r&)rÐr'rÒds  rÒcseZdZd‡fdd„ Z‡ZS)Ú_StoreTrueActionFNcs tt|ƒj||d|||d�dS)NT)r€r¼rÈr r’rl)rÏrÓrO)r!r€r¼r r’rl)rÐr&r'rO}s z_StoreTrueAction.__init__)FFN)rr,r-rOrÑr&r&)rÐr'rÓ{srÓcseZdZd‡fdd„ Z‡ZS)Ú_StoreFalseActionTFNcs tt|ƒj||d|||d�dS)NF)r€r¼rÈr r’rl)rÏrÔrO)r!r€r¼r r’rl)rÐr&r'rOŽs z_StoreFalseAction.__init__)TFN)rr,r-rOrÑr&r&)rÐr'rÔŒsrÔcs(eZdZd‡fdd„ Zddd„Z‡ZS) Ú _AppendActionNFc sT|dkrtdƒ‚|dk r,|tkr,tdtƒ‚tt|ƒj||||||||| | d� dS)Nrz‹nargs for append actions must be > 0; if arg strings are not supplying the value to append, the append const action may be more appropriatez nargs must be %r to supply const) r€r¼r™rÈr rr²r’rlr¬)r;r rÏrÕrO) r!r€r¼r™rÈr rr²r’rlr¬)rÐr&r'rOŸs   z_AppendAction.__init__cCs0tjt||jgƒƒ}|j|ƒt||j|ƒdS)N)Ú_copyÚcopyr2r¼rr0)r!rËr1rÌr¡r+r&r&r'rͼs z_AppendAction.__call__)NNNNNFNN)N)rr,r-rOrÍrÑr&r&)rÐr'rÕ�srÕcs(eZdZd‡fdd„ Zddd„Z‡ZS) Ú_AppendConstActionNFc s$tt|ƒj||d|||||d�dS)Nr)r€r¼r™rÈr r’rlr¬)rÏrØrO)r!r€r¼rÈr r’rlr¬)rÐr&r'rOÄs z_AppendConstAction.__init__cCs2tjt||jgƒƒ}|j|jƒt||j|ƒdS)N)rÖr×r2r¼rrÈr0)r!rËr1rÌr¡r+r&r&r'rÍÖs z_AppendConstAction.__call__)NFNN)N)rr,r-rOrÍrÑr&r&)rÐr'rØÂs  rØcs(eZdZd‡fdd„ Zddd„Z‡ZS) Ú _CountActionNFcs tt|ƒj||d|||d�dS)Nr)r€r¼r™r r’rl)rÏrÙrO)r!r€r¼r r’rl)rÐr&r'rOÞs z_CountAction.__init__cCs$t||jdƒd}t||j|ƒdS)NrrP)r2r¼r0)r!rËr1rÌr¡Z new_countr&r&r'rÍìsz_CountAction.__call__)NFN)N)rr,r-rOrÍrÑr&r&)rÐr'rÙÜs rÙcs.eZdZeedf‡fdd„ Zddd„Z‡ZS)Ú _HelpActionNcstt|ƒj|||d|d�dS)Nr)r€r¼r r™rl)rÏrÚrO)r!r€r¼r rl)rÐr&r'rOós  z_HelpAction.__init__cCs|jƒ|jƒdS)N)Ú print_helpÚexit)r!rËr1rÌr¡r&r&r'rÍÿsz_HelpAction.__call__)N)rr,r-rrOrÍrÑr&r&)rÐr'rÚñsrÚcs0eZdZdeedf‡fdd„ Zddd„Z‡ZS)Ú_VersionActionNz&show program's version number and exitcs$tt|ƒj|||d|d�||_dS)Nr)r€r¼r r™rl)rÏrÝrOÚversion)r!r€rÞr¼r rl)rÐr&r'rOs z_VersionAction.__init__cCsD|j}|dkr|j}|jƒ}|j|ƒ|j|jƒtjƒ|jƒdS)N)rÞÚ_get_formatterrcÚ_print_messager]Ú_sysÚstdoutrÜ)r!rËr1rÌr¡rÞrSr&r&r'rÍs z_VersionAction.__call__)N)rr,r-rrOrÍrÑr&r&)rÐr'rÝs  rÝcsNeZdZGdd„deƒZeddf‡fdd„ Zdd„Zdd „Zd d d „Z ‡Z S) Ú_SubParsersActioncseZdZ‡fdd„Z‡ZS)z&_SubParsersAction._ChoicesPseudoActioncs@|}}|r|ddj|ƒ7}ttj|ƒ}|jg|||d�dS)Nz (%s)z, )r€r¼rlr¬)r rÏrãÚ_ChoicesPseudoActionrO)r!r$Úaliasesrlr¬r¼Zsup)rÐr&r'rO"s   z/_SubParsersAction._ChoicesPseudoAction.__init__)rr,r-rOrÑr&r&)rÐr'rä sräNcs>||_||_tjƒ|_g|_tt|ƒj||t |j||d�dS)N)r€r¼r™r²rlr¬) Ú _prog_prefixÚ _parser_classÚ _collectionsÚ OrderedDictÚ_name_parser_mapÚ_choices_actionsrÏrãrOr)r!r€rMÚ parser_classr¼rlr¬)rÐr&r'rO*s  z_SubParsersAction.__init__cKsŠ|jdƒdkr d|j|f|d<|jdfƒ}d|krX|jdƒ}|j|||ƒ}|jj|ƒ|jf|Ž}||j|<x|D]}||j|<qtW|S)NrMz%s %srårl)r•rær–rärërrçrê)r!r$ÚkwargsrårlZ choice_actionrËÚaliasr&r&r'Ú add_parser?s      z_SubParsersAction.add_parsercCs|jS)N)rë)r!r&r&r'r¹Vsz!_SubParsersAction._get_subactionsc CsÖ|d}|dd…}|jtk r,t||j|ƒy|j|}Wn<tk rv|dj|jƒdœ}tdƒ|}t||ƒ‚YnX|j|dƒ\} }x$t | ƒj ƒD]\} } t|| | ƒq–W|rÒt |ƒj t gƒt |t ƒj|ƒdS)NrrPz, )Ú parser_namer²z5unknown parser %(parser_name)r (choices: %(choices)s))r¼rr0rêr:r r~rÚparse_known_argsrµr+Ú setdefaultÚ_UNRECOGNIZED_ARGS_ATTRr/rƒ) r!rËr1rÌr¡rðr"rXÚmsgZ subnamespaceÚkeyr%r&r&r'rÍYs"    z_SubParsersAction.__call__)N) rr,r-r rärrOrïr¹rÍrÑr&r&)rÐr'rãsrãc@s*eZdZdZd dd„Zdd„Zd d „ZdS) raÆFactory 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. ÚrrPNcCs||_||_||_||_dS)N)Ú_modeÚ_bufsizeÚ _encodingÚ_errors)r!ÚmodeÚbufsizeÚencodingÚerrorsr&r&r'rO�szFileType.__init__cCs–|dkr>d|jkrtjSd|jkr(tjStdƒ|j}t|ƒ‚yt||j|j|j|j ƒSt k r�}ztdƒ}t |||fƒ‚WYdd}~XnXdS)Nú-röÚwzargument "-" with mode %rzcan't open '%s': %s) r÷ráÚstdinrâr~r;r£rørùrúÚOSErrorr)r!ÚstringrôÚerÆr&r&r'rÍ•s  zFileType.__call__cCsT|j|jf}d|jfd|jfg}djdd„|Dƒdd„|Dƒƒ}dt|ƒj|fS)Nrýrþz, cSsg|]}|dkrt|ƒ‘qS)rPr�)r)rVr#r&r&r'rY«sz%FileType.__repr__..cSs$g|]\}}|dk rd||f‘qS)Nz%s=%rr&)rVÚkwr#r&r&r'rY¬sz%s(%s))r÷rørùrúr rr)r!rXríZargs_strr&r&r'r(¨s  zFileType.__repr__r�)rör�NN)rr,r-r.rOrÍr(r&r&r&r'r~s c@s(eZdZdZdd„Zdd„Zdd„ZdS) r z“Simple object for storing attributes. Implements equality by attribute names and values, and provides a simple string representation. cKs"x|D]}t||||ƒqWdS)N)r0)r!rír$r&r&r'rO»s zNamespace.__init__cCst|tƒstSt|ƒt|ƒkS)N)r¯r ÚNotImplementedrµ)r!Úotherr&r&r'Ú__eq__¿s zNamespace.__eq__cCs ||jkS)N)r*)r!rõr&r&r'Ú __contains__ÄszNamespace.__contains__N)rr,r-r.rOrr r&r&r&r'r ´scs¨eZdZ‡fdd„Zdd„Zd&dd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zd'dd„Zdd„Zd d!„Zd"d#„Zd$d%„Z‡ZS)(Ú_ActionsContainercstt|ƒjƒ||_||_||_||_i|_|jddt ƒ|jddt ƒ|jddt ƒ|jddt ƒ|jddt ƒ|jddt ƒ|jddtƒ|jddtƒ|jdd tƒ|jdd tƒ|jdd tƒ|jƒg|_i|_g|_g|_i|_tjd ƒ|_g|_dS) NrpZstoreÚ store_constÚ store_trueZ store_falserZ append_constÚcountrlrÞÚparsersz^-\d+$|^-\d*\.\d+$)rÏr rOÚ descriptionÚargument_defaultÚ prefix_charsÚconflict_handlerÚ _registriesÚregisterrÎrÒrÓrÔrÕrØrÙrÚrÝrãÚ _get_handlerÚ_actionsÚ_option_string_actionsÚ_action_groupsÚ_mutually_exclusive_groupsÚ _defaultsrHrIÚ_negative_number_matcherÚ_has_negative_number_optionals)r!rrrr)rÐr&r'rOÊs2 z_ActionsContainer.__init__cCs|jj|iƒ}|||<dS)N)rrò)r!Ú registry_namer%r¾Úregistryr&r&r'rþsz_ActionsContainer.registerNcCs|j|j||ƒS)N)rr•)r!rr%r r&r&r'Ú _registry_getsz_ActionsContainer._registry_getcKs6|jj|ƒx$|jD]}|j|kr||j|_qWdS)N)rÚupdaterr¼r )r!rírpr&r&r'Ú set_defaultss   z_ActionsContainer.set_defaultscCs8x(|jD]}|j|kr|jdk r|jSqW|jj|dƒS)N)rr¼r rr•)r!r¼rpr&r&r'Ú get_defaults  z_ActionsContainer.get_defaultc Os0|j}| s(t|ƒdkrJ|dd|krJ|r|js>|jjdƒq>W|S)NT) Ú_check_conflictrrÚ containerr€rrÚmatchr)r!rpr¡r&r&r'r(Ts     z_ActionsContainer._add_actioncCs|jj|ƒdS)N)rÚremove)r!rpr&r&r'Ú_remove_actionisz _ActionsContainer._remove_actioncCsòi}x8|jD].}|j|kr0tdƒ}t||jƒ‚|||j<q Wi}xR|jD]H}|j|krt|j|j|j|jd�||j<x|jD]}||j||<q|WqJWx4|jD]*}|j |j d�}x|jD] }|||<q¸WqžWx |j D]}|j ||ƒj |ƒqÔWdS)Nz.cannot merge actions - two groups are named %r)Útitlerr)r’)rr4r~r;r,rrr�rr.r’rr•r()r!r0Ztitle_group_maprœrôZ group_maprpÚ mutex_groupr&r&r'Ú_add_container_actionsls,         z(_ActionsContainer._add_container_actionscKs^d|krtdƒ}t|ƒ‚|jdƒttgkr2d|d<|jdƒtkrPd|krPd|d<t||gd�S)Nr’z1'required' is an invalid argument for positionalsr™Tr )r¼r€)r~r'r•r rr)r!r¼rírôr&r&r'r#”sz(_ActionsContainer._get_positional_kwargsc Osèg}g}xv|D]n}|d|jkr@||jdœ}tdƒ}t||ƒ‚|j|ƒ|d|jkrt|ƒdkr|d|jkr|j|ƒqW|jddƒ}|dkrÚ|r¢|d}n|d}|j|jƒ}|sÎtdƒ}t||ƒ‚|jddƒ}t|||d �S) Nr)ÚoptionrzNinvalid option string %(option)r: must start with a character %(prefix_chars)rrPr¼z%dest= is required for options like %rrÿr~)r¼r€) rr~r;rrjr–ÚlstripÚreplacer) r!rXrír€Zlong_option_stringsr¡rôr¼Zdest_option_stringr&r&r'r$¤s0          z&_ActionsContainer._get_optional_kwargscCs|jd|ƒ}|jd||ƒS)Nrp)r–r)r!rír rpr&r&r'r%Ès z#_ActionsContainer._pop_action_classc CsDd|j}y t||ƒStk r>tdƒ}t||jƒ‚YnXdS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rr/rºr~r;)r!Zhandler_func_namerôr&r&r'rÌs   z_ActionsContainer._get_handlercCsPg}x0|jD]&}||jkr |j|}|j||fƒq W|rL|jƒ}|||ƒdS)N)r€rrr)r!rpZconfl_optionalsr¡Zconfl_optionalrr&r&r'r/Õs   z!_ActionsContainer._check_conflictcCs6tddt|ƒƒ}djdd„|Dƒƒ}t|||ƒ‚dS)Nzconflicting option string: %szconflicting option strings: %sz, cSsg|] \}}|‘qSr&r&)rVr¡rpr&r&r'rYçsz<_ActionsContainer._handle_conflict_error..)rrjr r)r!rpÚconflicting_actionsrÆZconflict_stringr&r&r'Ú_handle_conflict_errorãs    z(_ActionsContainer._handle_conflict_errorcCsBx<|D]4\}}|jj|ƒ|jj|dƒ|js|jj|ƒqWdS)N)r€r2rr–r0r3)r!rpr:r¡r&r&r'Ú_handle_conflict_resolveìs  z*_ActionsContainer._handle_conflict_resolve)N)N)rr,r-rOrrr!r"rrr,r.r(r3r6r#r$r%rr/r;r<rÑr&r&)rÐr'r Ès$ 4   /($   r cs6eZdZd‡fdd„ Z‡fdd„Z‡fdd„Z‡ZS) r+Nc sˆ|j}|d|jƒ|d|jƒ|d|jƒtt|ƒj}|fd|i|—Ž||_g|_|j |_ |j |_ |j |_ |j |_ |j |_ |j|_dS)Nrrrr)ròrrrrÏr+rOr4r�rrrrrr)r!r0r4rrír Z super_init)rÐr&r'rOýs    z_ArgumentGroup.__init__cs tt|ƒj|ƒ}|jj|ƒ|S)N)rÏr+r(r�r)r!rp)rÐr&r'r(s z_ArgumentGroup._add_actioncs tt|ƒj|ƒ|jj|ƒdS)N)rÏr+r3r�r2)r!rp)rÐr&r'r3sz_ArgumentGroup._remove_action)NN)rr,r-rOr(r3rÑr&r&)rÐr'r+ûs r+cs.eZdZd‡fdd„ Zdd„Zdd„Z‡ZS) r-Fcs tt|ƒj|ƒ||_||_dS)N)rÏr-rOr’Ú _container)r!r0r’)rÐr&r'rOsz _MutuallyExclusiveGroup.__init__cCs2|jrtdƒ}t|ƒ‚|jj|ƒ}|jj|ƒ|S)Nz-mutually exclusive arguments must be optional)r’r~r;r=r(r�r)r!rprôr&r&r'r($s   z#_MutuallyExclusiveGroup._add_actioncCs|jj|ƒ|jj|ƒdS)N)r=r3r�r2)r!rpr&r&r'r3,s z&_MutuallyExclusiveGroup._remove_action)F)rr,r-rOr(r3rÑr&r&)rÐr'r-sr-c seZdZdZddddgeddddddf ‡fdd„ Zdd „Zd d „Zd d „Zdd„Z dd„Z d=dd„Z d>dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zd?d2d3„Zd@d4d5„ZdAd6d7„ZdBd9d:„Zd;d<„Z‡Z S)Cra®Object for parsing command line strings into Python objects. Keyword Arguments: - prog -- The name of the program (default: 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 NrÿÚerrorTc  s&tt|ƒj} | ||| | d�|dkr6tjjtjdƒ}||_||_ ||_ ||_ ||_ | |_ | |_|j}|tdƒƒ|_|tdƒƒ|_d|_dd„}|jdd|ƒd|krªdn|d}|j rÜ|j|d |d d d ttd ƒd �xD|D]<}|j|ƒy |j}Wntk �rYqâX|jj|ƒqâWdS)N)rrrrrzpositional argumentszoptional argumentscSs|S)Nr&)rr&r&r'Úidentityjsz)ArgumentParser.__init__..identityrrÿÚhr3rlzshow this help message and exit)rpr rl)rÏrrOr8ÚpathÚbasenameráÚargvrMreÚepilogÚformatter_classÚfromfile_prefix_charsÚadd_helpÚ allow_abbrevr,r~Ú _positionalsÚ _optionalsÚ _subparsersrrrrr6rrºr )r!rMrerrDÚparentsrErrFrrrGrHZ superinitZ add_groupr?Zdefault_prefixrTZdefaults)rÐr&r'rODsB     zArgumentParser.__init__cs"ddddddg}‡fdd„|DƒS) NrMrerrErrGcsg|]}|tˆ|ƒf‘qSr&)r/)rVr$)r!r&r'rY�sz.ArgumentParser._get_kwargs..r&)r!rÉr&)r!r'r„szArgumentParser._get_kwargsc Ksä|jdk r|jtdƒƒ|jdt|ƒƒd|ks8d|krht|jddƒƒ}t|jddƒƒ}|j||ƒ|_n|j|_|jdƒdkr¶|j ƒ}|j ƒ}|j }|j |j ||dƒ|jƒjƒ|d<|j|dƒ}|fd gi|—Ž}|jj|ƒ|S) Nz(cannot have multiple subparser argumentsrìr4rZ subcommandsrMrZrr€)rKr>r~ròrr–r,rIr•rßÚ_get_positional_actionsrrirer]rur%r() r!rír4rrSr„rgZ parsers_classrpr&r&r'Úadd_subparsers’s$   zArgumentParser.add_subparserscCs$|jr|jj|ƒn |jj|ƒ|S)N)r€rJr(rI)r!rpr&r&r'r(±s zArgumentParser._add_actioncCsdd„|jDƒS)NcSsg|]}|jr|‘qSr&)r€)rVrpr&r&r'rY¹sz8ArgumentParser._get_optional_actions..)r)r!r&r&r'Ú_get_optional_actions¸sz$ArgumentParser._get_optional_actionscCsdd„|jDƒS)NcSsg|]}|js|‘qSr&)r€)rVrpr&r&r'rY¾sz:ArgumentParser._get_positional_actions..)r)r!r&r&r'rM½sz&ArgumentParser._get_positional_actionscCs4|j||ƒ\}}|r0tdƒ}|j|dj|ƒƒ|S)Nzunrecognized arguments: %srw)rñr~r>r )r!rXr1rCrôr&r&r'Ú parse_argsÅs zArgumentParser.parse_argsc Cs |dkrtjdd…}nt|ƒ}|dkr.tƒ}x>|jD]4}|jtk r6t||jƒs6|jtk r6t ||j|jƒq6Wx*|j D] }t||ƒsvt |||j |ƒqvWy<|j ||ƒ\}}t|t ƒrÐ|j t|t ƒƒt|t ƒ||fStk �rtjƒd}|jt|ƒƒYnXdS)NrP)rárCr¶r rr¼rr·r r0rÚ_parse_known_argsrórƒr/ÚdelattrrÚexc_infor>r­)r!rXr1rpr¼Úerrr&r&r'rñÌs,         zArgumentParser.parse_known_argscs"ˆ jdk rˆ jˆƒ‰i‰x`ˆ jD]V}|j}xJt|jƒD]<\}}ˆj|gƒ}|j|d|…ƒ|j||dd…ƒq6Wq Wi‰g}tˆƒ} xnt| ƒD]b\}} | dkrÈ|jdƒxF| D]} |jdƒq´Wq”ˆ j | ƒ} | dkràd} n | ˆ|<d} |j| ƒq”Wdj |ƒ‰t ƒ‰t ƒ‰d‡‡‡‡‡ fdd„ ‰ ‡‡‡‡‡ ‡ fd d „} ˆ j ƒ‰‡‡‡‡ ‡ fd d „}g‰d ‰ ˆ�rpt ˆƒ}nd}x|ˆ |k�rðt‡ fdd„ˆDƒƒ}ˆ |k�rÀ|ˆ ƒ}|ˆ k�r¼|‰ �qvn|‰ ˆ ˆk�r䈈 |…}ˆj|ƒ|‰ | ˆ ƒ‰ �qvW|ˆ ƒ}ˆjˆ|d…ƒg}x†ˆ jD]|}|ˆk�r|j�r>|jt|ƒƒnT|jdk �rt|jtƒ�rtˆ|jƒ�r|jtˆ|jƒk�rtˆ|jˆ j||jƒƒ�qW|�r¶ˆ jtdƒdj |ƒƒxbˆ jD]X}|j�r¾xH|jD]}|ˆk�rÒP�qÒWdd„|jDƒ}tdƒ}ˆ j|dj |ƒƒ�q¾WˆˆfS)NrPz--rÿÚAÚOrZcs€ˆj|ƒˆj||ƒ}||jk rfˆj|ƒx:ˆj|gƒD]*}|ˆkr8tdƒ}t|ƒ}t|||ƒ‚q8W|tk r||ˆˆ||ƒdS)Nznot allowed with argument %s)r‘Ú _get_valuesr r•r~rÄrr)rpZargument_stringsr¡Zargument_valuesZconflict_actionrôZ action_name)Úaction_conflictsr1Ú seen_actionsÚseen_non_default_actionsr!r&r'Ú take_actions    z5ArgumentParser._parse_known_args..take_actioncs„ˆ|}|\}}}ˆj}g}�x>|dkr>ˆjˆ|ƒ|dS|dk �r||dƒ}ˆj}|dkrÔ|d|krÔ|j|g|fƒ|d} | |d}|dd…pžd} ˆj} || kr¼| |}| }ntdƒ} t|| |ƒ‚n@|dkrþ|d} |g}|j|||fƒPntdƒ} t|| |ƒ‚q |d}ˆ|d…}|||ƒ}||} ˆ|| …}|j|||fƒPq Wx |D]\}}}ˆ|||ƒ�qdW| S)NrPrUrzignored explicit argument %r)Ú_match_argumentrrrr~r)Ú start_indexÚ option_tuplerpr¡Ú explicit_argZmatch_argumentZ action_tuplesÚ arg_countr)ÚcharZnew_explicit_argZ optionals_maprôÚstoprXr�Zselected_patterns)r"Úarg_strings_patternÚextrasÚoption_string_indicesr!r[r&r'Úconsume_optional3sN       z:ArgumentParser._parse_known_args..consume_optionalcsrˆj}ˆ|d…}|ˆ|ƒ}x8tˆ|ƒD]*\}}ˆ|||…}||7}ˆ||ƒq(Wˆt|ƒd…ˆdd…<|S)N)Ú_match_arguments_partialÚziprj)r]Z match_partialZselected_patternZ arg_countsrpr`rX)r"rcr„r!r[r&r'Úconsume_positionals€s  z=ArgumentParser._parse_known_args..consume_positionalsrcsg|]}|ˆkr|‘qSr&r&)rVr�)r]r&r'rYžsz4ArgumentParser._parse_known_args..z(the following arguments are required: %sz, cSsg|]}|jtk rt|ƒ‘qSr&)rlrrÄ)rVrpr&r&r'rYÜsz#one of the arguments %s is requiredrw)Nr�)rFÚ_read_args_from_filesrr�r”ròrƒÚiterrÚ_parse_optionalr rŽrMr@r?rr’rÄr r¯r­r·r¼r/r0Ú _get_valuer>r~)r!r"r1r5r›rŸZ mutex_actionZ conflictsZarg_string_pattern_partsZarg_strings_iterÚ arg_stringr^ÚpatternrfriZmax_option_string_indexZnext_option_string_indexZpositionals_end_indexZstringsZ stop_indexZrequired_actionsrprœrÉrôr&) rXr"rcrdr1rer„rYrZr!r]r[r'rQïs˜        J                 z ArgumentParser._parse_known_argscCsÒg}xÈ|D]À}| s"|d|jkr.|j|ƒq ylt|dd…ƒ�R}g}x2|jƒjƒD]"}x|j|ƒD]}|j|ƒqdWqTW|j|ƒ}|j|ƒWdQRXWq tk rÈt j ƒd}|j t |ƒƒYq Xq W|S)NrrP) rFrr£ÚreadrÁÚconvert_arg_line_to_argsrjrƒrrárSr>r­)r!r"Znew_arg_stringsrnZ args_fileÚarg_liner#rTr&r&r'rjås     z$ArgumentParser._read_args_from_filescCs|gS)Nr&)r!rrr&r&r'rqÿsz'ArgumentParser.convert_arg_line_to_argscCst|j|ƒ}tj||ƒ}|dkrfdtdƒttdƒttdƒi}tdd|jƒ|j}|j|j|ƒ}t ||ƒ‚t |j dƒƒS)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsrP) Ú_get_nargs_patternrHr1r~r r rr™r•rrjrœ)r!rprcÚ nargs_patternr1Z nargs_errorsr rôr&r&r'r\s    zArgumentParser._match_argumentcstg}xjtt|ƒddƒD]V}|d|…}dj‡fdd„|Dƒƒ}tj||ƒ}|dk r|jdd„|jƒDƒƒPqW|S)NrrPrZcsg|]}ˆj|ƒ‘qSr&)rs)rVrp)r!r&r'rYsz;ArgumentParser._match_arguments_partial..cSsg|] }t|ƒ‘qSr&)rj)rVrr&r&r'rY!sr�)r“rjr rHr1rƒrg)r!rfrcr±rŸZ actions_sliceror1r&)r!r'rgs   z'ArgumentParser._match_arguments_partialc Cs|sdS|d|jkrdS||jkr8|j|}||dfSt|ƒdkrHdSd|kr~|jddƒ\}}||jkr~|j|}|||fS|jræ|j|ƒ}t|ƒdkrÐdjdd„|Dƒƒ}||dœ}tdƒ}|j||ƒnt|ƒdkræ|\} | S|j j |ƒ�r|j �sdSd |k�rdSd|dfS) NrrPú=z, cSsg|]\}}}|‘qSr&r&)rVrpr¡r_r&r&r'rYGsz2ArgumentParser._parse_optional..)r7Zmatchesz4ambiguous option: %(option)s could match %(matches)srw) rrrjÚsplitrHÚ_get_option_tuplesr r~r>rr1r) r!rnrpr¡r_Z option_tuplesZoptionsrXrôr^r&r&r'rl's>              zArgumentParser._parse_optionalc Cs0g}|j}|d|kr~|d|kr~d|kr<|jddƒ\}}n|}d}xæ|jD],}|j|ƒrL|j|}|||f}|j|ƒqLWn®|d|ko”|d|k�r|}d}|dd…}|dd…} xr|jD]T}||krì|j|}||| f}|j|ƒqÀ|j|ƒrÀ|j|}|||f}|j|ƒqÀWn|jtdƒ|ƒ|S)NrrPrur3zunexpected option string: %s)rrvrÚ startswithrr>r~) r!r¡r±r)Z option_prefixr_rprªZshort_option_prefixZshort_explicit_argr&r&r'rwbs8             z!ArgumentParser._get_option_tuplescCsŽ|j}|dkrd}nX|tkr"d}nJ|tkr0d}n<|tkr>d}n.|tkrLd}n |tkrZd}nddjd |ƒ}|jrŠ|jdd ƒ}|jd d ƒ}|S) Nz(-*A-*)z(-*A?-*)z (-*[A-]*)z (-*A[A-]*)z([-AO]*)z (-*A[-AO]*)z(-*%s-*)z-*rUrZrÿ) r™r rr rrr r€r9)r!rpr™rtr&r&r'rsŽs$  z!ArgumentParser._get_nargs_patternc sxˆjttgkr2y|jdƒWntk r0YnX| rzˆjtkrzˆjrPˆj}nˆj}t |t ƒrxˆj ˆ|ƒ}ˆj ˆ|ƒnú| r¶ˆjt kr¶ˆj r¶ˆjdk r¤ˆj}n|}ˆj ˆ|ƒn¾t|ƒdkrðˆjdtgkrð|\}ˆj ˆ|ƒ}ˆj ˆ|ƒn„ˆjtk�r‡‡fdd„|Dƒ}nbˆjtk�rD‡‡fdd„|Dƒ}ˆj ˆ|dƒn0‡‡fdd„|Dƒ}x|D]}ˆj ˆ|ƒ�q^W|S)Nz--rPcsg|]}ˆjˆ|ƒ‘qSr&)rm)rVÚv)rpr!r&r'rYÞsz.ArgumentParser._get_values..csg|]}ˆjˆ|ƒ‘qSr&)rm)rVry)rpr!r&r'rYâsrcsg|]}ˆjˆ|ƒ‘qSr&)rm)rVry)rpr!r&r'rYçs)r™rrr2r;r r€rÈr r¯r­rmÚ _check_valuerrj)r!rpr"r%rnryr&)rpr!r'rWºs>       zArgumentParser._get_valuesc CsÎ|jd|j|jƒ}t|ƒs0tdƒ}t|||ƒ‚y ||ƒ}WnŒtk r~t|jdt|jƒƒ}tt j ƒdƒ}t||ƒ‚YnLt t fk rÈt|jdt|jƒƒ}||dœ}tdƒ}t|||ƒ‚YnX|S)Nrz%r is not callablerrP)rr%z!invalid %(type)s value: %(value)r) rrr&r~rrr/rr­rárSr'r;)r!rprnr*rôr±r$rXr&r&r'rmîs   zArgumentParser._get_valuecCsF|jdk rB||jkrB|djtt|jƒƒdœ}tdƒ}t|||ƒ‚dS)Nz, )r%r²z3invalid choice: %(value)r (choose from %(choices)s))r²r Úmaprr~r)r!rpr%rXrôr&r&r'rz s zArgumentParser._check_valuecCs$|jƒ}|j|j|j|jƒ|jƒS)N)rßrirerrr])r!rSr&r&r'Ú format_usage s zArgumentParser.format_usagecCsx|jƒ}|j|j|j|jƒ|j|jƒx:|jD]0}|j|j ƒ|j|jƒ|j |j ƒ|j ƒq0W|j|j ƒ|jƒS)N)rßrirerrrcrrr_r4rsr�r`rDr])r!rSZ action_groupr&r&r'r] s        zArgumentParser.format_helpcCs|j|jd�S)N)rM)rErM)r!r&r&r'rß0 szArgumentParser._get_formattercCs"|dkrtj}|j|jƒ|ƒdS)N)rárâràr|)r!Úfiler&r&r'Ú print_usage6 szArgumentParser.print_usagecCs"|dkrtj}|j|jƒ|ƒdS)N)rárâràr])r!r}r&r&r'rÛ; szArgumentParser.print_helpcCs |r|dkrtj}|j|ƒdS)N)ráÚstderrÚwrite)r!rÆr}r&r&r'rà@ szArgumentParser._print_messagercCs |r|j|tjƒtj|ƒdS)N)ràrárrÜ)r!ZstatusrÆr&r&r'rÜI szArgumentParser.exitcCs0|jtjƒ|j|dœ}|jdtdƒ|ƒdS)zðerror(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. )rMrÆr3z%(prog)s: error: %(message)s N)r~rárrMrÜr~)r!rÆrXr&r&r'r>N s  zArgumentParser.error)NN)NN)N)N)N)rN)!rr,r-r.rrOrrNr(rOrMrPrñrQrjrqr\rgrlrwrsrWrmrzr|r]rßr~rÛràrÜr>rÑr&r&)rÐr'r1sP4  #w;,,4    )6r.Ú __version__Ú__all__Ú collectionsrèr×rÖÚosr8ÚrerHÚsysráÚtextwrapr»rr~rrr rr rrrór¾rr2rrrrr rÄÚ Exceptionrrr rÎrÒrÓrÔrÕrØrÙrÚrÝrãrr r r+r-rr&r&r&r'Ú>s€ n    [#%`65"