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: Ú ) rUrTrQÚ _join_partsr+rSrVrrB)r!r Z item_helpZcurrent_indentrVr&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!rXrYr&r&r'Ú _add_itemçszHelpFormatter._add_itemcCs0|jƒ|j||j|ƒ}|j|jgƒ||_dS)N)rQrErGr_r^)r!rVZsectionr&r&r'Ú start_sectioníszHelpFormatter.start_sectioncCs|jj|_|jƒdS)N)rGrUrS)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ÚprefixrYr&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)rWÚsr&r&r'rZ 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)rs)r!rgrqr&r&r'Ú add_argumentss zHelpFormatter.add_argumentscCs.|jjƒ}|r*|jjd|ƒ}|jdƒd}|S)Nz r\)rFr^rLÚsubÚstrip)r!rmr&r&r'r^s  zHelpFormatter.format_helpcCsdjdd„|DƒƒS)Nr[cSsg|]}|r|tk r|‘qSr&)r)rWÚpartr&r&r'rZ!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�r0dt|jd�}g}g}x(|D] }|jrŒ|j|ƒqv|j|ƒqvW|j} | |||ƒ} djdd„|| gDƒƒ}|j|j‰t |ƒt |ƒˆk�r0d} | ||ƒ} | ||ƒ} t j | | ƒ}t j | | ƒ}dj|ƒ| k�s,t ‚dj|ƒ| k�s@t ‚d‡fdd „ }t |ƒt |ƒd ˆk�rÌdt |ƒt |ƒd }|�rª||g|||ƒ}|j |||ƒƒn |�rÄ||g|||ƒ}n|g}nZdt |ƒ}||}|||ƒ}t |ƒd k�rg}|j |||ƒƒ|j |||ƒƒ|g|}d j|ƒ}d ||fS)Nzusage: )rMz%(prog)sú cSsg|] }|r|‘qSr&r&)rWrlr&r&r'rZAsz/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)NrPrxr)rkrr )ÚpartsÚindentriÚlinesÚlineZline_lenrw)Ú text_widthr&r'Ú get_linesUs"    z.HelpFormatter._format_usage..get_linesgè?rPr\z%s%s )N)Ú_Údictr<Úoption_stringsrÚ_format_actions_usager rArBrkrHÚfindallrRÚextend)r!rfrgrhrirMZ optionalsÚ positionalsrqÚformatZ action_usageZ part_regexpZ opt_usageZ pos_usageZ opt_partsZ pos_partsr~rzr{ryr&)r}r're%sZ            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)ÚreverserxcSsg|]}|dk r|‘qS)Nr&)rWÚitemr&r&r'rZØsz7HelpFormatter._format_actions_usage..z[\[(]z[\])]z(%s) z\1z (%s)z%s *%sr[z \(([^|]*)\)éÿÿÿÿrŽ)ÚsetÚindexÚ_group_actionsr;rkÚaddÚrequiredÚrangeÚ enumeratermrrÚgetÚpopr�Ú#_get_default_metavar_for_positionalÚ _format_argsÚnargsÚ!_get_default_metavar_for_optionalr)r rHrurv)r!rgrhÚ group_actionsZinsertsÚgroupÚstartÚendrqÚiryÚdefaultrwÚ option_stringÚ args_stringrcÚopenÚcloser&r&r'r‚…sr                 z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd�}t|j|jdƒ}d|j}|j|||ƒdS)Nz%(prog))rMé rxz )r€r<r@rArBÚ _fill_text)r!rcr}rzr&r&r'rbæ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¦r[z%*s%s z %*s%-*s rrPr\)r?rDr>r@rArBrnrmrkÚ _expand_helpÚ _split_linesrÚendswithrorpr]) r!rqZ help_positionZ help_widthZ action_widthZ action_headerÚtupZ indent_firstryZ help_textZ help_linesr|rrr&r&r'rpí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!rqr¡Úmetavarryr£r¢r&r&r'rns     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!rqÚdefault_metavarZ choice_strsr†r&)r²r'r¬4s   z HelpFormatter._metavar_formattercCsÀ|j||ƒ}|jdkr$d|dƒ}n˜|jtkr.rx) r¬ršr rr rrr”r )r!rqr´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®)rWÚcr&r&r'rZ`sz.HelpFormatter._expand_help..) r€Úvarsr<ÚlistrÚhasattrrr–r Ú_get_help_string)r!rqZparamsr$Z choices_strr&r&r'r¨Ws  zHelpFormatter._expand_helpc cs@y |j}Wntk rYnX|jƒ|ƒEdH|jƒdS)N)Ú_get_subactionsÚAttributeErrorrQrS)r!rqZget_subactionsr&r&r'rods  z'HelpFormatter._iter_indented_subactionscCs|jjd|ƒjƒ}tj||ƒS)Nrx)rKrurvÚ _textwrapZwrap)r!rcrNr&r&r'r©nszHelpFormatter._split_linescCs$|jjd|ƒjƒ}tj||||d�S)Nrx)Zinitial_indentZsubsequent_indent)rKrurvr¼Zfill)r!rcrNrzr&r&r'r§rs zHelpFormatter._fill_textcCs|jS)N)rm)r!rqr&r&r'r¹wszHelpFormatter._get_help_stringcCs |jjƒS)N)ÚdestÚupper)r!rqr&r&r'r›zsz/HelpFormatter._get_default_metavar_for_optionalcCs|jS)N)r½)r!rqr&r&r'r˜}sz1HelpFormatter._get_default_metavar_for_positional)r3r4N)N) rr,r-r.rOrQrSÚobjectrEr_r`rardrjrsrtr^r]rer‚rbrprnr¬r™r¨ror©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)Nr[c3s|]}ˆ|VqdS)Nr&)rWr|)rzr&r'ú ‰sz9RawDescriptionHelpFormatter._fill_text..T)Úkeepends)r Ú splitlines)r!rcrNrzr&)rzr'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!rcrNr&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))rmr¡rr rr�rš)r!rqrmZdefaulting_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!rqr&r&r'r›°sz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjS)N)rr)r!rqr&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“rmr­)r;r ÚsuperrÏrO) r!r�r½ršrÉr¡rr³r“rmr­)Ú __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“rm)rÐrÓrO)r!r�r½rÉr¡r“rmr­)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“rm)rÐrÔrO)r!r�r½r¡r“rm)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“rm)rÐrÕrO)r!r�r½r¡r“rm)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“rmr­)r;r rÐrÖrO) r!r�r½ršrÉr¡rr³r“rmr­)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“rmr­)rÐrÙrO)r!r�r½rÉr¡r“rmr­)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“rm)rÐrÚrO)r!r�r½r¡r“rm)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šrm)rÐrÛrO)r!r�r½r¡rm)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šrm)rÐrÞrOÚversion)r!r�rßr½r¡rm)rÑr&r'rOs z_VersionAction.__init__cCsD|j}|dkr|j}|jƒ}|j|ƒ|j|jƒtjƒ|jƒdS)N)rßÚ_get_formatterrdÚ_print_messager^Ú_sysÚstdoutrÝ)r!rÌr1rÍr¢rßrTr&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½rmr­)r rÐräÚ_ChoicesPseudoActionrO)r!r$Úaliasesrmr­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³rmr­) Ú _prog_prefixÚ _parser_classÚ _collectionsÚ OrderedDictÚ_name_parser_mapÚ_choices_actionsrÐrärOr)r!r�rMÚ parser_classr½rmr­)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ærm)r–rçr—rårìrrèrë)r!r$ÚkwargsrærmZ 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 rrÚparse_known_argsr¶r+Ú setdefaultÚ_UNRECOGNIZED_ARGS_ATTRr/r„) r!rÌr1rÍr¢rñr"rYÚ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ãrr;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)rWr#r&r&r'rZ«sz%FileType.__repr__..cSs$g|]\}}|dk rd||f‘qS)Nz%s=%rr&)rWÚkwr#r&r&r'rZ¬sz%s(%s))rørùrúrûr rr)r!rYrî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.rOr r 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) NrqZstoreÚ store_constÚ store_trueZ store_falserZ append_constÚcountrmrßÚ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îrqr&r&r'Ú set_defaultss   z_ActionsContainer.set_defaultscCs8x(|jD]}|j|kr|jdk r|jSqW|jj|dƒS)N)rr½r¡rr–)r!r½rqr&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!rqr¢r&r&r'r)Ts     z_ActionsContainer._add_actioncCs|jj|ƒdS)N)rÚremove)r!rqr&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“)rr5rr;r-rrr‘rr/r“rr–r))r!r1Ztitle_group_mapr�rõZ group_maprqÚ 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�)rr(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 %rrr)r½r�) rrr;rrkr—ÚlstripÚreplacer€) r!rYrîr�Zlong_option_stringsr¢rõr½Zdest_option_stringr&r&r'r%¤s0          z&_ActionsContainer._get_optional_kwargscCs|jd|ƒ}|jd||ƒS)Nrq)r—r )r!rîr¡rqr&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»rr;)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!rqZconfl_optionalsr¢Zconfl_optionalrr&r&r'r0Õs   z!_ActionsContainer._check_conflictcCs6tddt|ƒƒ}djdd„|Dƒƒ}t|||ƒ‚dS)Nzconflicting option string: %szconflicting option strings: %sz, cSsg|] \}}|‘qSr&r&)rWr¢rqr&r&r'rZçsz<_ActionsContainer._handle_conflict_error..)rrkr r)r!rqÚ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�r3rr—r1r4)r!rqr;r¢r&r&r'Ú_handle_conflict_resolveìs  z*_ActionsContainer._handle_conflict_resolve)N)N)rr,r-rOrr r"r#rsr-r/r)r4r7r$r%r&rr0r<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,rOr5r‘rrrrrr)r!r1r5rrîr!Z super_init)rÑr&r'rOýs    z_ArgumentGroup.__init__cs tt|ƒj|ƒ}|jj|ƒ|S)N)rÐr,r)r‘r)r!rq)rÑr&r'r)s z_ArgumentGroup._add_actioncs tt|ƒj|ƒ|jj|ƒdS)N)rÐr,r4r‘r3)r!rq)rÑr&r'r4sz_ArgumentGroup._remove_action)NN)rr,r-rOr)r4rÒ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!r1r“)rÑr&r'rOsz _MutuallyExclusiveGroup.__init__cCs2|jrtdƒ}t|ƒ‚|jj|ƒ}|jj|ƒ|S)Nz-mutually exclusive arguments must be optional)r“rr;r>r)r‘r)r!rqrõr&r&r'r)$s   z#_MutuallyExclusiveGroup._add_actioncCs|jj|ƒ|jj|ƒdS)N)r>r4r‘r3)r!rqr&r&r'r4,s z&_MutuallyExclusiveGroup._remove_action)F)rr,r-rOr)r4rÒ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Úhr3rmzshow this help message and exit)rqr¡rm)rÐrrOr8ÚpathÚbasenamerâÚargvrMrfÚepilogÚformatter_classÚfromfile_prefix_charsÚadd_helpÚ allow_abbrevr-rÚ _positionalsÚ _optionalsÚ _subparsersrrsrr7rr»r!)r!rMrfrrEÚparentsrFrrGrrrHrIZ superinitZ add_groupr@Zdefault_prefixrUZdefaults)rÑr&r'rODsB     zArgumentParser.__init__cs"ddddddg}‡fdd„|DƒS) NrMrfrrFrrHcsg|]}|tˆ|ƒf‘qSr&)r/)rWr$)r!r&r'rZ�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ír5rZ subcommandsrMr[rr�)rLr?rrórr—r-rJr–ràÚ_get_positional_actionsrrjrfr^rvr&r)) r!rîr5rrTr…rhZ parsers_classrqr&r&r'Úadd_subparsers’s$   zArgumentParser.add_subparserscCs$|jr|jj|ƒn |jj|ƒ|S)N)r�rKr)rJ)r!rqr&r&r'r)±s zArgumentParser._add_actioncCsdd„|jDƒS)NcSsg|]}|jr|‘qSr&)r�)rWrqr&r&r'rZ¹sz8ArgumentParser._get_optional_actions..)r)r!r&r&r'Ú_get_optional_actions¸sz$ArgumentParser._get_optional_actionscCsdd„|jDƒS)NcSsg|]}|js|‘qSr&)r�)rWrqr&r&r'rZ¾sz:ArgumentParser._get_positional_actions..)r)r!r&r&r'rN½sz&ArgumentParser._get_positional_actionscCs4|j||ƒ\}}|r0tdƒ}|j|dj|ƒƒ|S)Nzunrecognized arguments: %srx)ròrr?r )r!rYr1rDrõ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ârDr·r rr½rr¸r¡r0rÚ_parse_known_argsrôr„r/ÚdelattrrÚexc_infor?r®)r!rYr1rqr½Ú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ÚOr[cs€ˆ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–rrÅrr)rqZargument_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 W|�sht‚x |D]\}}}ˆ|||ƒ�qnW| S)NrPrVrzignored explicit argument %r)Ú_match_argumentrrrrrrR)Ú start_indexÚ option_tuplerqr¢Ú explicit_argZmatch_argumentZ action_tuplesÚ arg_countr*ÚcharZnew_explicit_argZ optionals_maprõÚstoprYržZselected_patterns)r"Úarg_strings_patternÚextrasÚoption_string_indicesr!r\r&r'Úconsume_optional3sP        z:ArgumentParser._parse_known_args..consume_optionalcsrˆj}ˆ|d…}|ˆ|ƒ}x8tˆ|ƒD]*\}}ˆ|||…}||7}ˆ||ƒq(Wˆt|ƒd…ˆdd…<|S)N)Ú_match_arguments_partialÚziprk)r^Z match_partialZselected_patternZ arg_countsrqrarY)r"rdr…r!r\r&r'Úconsume_positionals€s  z=ArgumentParser._parse_known_args..consume_positionalsrcsg|]}|ˆkr|‘qSr&r&)rWr�)r^r&r'rZžsz4ArgumentParser._parse_known_args..z(the following arguments are required: %sz, cSsg|]}|jtk rt|ƒ‘qSr&)rmrrÅ)rWrqr&r&r'rZÜsz#one of the arguments %s is requiredrx)NrŽ)rGÚ_read_args_from_filesrr‘r•rór„ÚiterrÚ_parse_optionalr r�rNr@r?rr“rÅr¡r°r®r¸r½r/r0Ú _get_valuer?r)r!r"r1r6rœr Z mutex_actionZ conflictsZarg_string_pattern_partsZarg_strings_iterÚ arg_stringr_ÚpatternrgrjZmax_option_string_indexZnext_option_string_indexZpositionals_end_indexZstringsZ stop_indexZrequired_actionsrqr�rÊrõr&) rYr"rdrer1rfr…rZr[r!r^r\r'rRï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) rGrr¤ÚreadrÂÚconvert_arg_line_to_argsrkr„rrârTr?r®)r!r"Znew_arg_stringsroZ args_fileÚarg_liner#rUr&r&r'rkås     z$ArgumentParser._read_args_from_filescCs|gS)Nr&)r!rsr&r&r'rrÿ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_patternrHr2rr r rršr–rrkr�)r!rqrdÚ nargs_patternr2Z 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)NrrPr[csg|]}ˆj|ƒ‘qSr&)rt)rWrq)r!r&r'rZsz;ArgumentParser._match_arguments_partial..cSsg|] }t|ƒ‘qSr&)rk)rWrr&r&r'rZ!srŽ)r”rkr rHr2r„rh)r!rgrdr²r Z actions_slicerpr2r&)r!r'rhs   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&)rWrqr¢r`r&r&r'rZGsz2ArgumentParser._parse_optional..)r8Zmatchesz4ambiguous option: %(option)s could match %(matches)srx) rrrkÚsplitrIÚ_get_option_tuplesr rr?rr2r) r!rorqr¢r`Z option_tuplesZoptionsrYrõr_r&r&r'rm'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)NrrPrvr3zunexpected option string: %s)rrwrÚ startswithrr?r) r!r¢r²r*Z option_prefixr`rqr«Zshort_option_prefixZshort_explicit_argr&r&r'rxbs8             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-*rVr[r) ršr rr rrr r�r:)r!rqršrur&r&r'rtŽ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&)rn)rWÚv)rqr!r&r'rZÞsz.ArgumentParser._get_values..csg|]}ˆjˆ|ƒ‘qSr&)rn)rWrz)rqr!r&r'rZâsrcsg|]}ˆjˆ|ƒ‘qSr&)rn)rWrz)rqr!r&r'rZçs)ršrrr3r;r r�rÉr¡r°r®rnÚ _check_valuerrk)r!rqr"r%rorzr&)rqr!r'rXº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) r rr'rrrr/rr®rârTr(r;)r!rqror+rõr²r$rYr&r&r'rnî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 Úmaprrr)r!rqr%rYrõr&r&r'r{ s zArgumentParser._check_valuecCs$|jƒ}|j|j|j|jƒ|jƒS)N)ràrjrfrrr^)r!rTr&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àrjrfrrrdrrr`r5rtr‘rarEr^)r!rTZ action_groupr&r&r'r^ s        zArgumentParser.format_helpcCs|j|jd�S)N)rM)rFrM)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âr€rÝ)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)rrâr€rMrÝr)r!rÇrYr&r&r'r?N s  zArgumentParser.error)NN)NN)N)N)N)rN)!rr,r-r.rrOrrOr)rPrNrQròrRrkrrr]rhrmrxrtrXrnr{r}r^ràrrÜrárÝr?rÒr&r&)rÑr'r1sP4  #w;,,4    )6r.Ú __version__Ú__all__Ú collectionsrérØr×Úosr8ÚrerHÚsysrâÚtextwrapr¼rrrrr 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"