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
 lŽŒY`ã@sdZdZdddddddd 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<e%ƒZ.Gd=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...Ú_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}x'|jƒD]}|jt|ƒƒq"Wx1|jƒD]#\}}|jd||fƒqLWd|dj|ƒfS)Nz%s=%rz%s(%s)z, )ÚtypeÚ__name__Ú _get_argsÚappendÚreprÚ _get_kwargsÚjoin)ÚselfÚ type_nameÚ arg_stringsÚargÚnameÚvalue©r'ú'/opt/python35/lib/python3.5/argparse.pyÚ__repr__vsz_AttributeHolder.__repr__cCst|jjƒƒS)N)ÚsortedÚ__dict__Úitems)r!r'r'r(rsz_AttributeHolder._get_kwargscCsgS)Nr')r!r'r'r(r‚sz_AttributeHolder._get_argsN)rÚ __module__Ú __qualname__Ú__doc__r)rrr'r'r'r(rms  rcCs5t||dƒdkr(t|||ƒt||ƒS)N)ÚgetattrÚsetattr)Ú namespacer%r&r'r'r(Ú _ensure_value†sr3c@speZdZdZddddd„Zdd„Zd d „ZGd d „d eƒZd d„Z dd„Z dd„Z dd„Z ddd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„ZdS);rz×Formatter 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. ééNcCsÿ|dkrNyttjdƒ}Wnttfk rCd}YnX|d8}||_||_||_t|t |d|dƒƒ|_||_ d|_ d|_ d|_ |j|dƒ|_|j|_tjdtjƒ|_tjdƒ|_dS)NÚCOLUMNSéPr4érz\s+z\n\n\n+)ÚintÚ_osÚenvironÚKeyErrorÚ ValueErrorÚ_progÚ_indent_incrementÚ_max_help_positionÚminÚmaxÚ_widthÚ_current_indentÚ_levelÚ_action_max_lengthÚ_SectionÚ _root_sectionÚ_current_sectionÚ_reÚcompileÚASCIIÚ_whitespace_matcherÚ_long_break_matcher)r!ÚprogÚindent_incrementÚmax_help_positionÚwidthr'r'r(Ú__init__—s&           zHelpFormatter.__init__cCs%|j|j7_|jd7_dS)Né)rDr?rE)r!r'r'r(Ú_indent¹szHelpFormatter._indentcCs@|j|j8_|jdks-tdƒ‚|jd8_dS)NrzIndent decreased below 0.rT)rDr?ÚAssertionErrorrE)r!r'r'r(Ú_dedent½szHelpFormatter._dedentc@s+eZdZddd„Zdd„ZdS)zHelpFormatter._SectionNcCs(||_||_||_g|_dS)N)Ú formatterÚparentÚheadingr,)r!rXrYrZr'r'r(rSÄs   zHelpFormatter._Section.__init__cCsí|jdk r|jjƒ|jj}x!|jD]\}}||Œq2W|dd„|jDƒƒ}|jdk r„|jjƒ|sŽdS|jtk rÑ|jdk rÑ|jj}d|d|jf}nd}|d||dgƒS)NcSs"g|]\}}||Œ‘qSr'r')Ú.0ÚfuncÚargsr'r'r(ú Ñs z6HelpFormatter._Section.format_help..Úz%*s%s: Ú ) rYrXrUÚ _join_partsr,rWrZrrD)r!r r\r]Ú item_helpÚcurrent_indentrZr'r'r(Ú format_helpÊs    z"HelpFormatter._Section.format_help)rr-r.rSrdr'r'r'r(rGÂs rGcCs|jjj||fƒdS)N)rIr,r)r!r\r]r'r'r(Ú _add_itemãszHelpFormatter._add_itemcCsB|jƒ|j||j|ƒ}|j|jgƒ||_dS)N)rUrGrIrerd)r!rZÚsectionr'r'r(Ú start_sectionés zHelpFormatter.start_sectioncCs|jj|_|jƒdS)N)rIrYrW)r!r'r'r(Ú end_sectionïszHelpFormatter.end_sectioncCs2|tk r.|dk r.|j|j|gƒdS)N)rreÚ _format_text)r!Útextr'r'r(Úadd_textószHelpFormatter.add_textcCs5|tk r1||||f}|j|j|ƒdS)N)rreÚ _format_usage)r!ÚusageÚactionsÚgroupsÚprefixr]r'r'r(Ú add_usage÷s zHelpFormatter.add_usagecCs©|jtk r¥|j}||ƒg}x*|j|ƒD]}|j||ƒƒq7Wtdd„|Dƒƒ}||j}t|j|ƒ|_|j|j |gƒdS)NcSsg|]}t|ƒ‘qSr')Úlen)r[Úsr'r'r(r^s z.HelpFormatter.add_argument..) ÚhelprÚ_format_action_invocationÚ_iter_indented_subactionsrrBrDrFreÚ_format_action)r!ÚactionÚget_invocationÚ invocationsÚ subactionÚinvocation_lengthÚ action_lengthr'r'r(Ú add_argumentüs    zHelpFormatter.add_argumentcCs"x|D]}|j|ƒqWdS)N)r~)r!rnrxr'r'r(Ú add_argumentss zHelpFormatter.add_argumentscCsA|jjƒ}|r=|jjd|ƒ}|jdƒd}|S)Nz r`)rHrdrNÚsubÚstrip)r!rtr'r'r(rds zHelpFormatter.format_helpcCsdjdd„|DƒƒS)Nr_cSs(g|]}|r|tk r|‘qSr')r)r[Úpartr'r'r(r^s z-HelpFormatter._join_parts..)r )r!Ú part_stringsr'r'r(raszHelpFormatter._join_partscs|dkrtdƒ}|dk r=|td|jƒ}n»|dkri| ridtd|jƒ}n�|dkrødtd|jƒ}g}g}x4|D],}|jr½|j|ƒqž|j|ƒqžW|j} | |||ƒ} djdd„|| gDƒƒ}|j|j‰t |ƒt |ƒˆkrød} | ||ƒ} | ||ƒ} t j | | ƒ}t j | | ƒ}dj|ƒ| ks›t ‚dj|ƒ| ks¶t ‚d‡fdd †}t |ƒt |ƒd ˆkrodt |ƒt |ƒd }|rA||g|||ƒ}|j |||ƒƒqé|rc||g|||ƒ}qé|g}nzdt |ƒ}||}|||ƒ}t |ƒd krÜg}|j |||ƒƒ|j |||ƒƒ|g|}d j|ƒ}d ||fS)Nzusage: rOz%(prog)sú cSsg|]}|r|‘qSr'r')r[rsr'r'r(r^=s z/HelpFormatter._format_usage..z\(.*?\)+|\[.*?\]+|\S+cs g}g}|dk r+t|ƒd}nt|ƒd}x|D]w}|dt|ƒˆkr˜|r˜|j|dj|ƒƒg}t|ƒd}|j|ƒ|t|ƒd7}qBW|rÝ|j|dj|ƒƒ|dk r|dt|ƒd…|d<|S)NrTr„r)rrrr )ÚpartsÚindentrpÚlinesÚlineÚline_lenr‚)Ú text_widthr'r(Ú get_linesMs"     z.HelpFormatter._format_usage..get_linesgè?rTr`z%s%s )Ú_Údictr>Úoption_stringsrÚ_format_actions_usager rCrDrrrJÚfindallrVÚextend)r!rmrnrorprOÚ optionalsÚ positionalsrxÚformatÚ action_usageÚ part_regexpÚ opt_usageÚ pos_usageÚ opt_partsÚ pos_partsr‹r†r‡r…r')rŠr(rl!sZ       "    zHelpFormatter._format_usagec Cs•tƒ}i}x#|D]}y|j|jdƒ}Wntk rMwYqX|t|jƒ}|||…|jkrx|jD]}|j|ƒq„W|jsØ||krÁ||d7.z[\[(]z[\])]z(%s) z\1z (%s)z%s *%sr_z \(([^|]*)\)éÿÿÿÿr¢)ÚsetÚindexÚ_group_actionsr=rrÚaddÚrequiredÚrangeÚ enumeratertrrÚgetÚpoprŽÚ#_get_default_metavar_for_positionalÚ _format_argsÚnargsÚ!_get_default_metavar_for_optionalr*r rJr€r�)r!rnroÚ group_actionsÚinsertsÚgroupÚstartÚendrxÚir…Údefaultr‚Ú option_stringÚ args_stringrjÚopenÚcloser'r'r(r�}sr                  z#HelpFormatter._format_actions_usagecCs_d|kr"|td|jƒ}t|j|jdƒ}d|j}|j|||ƒdS)Nz%(prog)rOé r„z )r�r>rBrCrDÚ _fill_text)r!rjrŠr†r'r'r(riÞs   zHelpFormatter._format_textc Csµt|jd|jƒ}t|j|dƒ}||jd}|j|ƒ}|jsw|jd|f}d|}n\t|ƒ|kr±|jd||f}d|}d}n"|jd|f}d|}|}|g}|jr\|j |ƒ} |j | |ƒ} |j d|d| dfƒxQ| dd…D] } |j d|d| fƒq5Wn|j dƒsx|j dƒx-|j |ƒD]} |j |j| ƒƒqˆW|j|ƒS) Nr4r»r_z%*s%s z %*s%-*s rrTr`)rArFr@rBrCrDrurtrrÚ _expand_helpÚ _split_linesrÚendswithrvrwra) r!rxÚ help_positionÚ help_widthÚ action_widthÚ action_headerÚtupÚ indent_firstr…Ú help_textÚ help_linesrˆr{r'r'r(rwås6         ! zHelpFormatter._format_actioncCs¼|js7|j|ƒ}|j||ƒdƒ\}|Sg}|jdkr_|j|jƒnL|j|ƒ}|j||ƒ}x(|jD]}|jd||fƒqŠWdj|ƒSdS)NrTrz%s %sz, ) rŽr¬Ú_metavar_formatterr®r‘r¯r­rr )r!rxr¶Úmetavarr…r¸r·r'r'r(rus z'HelpFormatter._format_action_invocationcsr|jdk r|j‰nA|jdk rVdd„|jDƒ}ddj|ƒ‰n|‰‡fdd†}|S)NcSsg|]}t|ƒ‘qSr')Ústr)r[Úchoicer'r'r(r^0s z4HelpFormatter._metavar_formatter..z{%s}ú,cs"tˆtƒrˆSˆf|SdS)N)Ú isinstanceÚtuple)Ú tuple_size)Úresultr'r(r”5sz0HelpFormatter._metavar_formatter..format)rÉÚchoicesr )r!rxÚdefault_metavarÚ choice_strsr”r')rÐr(rÈ,s z HelpFormatter._metavar_formattercCs|j||ƒ}|jdkr4d|dƒ}nØ|jtkrVd|dƒ}n¶|jtkrxd|dƒ}n”|jtkršd|dƒ}nr|jtkr²d}nZ|jtkrÔd|dƒ}n8d d „t|jƒDƒ}d j|ƒ||jƒ}|S) Nz%srTz[%s]z [%s [%s ...]]r4z %s [%s ...]z...z%s ...cSsg|] }d‘qS)z%sr')r[rŒr'r'r(r^Ks z.HelpFormatter._format_args..r„) rÈr®r rr rrr¨r )r!rxrÒÚ get_metavarrÐÚformatsr'r'r(r­<s  zHelpFormatter._format_argscCsÔtt|ƒd|jƒ}x+t|ƒD]}||tkr(||=q(Wx8t|ƒD]*}t||dƒrV||j||.) r�Úvarsr>ÚlistrÚhasattrrrªr Ú_get_help_string)r!rxÚparamsr%Ú choices_strr'r'r(r½Os   zHelpFormatter._expand_helpc csFy |j}Wntk r!Yn!X|jƒ|ƒEdH|jƒdS)N)Ú_get_subactionsÚAttributeErrorrUrW)r!rxÚget_subactionsr'r'r(rv\s    z'HelpFormatter._iter_indented_subactionscCs+|jjd|ƒjƒ}tj||ƒS)Nr„)rMr€r�Ú _textwrapÚwrap)r!rjrRr'r'r(r¾fszHelpFormatter._split_linescCs7|jjd|ƒjƒ}tj||d|d|ƒS)Nr„Úinitial_indentÚsubsequent_indent)rMr€r�ràÚfill)r!rjrRr†r'r'r(r¼jszHelpFormatter._fill_textcCs|jS)N)rt)r!rxr'r'r(rÚoszHelpFormatter._get_help_stringcCs |jjƒS)N)ÚdestÚupper)r!rxr'r'r(r¯rsz/HelpFormatter._get_default_metavar_for_optionalcCs|jS)N)rå)r!rxr'r'r(r¬usz1HelpFormatter._get_default_metavar_for_positional) rr-r.r/rSrUrWÚobjectrGrergrhrkrqr~rrdrarlr�rirwrurÈr­r½rvr¾r¼rÚr¯r¬r'r'r'r(r�s<   !         \ a  /       c@s"eZdZdZdd„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')r[rˆ)r†r'r(ú �sz9RawDescriptionHelpFormatter._fill_text..ÚkeependsT)r Ú splitlines)r!rjrRr†r')r†r(r¼€sz&RawDescriptionHelpFormatter._fill_textN)rr-r.r/r¼r'r'r'r(rys c@s"eZdZdZdd„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!rjrRr'r'r(r¾‹sz!RawTextHelpFormatter._split_linesN)rr-r.r/r¾r'r'r'r(r„s c@s"eZdZdZdd„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. cCsY|j}d|jkrU|jtk rUttg}|jsK|j|krU|d7}|S)Nz %(default)z (default: %(default)s))rtr¶rr rrŽr®)r!rxrtÚdefaulting_nargsr'r'r(rÚ–s   z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr-r.r/rÚr'r'r'r(r�s c@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!rxr'r'r(r¯¨sz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs |jjS)N)rr)r!rxr'r'r(r¬«sz.r')r!Únamesr')r!r(r's zAction._get_kwargscCsttdƒƒ‚dS)Nz.__call__() not defined)ÚNotImplementedErrorrŒ)r!Úparserr2Úvaluesr·r'r'r(Ú__call__5szAction.__call__)rr-r.r/rSrr÷r'r'r'r(r Þs 1 c sIeZdZdddddddd‡fdd†Zddd„Z‡S)Ú _StoreActionNFc s“|dkrtdƒ‚|dk r@|tkr@tdtƒ‚tt|ƒjd|d|d|d|d|d |d |d |d | 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 constrŽrår®ròr¶rrÑr§rtrÉ)r=r ÚsuperrørS) r!rŽrår®ròr¶rrÑr§rtrÉ)Ú __class__r'r(rS;s  z_StoreAction.__init__cCst||j|ƒdS)N)r1rå)r!rõr2rör·r'r'r(r÷Xsz_StoreAction.__call__)rr-r.rSr÷r'r')rúr(rø9s røcs=eZdZdddd‡fdd†Zddd„Z‡S)Ú_StoreConstActionNFcsAtt|ƒjd|d|ddd|d|d|d|ƒdS) NrŽrår®rròr¶r§rt)rùrûrS)r!rŽråròr¶r§rtrÉ)rúr'r(rS^sz_StoreConstAction.__init__cCst||j|jƒdS)N)r1rårò)r!rõr2rör·r'r'r(r÷osz_StoreConstAction.__call__)rr-r.rSr÷r'r')rúr(rû\s  rûcs+eZdZddd‡fdd†Z‡S)Ú_StoreTrueActionFNc s;tt|ƒjd|d|ddd|d|d|ƒdS)NrŽråròTr¶r§rt)rùrürS)r!rŽrår¶r§rt)rúr'r(rSusz_StoreTrueAction.__init__)rr-r.rSr'r')rúr(rüss rücs+eZdZddd‡fdd†Z‡S)Ú_StoreFalseActionTFNc s;tt|ƒjd|d|ddd|d|d|ƒdS)NrŽråròFr¶r§rt)rùrýrS)r!rŽrår¶r§rt)rúr'r(rS†sz_StoreFalseAction.__init__)rr-r.rSr'r')rúr(rý„s rýc sIeZdZdddddddd‡fdd†Zddd„Z‡S)Ú _AppendActionNFc s“|dkrtdƒ‚|dk r@|tkr@tdtƒ‚tt|ƒjd|d|d|d|d|d |d |d |d | 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 constrŽrår®ròr¶rrÑr§rtrÉ)r=r rùrþrS) r!rŽrår®ròr¶rrÑr§rtrÉ)rúr'r(rS—s  z_AppendAction.__init__cCsBtjt||jgƒƒ}|j|ƒt||j|ƒdS)N)Ú_copyÚcopyr3rårr1)r!rõr2rör·r,r'r'r(r÷´s z_AppendAction.__call__)rr-r.rSr÷r'r')rúr(rþ•s rþcs=eZdZdddd‡fdd†Zddd„Z‡S)Ú_AppendConstActionNFcsGtt|ƒjd|d|ddd|d|d|d|d |ƒdS) NrŽrår®rròr¶r§rtrÉ)rùrrS)r!rŽråròr¶r§rtrÉ)rúr'r(rS¼sz_AppendConstAction.__init__cCsEtjt||jgƒƒ}|j|jƒt||j|ƒdS)N)rÿrr3rårròr1)r!rõr2rör·r,r'r'r(r÷Îsz_AppendConstAction.__call__)rr-r.rSr÷r'r')rúr(rºs  rcs:eZdZddd‡fdd†Zddd„Z‡S)Ú _CountActionNFc s;tt|ƒjd|d|ddd|d|d|ƒdS)NrŽrår®rr¶r§rt)rùrrS)r!rŽrår¶r§rt)rúr'r(rSÖsz_CountAction.__init__cCs0t||jdƒd}t||j|ƒdS)NrrT)r3rår1)r!rõr2rör·Ú new_countr'r'r(r÷äsz_CountAction.__call__)rr-r.rSr÷r'r')rúr(rÔs  rcs:eZdZeed‡fdd†Zddd„Z‡S)Ú _HelpActionNc s5tt|ƒjd|d|d|ddd|ƒdS)NrŽrår¶r®rrt)rùrrS)r!rŽrår¶rt)rúr'r(rSës z_HelpAction.__init__cCs|jƒ|jƒdS)N)Ú print_helpÚexit)r!rõr2rör·r'r'r(r÷÷s z_HelpAction.__call__)rr-r.rrSr÷r'r')rúr(rés rcs=eZdZdeed‡fdd†Zddd„Z‡S)Ú_VersionActionNz&show program's version number and exitc s>tt|ƒjd|d|d|ddd|ƒ||_dS)NrŽrår¶r®rrt)rùrrSÚversion)r!rŽrrår¶rt)rúr'r(rSþsz_VersionAction.__init__cCs^|j}|dkr|j}|jƒ}|j|ƒ|j|jƒtjƒ|jƒdS)N)rÚ_get_formatterrkÚ_print_messagerdÚ_sysÚstdoutr)r!rõr2rör·rrXr'r'r(r÷ s     z_VersionAction.__call__)rr-r.rrSr÷r'r')rúr(rüs  rcsheZdZGdd„deƒZedd‡fdd†Zdd„Zdd „Zdd d „Z ‡S) Ú_SubParsersActioncs"eZdZ‡fdd†Z‡S)z&_SubParsersAction._ChoicesPseudoActionc s_|}}|r'|ddj|ƒ7}ttj|ƒ}|jdgd|d|d|ƒdS)Nz (%s)z, rŽrårtrÉ)r rùr Ú_ChoicesPseudoActionrS)r!r%ÚaliasesrtrÉråÚsup)rúr'r(rSs  z/_SubParsersAction._ChoicesPseudoAction.__init__)rr-r.rSr'r')rúr(rs rNc sh||_||_tjƒ|_g|_tt|ƒjd|d|dt d|jd|d|ƒdS)NrŽrår®rÑrtrÉ) Ú _prog_prefixÚ _parser_classÚ _collectionsÚ OrderedDictÚ_name_parser_mapÚ_choices_actionsrùr rSr)r!rŽrOÚ parser_classrårtrÉ)rúr'r(rS"s    z_SubParsersAction.__init__cKs¼|jdƒdkr,d|j|f|d<|jdfƒ}d|kr~|jdƒ}|j|||ƒ}|jj|ƒ|j|�}||j|.cSs2g|](\}}|dk rd||f‘qS)Nz%s=%rr')r[Úkwr$r'r'r(r^¤s z%s(%s))r$r%r&r'r rr)r!r]rÚargs_strr'r'r(r) s zFileType.__repr__r¢)rr-r.r/rSr÷r)r'r'r'r(rvs  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)r1)r!rr%r'r'r(rS³s zNamespace.__init__cCs)t|tƒstSt|ƒt|ƒkS)N)rÍr ÚNotImplementedr×)r!Úotherr'r'r(Ú__eq__·szNamespace.__eq__cCs ||jkS)N)r+)r!r"r'r'r(Ú __contains__¼szNamespace.__contains__N)rr-r.r/rSr6r7r'r'r'r(r ¬s   csôeZdZ‡fdd†Zdd„Zddd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zddd„Zdd„Zd d!„Zd"d#„Zd$d%„Z‡S)&Ú_ActionsContainercsgtt|ƒ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) NrxÚstoreÚ store_constÚ store_trueÚ store_falserÚ append_constÚcountrtrÚparsersz^-\d+$|^-\d*\.\d+$)rùr8rSÚ descriptionÚargument_defaultÚ prefix_charsÚconflict_handlerÚ _registriesÚregisterrørûrürýrþrrrrr Ú _get_handlerÚ_actionsÚ_option_string_actionsÚ_action_groupsÚ_mutually_exclusive_groupsÚ _defaultsrJrKÚ_negative_number_matcherÚ_has_negative_number_optionals)r!r@rBrArC)rúr'r(rSÂs2           z_ActionsContainer.__init__cCs#|jj|iƒ}|||.)rrrr r)r!rxÚconflicting_actionsrðÚconflict_stringr'r'r(Ú_handle_conflict_errorÛs  z(_ActionsContainer._handle_conflict_errorcCsWxP|D]H\}}|jj|ƒ|jj|dƒ|js|jj|ƒqWdS)N)rŽrdrHr«rbre)r!rxrsr·r'r'r(Ú_handle_conflict_resolveäs  z*_ActionsContainer._handle_conflict_resolve)rr-r.rSrErPrRrSr~r^r`rYrerjrTrUrVrFrarurvr'r')rúr(r8Às$ 4  /     (  $  r8csLeZdZdd‡fdd†Z‡fdd†Z‡fdd†Z‡S)r]Nc s¹|j}|d|jƒ|d|jƒ|d|jƒtt|ƒj}|d||�||_g|_|j |_ |j |_ |j |_ |j |_ |j |_ |j|_dS)NrCrBrAr@)rrCrBrArùr]rSrfr¥rDrGrHrKrMrJ)r!rbrfr@rrQÚ super_init)rúr'r(rSõs        z_ArgumentGroup.__init__cs,tt|ƒj|ƒ}|jj|ƒ|S)N)rùr]rYr¥r)r!rx)rúr'r(rY sz_ArgumentGroup._add_actioncs*tt|ƒj|ƒ|jj|ƒdS)N)rùr]rer¥rd)r!rx)rúr'r(resz_ArgumentGroup._remove_action)rr-r.rSrYrer'r')rúr(r]ós r]cs=eZdZd‡fdd†Zdd„Zdd„Z‡S)r_Fcs,tt|ƒj|ƒ||_||_dS)N)rùr_rSr§Ú _container)r!rbr§)rúr'r(rSs z _MutuallyExclusiveGroup.__init__cCsG|jr!tdƒ}t|ƒ‚|jj|ƒ}|jj|ƒ|S)Nz-mutually exclusive arguments must be optional)r§rŒr=rxrYr¥r)r!rxr r'r'r(rYs    z#_MutuallyExclusiveGroup._add_actioncCs$|jj|ƒ|jj|ƒdS)N)rxrer¥rd)r!rxr'r'r(re$sz&_MutuallyExclusiveGroup._remove_action)rr-r.rSrYrer'r')rúr(r_s  r_csŸeZdZdZddddgedddddd‡fdd† Zdd „Zd d „Zd d „Zdd„Z dd„Z dddd„Z dddd„Z dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„Zd0d1„Zdd2d3„Zdd4d5„Zdd6d7„Zd8dd9d:„Zd;d<„Z‡S)=ra®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|d|d| d| ƒ|dkrVtjjtjdƒ}||_||_ ||_ ||_ ||_ | |_ | |_|j}|tdƒƒ|_|tdƒƒ|_d|_dd „}|jd d|ƒd |krd n|d}|j rI|j|d |d ddddtdtdƒƒxM|D]E}|j|ƒy |j}Wntk r„YqPX|jj|ƒqPWdS)Nr@rBrArCrzpositional argumentszoptional argumentscSs|S)Nr')r0r'r'r(Úidentitybsz)ArgumentParser.__init__..identityrr,Úhr4rtrxr¶zshow this help message and exit)rùrrSr:ÚpathÚbasenamer ÚargvrOrmÚepilogÚformatter_classÚfromfile_prefix_charsÚadd_helpÚ allow_abbrevr^rŒÚ _positionalsÚ _optionalsÚ _subparsersrEr~rrjrKrÞrQ)r!rOrmr@rÚparentsr€rBr�rArCr‚rƒÚ superinitÚ add_grouprzÚdefault_prefixrYÚdefaults)rúr'r(rS<sB                   zArgumentParser.__init__cs/ddddddg}‡fdd†|DƒS) NrOrmr@r€rCr‚cs%g|]}|tˆ|ƒf‘qSr')r0)r[r%)r!r'r(r^…s z.ArgumentParser._get_kwargs..r')r!rór')r!r(r|s zArgumentParser._get_kwargsc KsA|jdk r"|jtdƒƒ|jdt|ƒƒd|ksPd|kr˜t|jddƒƒ}t|jddƒƒ}|j||ƒ|_n |j|_|jdƒdkr |j ƒ}|j ƒ}|j }|j |j ||dƒ|jƒjƒ|d<|j|dƒ}|d g|�}|jj|ƒ|S) Nz(cannot have multiple subparser argumentsrrfr@Ú subcommandsrOr_r?rŽ)r†ryrŒrrr«r^r„rªr Ú_get_positional_actionsrJrqrmrdr�rVrY) r!rrfr@rXr“roÚ parsers_classrxr'r'r(Úadd_subparsersŠs$    zArgumentParser.add_subparserscCs0|jr|jj|ƒn|jj|ƒ|S)N)rŽr…rYr„)r!rxr'r'r(rY©s zArgumentParser._add_actioncCsdd„|jDƒS)NcSsg|]}|jr|‘qSr')rŽ)r[rxr'r'r(r^±s z8ArgumentParser._get_optional_actions..)rG)r!r'r'r(Ú_get_optional_actions°s z$ArgumentParser._get_optional_actionscCsdd„|jDƒS)NcSsg|]}|js|‘qSr')rŽ)r[rxr'r'r(r^¶s z:ArgumentParser._get_positional_actions..)rG)r!r'r'r(r�µs z&ArgumentParser._get_positional_actionscCsH|j||ƒ\}}|rDtdƒ}|j|dj|ƒƒ|S)Nzunrecognized arguments: %sr„)rrŒryr )r!r]r2r~r r'r'r(Ú parse_args½s  zArgumentParser.parse_argsc Csk|dkr"tjdd…}n t|ƒ}|dkrCtƒ}xW|jD]L}|jtk rMt||jƒsM|jtk rMt ||j|jƒqMWx7|j D],}t||ƒs§t |||j |ƒq§WyX|j ||ƒ\}}t|t ƒr$|j t|t ƒƒt|t ƒ||fSWn5tk rftjƒd}|jt|ƒƒYnXdS)NrT)r r~rØr rGrårrÙr¶r1rKÚ_parse_known_argsrr‘r0ÚdelattrrÚexc_inforyrÊ)r!r]r2rxråÚerrr'r'r(rÄs,      zArgumentParser.parse_known_argscs.ˆ jdk rˆ jˆƒ‰i‰x~ˆ jD]s}|j}xat|jƒD]P\}}ˆj|gƒ}|j|d|…ƒ|j||dd…ƒqMWq.Wi‰g}tˆƒ} x•t| ƒD]‡\}} | dkr|jdƒx_| D]} |jdƒqöWqʈ j | ƒ} | dkr4d} n| ˆ|.take_actioncsˆ|}|\}}}ˆj}g}x¬|dkrPˆjˆ|ƒ|dS|dk ry||dƒ}ˆj}|dkr|d|kr|j|g|fƒ|d} | |d}|dd…pÑd} ˆj} || krü| |}| }qvtdƒ} t|| |ƒ‚qÓ|dkrW|d} |g}|j|||fƒPqÓtdƒ} t|| |ƒ‚q+|d}ˆ|d…}|||ƒ}||} ˆ|| …}|j|||fƒPq+W|sãt‚x'|D]\}}}ˆ|||ƒqêW| S)NrTr–rzignored explicit argument %r)Ú_match_argumentrrBrHrŒrrV)Ú start_indexÚ option_tuplerxr·Ú explicit_argÚmatch_argumentÚ action_tuplesÚ arg_countrZÚcharÚnew_explicit_argÚ optionals_mapr Ústopr]r³Úselected_patterns)r#Úarg_strings_patternÚextrasÚoption_string_indicesr!r r'r(Úconsume_optional+sP                  z:ArgumentParser._parse_known_args..consume_optionalcs—ˆj}ˆ|d…}|ˆ|ƒ}xHtˆ|ƒD]7\}}ˆ|||…}||7}ˆ||ƒq8Wˆt|ƒd…ˆdd…<|S)N)Ú_match_arguments_partialÚziprr)r¢Ú match_partialÚselected_patternÚ arg_countsrxr§r])r#r­r“r!r r'r(Úconsume_positionalsxs   z=ArgumentParser._parse_known_args..consume_positionalsrcs"g|]}|ˆkr|‘qSr'r')r[r¤)r¢r'r(r^–s z4ArgumentParser._parse_known_args..z(the following arguments are required: %sz, cSs+g|]!}|jtk rt|ƒ‘qSr')rtrrî)r[rxr'r'r(r^Ôs z#one of the arguments %s is requiredr„r¢)r�Ú_read_args_from_filesrJr¥r©rr‘ÚiterrÚ_parse_optionalr r£r�rBrArGr§rîr¶rÍrÊrÙrår0r1Ú _get_valueryrŒ)r!r#r2rir°rµÚ mutex_actionÚ conflictsÚarg_string_pattern_partsÚarg_strings_iterÚ arg_stringr£Úpatternr°r¶Úmax_option_string_indexÚnext_option_string_indexÚpositionals_end_indexÚstringsÚ stop_indexÚrequired_actionsrxr²rór r') r�r#r­r®r2r¯r“ržrŸr!r¢r r(r’çs˜ #         !!J                z ArgumentParser._parse_known_argscCsg}xú|D]ò}| s-|d|jkr=|j|ƒq yŠt|dd…ƒ�m}g}xA|jƒjƒD]-}x$|j|ƒD]}|j|ƒqˆWqrW|j|ƒ}|j|ƒWdQRXWq tk rþt j ƒd}|j t |ƒƒYq Xq W|S)NrrT) r�rr¹ÚreadrêÚconvert_arg_line_to_argsr·r‘r/r r”ryrÊ)r!r#Únew_arg_stringsr¿Ú args_fileÚarg_liner$r•r'r'r(r·Ýs   z$ArgumentParser._read_args_from_filescCs|gS)Nr')r!rËr'r'r(rÈ÷sz'ArgumentParser.convert_arg_line_to_argscCsª|j|ƒ}tj||ƒ}|dkr—dtdƒ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 argumentsrT) Ú_get_nargs_patternrJrcrŒr r rr®rªrrrr²)r!rxr­Ú nargs_patternrcÚ nargs_errorsr¶r r'r'r(r¡ús   zArgumentParser._match_argumentcsžg}x‘tt|ƒddƒD]w}|d|…}dj‡fdd†|Dƒƒ}tj||ƒ}|dk r|jdd„|jƒDƒƒPqW|S)NrrTr_csg|]}ˆj|ƒ‘qSr')rÌ)r[rx)r!r'r(r^s z;ArgumentParser._match_arguments_partial..cSsg|]}t|ƒ‘qSr')rr)r[r0r'r'r(r^s r¢)r¨rrr rJrcr‘ro)r!rnr­rÐrµÚ actions_slicerÀrcr')r!r(r±s   z'ArgumentParser._match_arguments_partialc Cs€|s dS|d|jkr!dS||jkrJ|j|}||dfSt|ƒdkr`dSd|kr­|jddƒ\}}||jkr­|j|}|||fS|jrD|j|ƒ}t|ƒdkr%djdd„|Dƒƒ}d|d|i}td ƒ}|j||ƒnt|ƒdkrD|\} | S|j j |ƒrc|j scdSd |krsdSd|dfS) NrrTú=z, cSsg|]\}}}|‘qSr'r')r[rxr·r¤r'r'r(r^?s z2ArgumentParser._parse_optional..rkÚmatchesz4ambiguous option: %(option)s could match %(matches)sr„) rBrHrrÚsplitrƒÚ_get_option_tuplesr rŒryrLrcrM) r!r¿rxr·r¤Ú option_tuplesÚoptionsr]r r£r'r'r(r¹s>           zArgumentParser._parse_optionalc CsŸg}|j}|d|kr±|d|kr±d|krV|jddƒ\}}n |}d}x6|jD]>}|j|ƒrl|j|}|||f}|j|ƒqlWnê|d|kr„|d|kr„|}d}|dd…}|dd…} x›|jD]v}||krE|j|}||| f}|j|ƒq|j|ƒr|j|}|||f}|j|ƒqWn|jtdƒ|ƒ|S)NrrTrÐr4zunexpected option string: %s)rBrÒrHÚ startswithrryrŒ) r!r·rÐrZÚ option_prefixr¤rxrÄÚshort_option_prefixÚshort_explicit_argr'r'r(rÓZs8        z!ArgumentParser._get_option_tuplescCsÏ|j}|dkrd}n€|tkr3d}nk|tkrHd}nV|tkr]d}nA|tkrrd}n,|tkr‡d}nddjd |ƒ}|jrË|jdd ƒ}|jd d ƒ}|S) Nz(-*A-*)z(-*A?-*)z (-*[A-]*)z (-*A[A-]*)z([-AO]*)z (-*A[-AO]*)z(-*%s-*)z-*r–r_r,) r®r rr rrr rŽrm)r!rxr®rÍr'r'r(r̆s$              z!ArgumentParser._get_nargs_patternc sýˆjttgkr;y|jdƒWntk r:YnX| r£ˆjtkr£ˆjrfˆj}n ˆj}t |t ƒrùˆj ˆ|ƒ}ˆj ˆ|ƒnV| r÷ˆjt kr÷ˆj r÷ˆjdk rÞˆj}n|}ˆj ˆ|ƒnt|ƒdkrLˆjdtgkrL|\}ˆj ˆ|ƒ}ˆj ˆ|ƒn­ˆjtkrz‡‡fdd†|Dƒ}nˆjtkr¼‡‡fdd†|Dƒ}ˆj ˆ|dƒn=‡‡fdd†|Dƒ}x|D]}ˆj ˆ|ƒqßW|S)Nz--rTcs"g|]}ˆjˆ|ƒ‘qSr')rº)r[Úv)rxr!r'r(r^Ös z.ArgumentParser._get_values..cs"g|]}ˆjˆ|ƒ‘qSr')rº)r[rÚ)rxr!r'r(r^Ús rcs"g|]}ˆjˆ|ƒ‘qSr')rº)r[rÚ)rxr!r'r(r^ßs )r®rrrdr=r rŽròr¶rÍrÊrºÚ _check_valuerrr)r!rxr#r&r¿rÚr')rxr!r(r˜²s>      '  zArgumentParser._get_valuesc Cs|jd|j|jƒ}t|ƒsFtdƒ}t|||ƒ‚y||ƒ}Wn»tk r­t|jdt|jƒƒ}tt j ƒdƒ}t||ƒ‚Yngt t fk rt|jdt|jƒƒ}d|d|i}tdƒ}t|||ƒ‚YnX|S)Nrz%r is not callablerrTr&z!invalid %(type)s value: %(value)r) rPrrWrŒrrr0rrÊr r”rXr=)r!rxr¿r\r rÐr%r]r'r'r(rºæs     zArgumentParser._get_valuecCsh|jdk rd||jkrdd|ddjtt|jƒƒi}tdƒ}t|||ƒ‚dS)Nr&rÑz, z3invalid choice: %(value)r (choose from %(choices)s))rÑr ÚmaprrŒr)r!rxr&r]r r'r'r(rÛ s ! zArgumentParser._check_valuecCs2|jƒ}|j|j|j|jƒ|jƒS)N)r rqrmrGrJrd)r!rXr'r'r(Ú format_usage s  zArgumentParser.format_usagecCs |jƒ}|j|j|j|jƒ|j|jƒxK|jD]@}|j|j ƒ|j|jƒ|j |j ƒ|j ƒqBW|j|j ƒ|jƒS)N)r rqrmrGrJrkr@rIrgrfrr¥rhrrd)r!rXÚ action_groupr'r'r(rd s  zArgumentParser.format_helpcCs|jd|jƒS)NrO)r€rO)r!r'r'r(r ( szArgumentParser._get_formattercCs/|dkrtj}|j|jƒ|ƒdS)N)r r r rÝ)r!Úfiler'r'r(Ú print_usage. s  zArgumentParser.print_usagecCs/|dkrtj}|j|jƒ|ƒdS)N)r r r rd)r!rßr'r'r(r3 s  zArgumentParser.print_helpcCs,|r(|dkrtj}|j|ƒdS)N)r ÚstderrÚwrite)r!rðrßr'r'r(r 8 s  zArgumentParser._print_messagercCs*|r|j|tjƒtj|ƒdS)N)r r rár)r!Ústatusrðr'r'r(rA szArgumentParser.exitcCsC|jtjƒd|jd|i}|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. rOrðr4z%(prog)s: error: %(message)s N)ràr rárOrrŒ)r!rðr]r'r'r(ryF s zArgumentParser.error) rr-r.r/rrSrr�rYr�r�r‘rr’r·rÈr¡r±r¹rÓrÌr˜rºrÛrÝrdr ràrr rryr'r')rúr(r)sN 4     # ö     ; , , 4     )6r/Ú __version__Ú__all__Ú collectionsrrrÿÚosr:ÚrerJÚsysr ÚtextwrapràrrŒrrr rr rrrrçrr3rrrrr rîÚ Exceptionrrr rørûrürýrþrrrrr rr r8r]r_rr'r'r'r(Ú>sz        ÿê    [#%`6ÿ4"