
    Rhv                       d Z dZg dZddlZddlZddlZddl	Z		 ddl
m
ZmZ dZd	Zd
ZdZdZdZdZ G d de      Zd Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zd Z G d de      Z G d d e      Z  G d! d"e      Z! e       Z" G d# d$e!      Z# G d% d&e!      Z$ G d' d(e!      Z% G d) d*e%      Z& G d+ d,e%      Z' G d- d.e!      Z( G d/ d0e!      Z) G d1 d2e!      Z* G d3 d4e!      Z+ G d5 d6e!      Z, G d7 d8e!      Z- G d9 d:e(      Z. G d; d<e      Z/ G d= d>e      Z0 G d? d@e      Z1 G dA dBe1      Z2 G dC dDe2      Z3 G dE dFee1      Z4y# e$ r
 d Zd ZY Tw xY w)Ga
  Command-line parsing library

This module is an optparse-inspired command-line parsing library that:

    - handles both optional and positional arguments
    - produces highly informative usage messages
    - supports parsers that dispatch to sub-parsers

The following is a simple usage example that sums integers from the
command-line and writes the result to a file::

    parser = argparse.ArgumentParser(
        description='sum the integers at the command line')
    parser.add_argument(
        'integers', metavar='int', nargs='+', type=int,
        help='an integer to be summed')
    parser.add_argument(
        '--log', default=sys.stdout, type=argparse.FileType('w'),
        help='the file where the sum should be written')
    args = parser.parse_args()
    args.log.write('%s' % sum(args.integers))
    args.log.close()

The module contains the following public classes:

    - ArgumentParser -- The main entry point for command-line parsing. As the
        example above shows, the add_argument() method is used to populate
        the parser with actions for optional and positional arguments. Then
        the parse_args() method is invoked to convert the args at the
        command-line into an object with attributes.

    - ArgumentError -- The exception raised by ArgumentParser objects when
        there are errors with the parser's actions. Errors raised while
        parsing the command-line are caught by ArgumentParser and emitted
        as command-line messages.

    - FileType -- A factory for defining types of files to be created. As the
        example above shows, instances of FileType are typically passed as
        the type= argument of add_argument() calls.

    - Action -- The base class for parser actions. Typically actions are
        selected by passing strings like 'store_true' or 'append_const' to
        the action= argument of add_argument(). However, for greater
        customization of ArgumentParser actions, subclasses of Action may
        be defined and passed as the action= argument.

    - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
        ArgumentDefaultsHelpFormatter -- Formatter classes which
        may be passed as the formatter_class= argument to the
        ArgumentParser constructor. HelpFormatter is the default,
        RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
        not to change the formatting for help text, and
        ArgumentDefaultsHelpFormatter adds information about argument defaults
        to the help.

All other classes in this module are considered implementation details.
(Also note that HelpFormatter and RawDescriptionHelpFormatter are only
considered public as object names -- the API of the formatter objects is
still considered an implementation detail.)
z1.1)ArgumentParserArgumentErrorArgumentTypeErrorBooleanOptionalActionFileTypeHelpFormatterArgumentDefaultsHelpFormatterRawDescriptionHelpFormatterRawTextHelpFormatterMetavarTypeHelpFormatter	NamespaceActionONE_OR_MOREOPTIONALPARSER	REMAINDERSUPPRESSZERO_OR_MORE    N)gettextngettextc                     | S N )messages    /usr/lib/python3.12/argparse.py_r   a   s        c                     |dk(  r| S |S N   r   )singularpluralns      r   r   r   c   s    6OMr   z==SUPPRESS==?*+zA......_unrecognized_argsc                   "    e Zd ZdZd Zd Zd Zy)_AttributeHoldera  Abstract 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__.
    c                    t        |       j                  }g }i }| j                         D ]  }|j                  t	        |              | j                         D ]1  \  }}|j                         r|j                  |d|       -|||<   3 |r|j                  dt	        |      z         |ddj                  |      dS )N=z**%s(, ))type__name__	_get_argsappendrepr_get_kwargsisidentifierjoin)self	type_namearg_strings	star_argsargnamevalues          r   __repr__z_AttributeHolder.__repr__   s    J''		>># 	*CtCy)	*++- 	(KD%  """dE#:;"'	$		(
 vY78$dii&<==r   c                 H    t        | j                  j                               S r   )list__dict__itemsr8   s    r   r5   z_AttributeHolder._get_kwargs   s    DMM'')**r   c                     g S r   r   rD   s    r   r2   z_AttributeHolder._get_args   s    	r   N)r1   
__module____qualname____doc__r?   r5   r2   r   r   r   r*   r*   v   s    >+r   r*   c                 `    | g S t        |       t        u r| d d  S dd l}|j                  |       S Nr   )r0   rA   copy)rC   rK   s     r   _copy_itemsrL      s5    }	 E{dQx99Ur   c                       e Zd ZdZ	 	 	 ddZd Zd Z G d de      Zd Z	d	 Z
d
 Zd Zd dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)!r   zFormatter for generating usage messages and argument help strings.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    Nc                    |$	 dd l }|j                         j                  }|dz  }|| _        || _        t        |t        |dz
  |dz              | _        || _	        d| _
        d| _        d| _        | j                  | d       | _        | j                  | _        t!        j"                  dt         j$                        | _        t!        j"                  d      | _        y # t        $ r d}Y w xY w)Nr      F      z\s+z\n\n\n+)shutilget_terminal_sizecolumnsImportError_prog_indent_incrementminmax_max_help_position_width_current_indent_level_action_max_length_Section_root_section_current_section_recompileASCII_whitespace_matcher_long_break_matcher)r8   progindent_incrementmax_help_positionwidth_shutils         r   __init__zHelpFormatter.__init__   s     =(113;;
 
!1"%&7&)%"*6F6J&K#M "#!]]46 $ 2 2#&;;vsyy#A #&;;z#: #  s   #C C,+C,c                 l    | xj                   | j                  z  c_         | xj                  dz  c_        y r   r\   rW   r]   rD   s    r   _indentzHelpFormatter._indent   s'     6 66qr   c                     | xj                   | j                  z  c_         | j                   dk\  sJ d       | xj                  dz  c_        y )Nr   zIndent decreased below 0.r    rn   rD   s    r   _dedentzHelpFormatter._dedent   sA     6 66##q(E*EE(qr   c                       e Zd ZddZd Zy)HelpFormatter._SectionNc                 <    || _         || _        || _        g | _        y r   )	formatterparentheadingrC   )r8   ru   rv   rw   s       r   rl   zHelpFormatter._Section.__init__   s    &DN DK"DLDJr   c           	         | j                   | j                  j                          | j                  j                  } || j                  D cg c]
  \  }} ||  c}}      }| j                   | j                  j                          |sy| j                  t        urM| j                  A| j                  j                  }t        d      t        | j                        z  }d|d|fz  }nd} |d||dg      S c c}}w )N z%(heading)s:)rw   %*s%s

)rv   ru   ro   _join_partsrC   rq   rw   r   r\   r   dict)r8   r7   funcargs	item_helpcurrent_indentheading_textrw   s           r   format_helpz"HelpFormatter._Section.format_help   s    {{&&&(>>--DDJJGjdDdDkGHI{{&&&(  ||8+0H!%!?!? 043MM#~r<&HH w	4899# Hs   C;
r   )r1   rF   rG   rl   r   r   r   r   r_   rs      s    		:r   r_   c                 R    | j                   j                  j                  ||f       y r   )ra   rC   r3   )r8   r~   r   s      r   	_add_itemzHelpFormatter._add_item   s     ##**D$<8r   c                     | j                          | j                  | | j                  |      }| j                  |j                  g        || _        y r   )ro   r_   ra   r   r   )r8   rw   sections      r   start_sectionzHelpFormatter.start_section   s?    --d&;&;WEw**B/ 'r   c                 Z    | j                   j                  | _         | j                          y r   )ra   rv   rq   rD   s    r   end_sectionzHelpFormatter.end_section  s     $ 5 5 < <r   c                 V    |t         ur!|| j                  | j                  |g       y y y r   )r   r   _format_text)r8   texts     r   add_textzHelpFormatter.add_text  s-    xD$4NN4,,tf5 %5r   c                 Z    |t         ur#||||f}| j                  | j                  |       y y r   )r   r   _format_usage)r8   usageactionsgroupsprefixr   s         r   	add_usagezHelpFormatter.add_usage  s1     '661DNN4--t4 !r   c                 n   |j                   t        ur| j                  } ||      g}| j                  |      D ]  }|j	                   ||              t        t        t        |            }|| j                  z   }t        | j                  |      | _	        | j                  | j                  |g       y y r   )helpr   _format_action_invocation_iter_indented_subactionsr3   rY   maplenr\   r^   r   _format_action)r8   actionget_invocationinvocations	subactioninvocation_lengthaction_lengths          r   add_argumentzHelpFormatter.add_argument  s    ;;h& ";;N)&12K!;;FC >	"">)#<=> !$C[$9 :-0D0DDM&)$*A*A*7'9D# NN4..9 'r   c                 4    |D ]  }| j                  |        y r   )r   )r8   r   r   s      r   add_argumentszHelpFormatter.add_arguments#  s     	&Ff%	&r   c                     | j                   j                         }|r0| j                  j                  d|      }|j	                  d      dz   }|S )N

r{   )r`   r   rf   substrip)r8   r   s     r   r   zHelpFormatter.format_help*  sI    !!--/++//=D::d#d*Dr   c                 ^    dj                  |D cg c]  }|r
|t        ur| c}      S c c}w )Nry   )r7   r   )r8   part_stringsparts      r   r|   zHelpFormatter._join_parts1  s8    ww$0: D$8  : ; 	; :s   *c                    |t        d      }||t        | j                        z  }nB||sdt        | j                        z  }n#| dt        | j                        z  }g }g }|D ]1  }|j                  r|j	                  |       !|j	                  |       3 | j
                  }	 |	||z   |      }
dj                  ||
fD cg c]  }|s|	 c}      }| j                  | j                  z
  t        |      t        |      z   kD  r]d} |	||      } |	||      }t        j                  ||      }t        j                  ||      }dj                  |      |k(  sJ dj                  |      |k(  sJ dfd	}t        |      t        |      z   dz  k  r[dt        |      t        |      z   dz   z  }|r' ||g|z   ||      }|j                   |||             nw|r ||g|z   ||      }nf|g}nbdt        |      z  }||z   } |||      }t        |      dkD  r2g }|j                   |||             |j                   |||             |g|z   }d	j                  |      }||d
S c c}w )Nzusage: rg   z%(prog)s z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+c                    g }g }t        |      }|t        |      dz
  }n|dz
  }| D ]d  }|dz   t        |      z   kD  r,|r*|j                  |dj                  |      z          g }|dz
  }|j                  |       |t        |      dz   z  }f |r#|j                  |dj                  |      z          ||d   |d  |d<   |S )Nr    r   r   )r   r3   r7   )	partsindentr   lineslineindent_lengthline_lenr   
text_widths	           r   	get_linesz.HelpFormatter._format_usage.<locals>.get_linesf  s    ED$'KM)#&v;?#01#4 % 2#a<#d)3j@T!LL#((4.)@A#%D'4q'8HD) CIM12 Vchhtn%<=)#(8MN#;a Lr   g      ?r    r{   r   r   )r   r}   rV   option_stringsr3   _format_actions_usager7   r[   r\   r   rb   findallextend)r8   r   r   r   r   rg   	optionalspositionalsr   formataction_usagespart_regexp	opt_usage	pos_usage	opt_parts	pos_partsr   r   r   r   r   s                        @r   r   zHelpFormatter._format_usage6  s   >y\F Ddjj11E ]74::!66E ]$** 55D IK! /(($$V,&&v.	/ //F!)k"96BLHH$)=CAaCDE t';';;J6{SZ'*4 
 #9f5	";7	KKY?	KKY?	xx	*i777xx	*i777!, v;T*dZ.?? CK#d)$;a$?@F  )4&9*<ff MYy&%AB" )4&9*<ff M!% !3v;.F%	1E%eV4E5zA~ "Yy&%ABYy&%AB!FUNE 		%( $U++G Ds   
I5I5c                    t               }i }|D ]4  }|j                  st        d|       	 |j                  |j                  d         }t	        |j                        }||z   }||| |j                  k(  sjd}	|j                  D ]+  }
|j                  |
       |
j                  t        u s'|	dz  }	- ||	z
  }|s|j                  s/||v r||xx   dz  cc<   nd||<   ||v r||xx   dz  cc<   n9d||<   n3|dkD  r.||v r||xx   dz  cc<   nd||<   ||v r||xx   d	z  cc<   nd	||<   t        |dz   |      D ]  }d
||<   	 7 g }t        |      D ]U  \  }}
|
j                  t        u rd|j                  d        |j                  |      d
k(  r|j                  |       P|j                  |dz         d
k(  sh|j                  |dz          }|
j                  sN| j                  |
      }| j!                  |
|      }|
|v r|d   dk(  r|d   dk(  r|dd }|j                  |       |
j                  d   }|
j"                  dk(  r|
j%                         }n*| j'                  |
      }| j!                  |
|      }|d|}|
j                  s	|
|vrd|z  }|j                  |       X t)        |d      D ]  }||   g|||  dj+                  |D cg c]  }||	 c}      }d}d}t-        j.                  d|z  d|      }t-        j.                  d|z  d|      }t-        j.                  |d|d|      }|j1                         }|S # t        $ r Y Mw xY wc c}w )Nzempty group r   r    z [[]z (r-   r/   |r   [%s]T)reversez[\[(]z[\])]z(%s) z\1 (%s)z *ry   )set_group_actions
ValueErrorindexr   addr   r   requiredrange	enumerater3   getpopr   #_get_default_metavar_for_positional_format_argsnargsformat_usage!_get_default_metavar_for_optionalsortedr7   rb   r   r   )r8   r   r   group_actionsinsertsgroupstartgroup_action_countendsuppressed_actions_countr   exposed_actions_countir   defaultr   option_stringargs_stringitemr   opencloses                         r   r   z#HelpFormatter._format_actions_usage  s    *	)E'' <w!788&)e&:&:1&=> &))=)=%>"005%)=)==/0,"'"6"6 :%))&1!;;(2494:
 -?AY,Y)0  >> G+#ENd2N-0GEN'>#CLC/L+.GCL.2 G+#ENd2N-0GEN'>#CLC/L+.GCL"519c2 )%(
)S*	)Z "7+ -	#IAv {{h&T";;q>S(KKN[[Q'3.KKA& **BB6J((9 ]*Aw#~$r(c/#Abz T" !' 5 5a 8 <<1$!..0D
 #DDVLG"&"3"3FG"DK&3[AD 6+F!D=D T"[-	#` . 	&A!!*E!AJ	& xx%D$43CDE wwx$t4wwx%'5wwD%0#t<zz| O  x Es   MM M 	MMc                     d|v r|t        | j                        z  }t        | j                  | j                  z
  d      }d| j                  z  }| j                  |||      dz   S )Nz%(prog)r      r   r   )r}   rV   rY   r[   r\   
_fill_text)r8   r   r   r   s       r   r   zHelpFormatter._format_text
  s`    $DJJ//Dt';';;R@
t+++tZ86AAr   c                 `   t        | j                  dz   | j                        }t        | j                  |z
  d      }|| j
                  z
  dz
  }| j                  |      }|j                  s| j
                  d|f}d|z  }n<t        |      |k  r| j
                  d||f}d|z  }d}n| j
                  d|f}d|z  }|}|g}|j                  r{|j                  j                         ra| j                  |      }	|	rp| j                  |	|      }
|j                  dd|
d   fz         |
dd  D ]  }|j                  d|d|fz          n"|j                  d      s|j                  d       | j                  |      D ]"  }|j                  | j                  |             $ | j!                  |      S )	NrO   r   ry   rz   z	%*s%-*s  r   r    r{   )rX   r^   rZ   rY   r[   r\   r   r   r   r   _expand_help_split_linesr3   endswithr   r   r|   )r8   r   help_position
help_widthaction_widthaction_headertupindent_firstr   	help_text
help_linesr   r   s                r   r   zHelpFormatter._format_action  s   D33a7 335}4b9
$t';';;a?66v> {{&&M9C%OM </&&L-GC'#-ML &&M9C%OM(L  ;;6;;,,.))&1I!..y*E
Y,JqM)JJK&qrN HDLLmR-F!FGH ''-LL 77? 	9ILL,,Y78	9 &&r   c                    |j                   s-| j                  |      } | j                  ||      d      \  }|S g }|j                  dk(  r|j	                  |j                          nJ| j                  |      }| j                  ||      }|j                   D ]  }|j                  |d|        dj                  |      S )Nr    r   r   r.   )	r   r   _metavar_formatterr   r   r   r   r3   r7   )r8   r   r   metavarr   r   r   s          r   r   z'HelpFormatter._format_action_invocationA  s    $$>>vFG?t..vw?BHGN E ||q V223
 @@H"//@%+%:%: IMLLM;!GHI 99U##r   c                     |j                   |j                   nE|j                  7|j                  D cg c]  }t        |       }}ddj                  |      z  n|fd}|S c c}w )Nz{%s},c                 4    t        t              rS f| z  S r   )
isinstancetuple)
tuple_sizeresults    r   r   z0HelpFormatter._metavar_formatter.<locals>.formatb  s    &%(zJ..r   )r   choicesstrr7   )r8   r   default_metavarchoicechoice_strsr   r  s         @r   r   z HelpFormatter._metavar_formatterY  se    >>%^^F^^'5;^^D63v;DKDchh{33F$F	/
  Es   A'c                    | j                  ||      }|j                  d |d      z  }|S |j                  t        k(  rd |d      z  }|S |j                  t        k(  r$ |d      }t	        |      dk(  rd|z  }|S d|z  }|S |j                  t
        k(  rd |d      z  }|S |j                  t        k(  rd}|S |j                  t        k(  rd	 |d      z  }|S |j                  t        k(  rd
}|S 	 t        |j                        D cg c]  }d }}dj                  |       ||j                        z  }|S c c}w # t        $ r t        d      d w xY w)Nz%sr    r   rO   z[%s [%s ...]]z[%s ...]z%s [%s ...]r'   z%s ...ry   zinvalid nargs valuer   )r   r   r   r   r   r   r   r   r   r   	TypeErrorr   r7   )r8   r   r	  get_metavarr  r   r   formatss           r   r   zHelpFormatter._format_argsi  s   --foF<<KN*F. - \\X%k!n,F* ) \\\)!!nG7|q (72"  $g-  \\[("[^3F  \\Y&F  \\V#A.F  \\X%F B).v||)<=A4== XXg&V\\)BBF	 > B !67TABs   2D? 		D:D? :D? ?Ec                    t        t        |      | j                        }t        |      D ]  }||   t        u s||=  t        |      D ]$  }t        ||   d      s||   j                  ||<   & |j                  d      0dj                  |d   D cg c]  }t        |       c}      }||d<   | j                  |      |z  S c c}w )Nr   r1   r  r.   )r}   varsrV   rA   r   hasattrr1   r   r7   r  _get_help_string)r8   r   paramsr=   cchoices_strs         r   r   zHelpFormatter._expand_help  s    d6l4L 	!Dd|x'4L	! L 	5Dvd|Z0%d|44t	5 ::i ,))VI5F$GSV$GHK +F9$$V,v55 %Hs   Cc              #      K   	 |j                   }| j                           |       E d {    | j                          y 7 # t        $ r Y y w xY wwr   )_get_subactionsro   rq   AttributeError)r8   r   get_subactionss      r   r   z'HelpFormatter._iter_indented_subactions  sN     	#33N LLN%'''LLN (	  		s1   AA AA A	AAAAc                     | j                   j                  d|      j                         }dd l}|j	                  ||      S )Nr   r   )re   r   r   textwrapwrap)r8   r   rj   r  s       r   r   zHelpFormatter._split_lines  s9    ''++C6<<> 	}}T5))r   c                     | j                   j                  d|      j                         }dd l}|j	                  ||||      S )Nr   r   )initial_indentsubsequent_indent)re   r   r   r  fill)r8   r   rj   r   r  s        r   r   zHelpFormatter._fill_text  sF    ''++C6<<>}}T5,2/5  7 	7r   c                     |j                   S r   )r   r8   r   s     r   r  zHelpFormatter._get_help_string      {{r   c                 6    |j                   j                         S r   )destupperr#  s     r   r   z/HelpFormatter._get_default_metavar_for_optional  s    {{  ""r   c                     |j                   S r   )r&  r#  s     r   r   z1HelpFormatter._get_default_metavar_for_positional  r$  r   )rO      Nr   ) r1   rF   rG   rH   rl   ro   rq   objectr_   r   r   r   r   r   r   r   r   r|   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r      s     #$#%	;D
:6 :@9(65
:$&;
_,BqfB.'`$0 86*7#r   r   c                       e Zd ZdZd Zy)r	   zHelp message formatter which retains any formatting in descriptions.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    c                 X    dj                  fd|j                  d      D              S )Nry   c              3   (   K   | ]	  }|z     y wr   r   ).0r   r   s     r   	<genexpr>z9RawDescriptionHelpFormatter._fill_text.<locals>.<genexpr>  s     Pv}Ps   T)keepends)r7   
splitlines)r8   r   rj   r   s      `r   r   z&RawDescriptionHelpFormatter._fill_text  s#    wwP$1OPPPr   N)r1   rF   rG   rH   r   r   r   r   r	   r	     s    Qr   r	   c                       e Zd ZdZd Zy)r
   zHelp message formatter which retains formatting of all help text.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    c                 "    |j                         S r   )r1  )r8   r   rj   s      r   r   z!RawTextHelpFormatter._split_lines  s      r   N)r1   rF   rG   rH   r   r   r   r   r
   r
     s    !r   r
   c                       e Zd ZdZd Zy)r   zHelp message formatter which adds default values to argument help.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    c                     |j                   }|d}d|vrF|j                  t        ur4t        t        g}|j
                  s|j                  |v r|t        d      z  }|S )a6  
        Add the default value to the option help message.

        ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't
        already present. This code will do that, detecting cornercases to
        prevent duplicates or cases where it wouldn't make sense to the end
        user.
        ry   z
%(default)z (default: %(default)s))r   r   r   r   r   r   r   r   )r8   r   r   defaulting_nargss       r   r  z.ArgumentDefaultsHelpFormatter._get_help_string  s`     {{<Dt#~~X-$,l#; ((FLL<L,LA788Dr   N)r1   rF   rG   rH   r  r   r   r   r   r     s    r   r   c                       e Zd ZdZd Zd Zy)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.
    c                 .    |j                   j                  S r   r0   r1   r#  s     r   r   z:MetavarTypeHelpFormatter._get_default_metavar_for_optional      {{###r   c                 .    |j                   j                  S r   r9  r#  s     r   r   z<MetavarTypeHelpFormatter._get_default_metavar_for_positional  r:  r   N)r1   rF   rG   rH   r   r   r   r   r   r   r     s    $$r   r   c                 2   | y | j                   rdj                  | j                         S | j                  d t        fvr| j                  S | j                  d t        fvr| j                  S | j
                  r!ddj                  | j
                        z   dz   S y )N/{r  })r   r7   r   r   r&  r  )arguments    r   _get_action_namerA    s    		 	 xx//00			$!1	1	tX.	.}}			SXXh..//#55r   c                       e Zd ZdZd Zd Zy)r   zAn error from creating or using an argument (optional or positional).

    The string value of this exception is the message, augmented with
    information about the argument that caused it.
    c                 2    t        |      | _        || _        y r   )rA  argument_namer   )r8   r@  r   s      r   rl   zArgumentError.__init__  s    -h7r   c                 ~    | j                   d}nt        d      }|t        | j                  | j                         z  S )Nz%(message)sz'argument %(argument_name)s: %(message)s)r   rD  )rD  r   r}   r   )r8   r   s     r   __str__zArgumentError.__str__  sA    %"F@AFT\\+/+=+=? ? 	?r   N)r1   rF   rG   rH   rl   rF  r   r   r   r   r   	  s    ?r   r   c                       e Zd ZdZy)r   z@An error from trying to convert a command line string to a type.N)r1   rF   rG   rH   r   r   r   r   r     s    Jr   r   c                   <    e Zd ZdZ	 	 	 	 	 	 	 	 ddZd Zd ZddZy)	r   a\	  Information about how to convert command line strings to Python objects.

    Action objects are used by an ArgumentParser to represent the information
    needed to parse a single argument from one or more strings from the
    command line. The keyword arguments to the Action constructor are also
    all attributes of Action instances.

    Keyword Arguments:

        - option_strings -- A list of command-line option strings which
            should be associated with this action.

        - dest -- The name of the attribute to hold the created object(s)

        - nargs -- The number of command-line arguments that should be
            consumed. By default, one argument will be consumed and a single
            value will be produced.  Other values include:
                - N (an integer) consumes N arguments (and produces a list)
                - '?' consumes zero or one arguments
                - '*' consumes zero or more arguments (and produces a list)
                - '+' consumes one or more arguments (and produces a list)
            Note that the difference between the default and nargs=1 is that
            with the default, a single value will be produced, while with
            nargs=1, a list containing a single value will be produced.

        - const -- The value to be produced if the option is specified and the
            option uses an action that takes no values.

        - default -- The value to be produced if the option is not specified.

        - type -- A callable that accepts a single string argument, and
            returns the converted value.  The standard Python types str, int,
            float, and complex are useful examples of such callables.  If None,
            str is used.

        - choices -- A container of values that should be allowed. If not None,
            after a command-line argument has been converted to the appropriate
            type, an exception will be raised if it is not a member of this
            collection.

        - required -- True if the action must always be specified at the
            command line. This is only meaningful for optional command-line
            arguments.

        - help -- The help string describing the argument.

        - metavar -- The name to be used for the option's argument with the
            help string. If None, the 'dest' value will be used as the name.
    Nc                     || _         || _        || _        || _        || _        || _        || _        || _        |	| _        |
| _	        y r   
r   r&  r   constr   r0   r  r   r   r   )r8   r   r&  r   rK  r   r0   r  r   r   r   s              r   rl   zAction.__init__Y  sK     -	

	 	r   c                 L    g d}|D cg c]  }|t        | |      f c}S c c}w )NrJ  getattrr8   namesr=   s      r   r5   zAction._get_kwargso  s+    
 9>>wtT*+>>>   !c                      | j                   d   S rJ   )r   rD   s    r   r   zAction.format_usage~  s    ""1%%r   c                 *    t        t        d            )Nz.__call__() not defined)NotImplementedErrorr   r8   parser	namespacevaluesr   s        r   __call__zAction.__call__  s    !!$=">??r   NNNNNFNNr   )r1   rF   rG   rH   rl   r5   r   rY  r   r   r   r   r   &  s7    0j ,?&@r   r   c                   :     e Zd Zdeeddef fd	ZddZd Z xZS )r   NFc	                 b   g }	|D ]>  }
|	j                  |
       |
j                  d      s&d|
dd  z   }
|	j                  |
       @ dD ].  }t               |   t        ust	        j
                  |dd       0 |t        u rd }|t        u rd }|t        u rd }t        |   |	|d||||||		       y )
N----no-rO   )r0   r  r   zP{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.)      )remover   )	r   r&  r   r   r0   r  r   r   r   )r3   
startswithlocals_deprecated_defaultwarnings_deprecatedsuperrl   )r8   r   r&  r   r0   r  r   r   r   _option_stringsr   
field_name	__class__s               r   rl   zBooleanOptionalAction.__init__  s     + 	6M""=1''- '-*; ;&&}5	6 9 	$Jx
#+>>$$2"	$	$ &&D))G))G* 	 		r   c                 p    || j                   v r(t        || j                  |j                  d              y y )Nr^  )r   setattrr&  rb  rU  s        r   rY  zBooleanOptionalAction.__call__  s3    D///Ityym.F.Fw.O*OP 0r   c                 8    dj                  | j                        S )Nz | )r7   r   rD   s    r   r   z"BooleanOptionalAction.format_usage  s    zz$--..r   r   )r1   rF   rG   rd  rl   rY  r   __classcell__rj  s   @r   r   r     s(     ),,-`Q/r   r   c                   8     e Zd Z	 	 	 	 	 	 	 	 d fd	ZddZ xZS )_StoreActionc                     |dk(  rt        d      ||t        k7  rt        dt        z        t        t        |   |||||||||	|

       y )Nr   znargs for store actions must be != 0; if you have nothing to store, actions such as store true or store const may be more appropriate nargs must be %r to supply constrJ  )r   r   rg  rq  rl   r8   r   r&  r   rK  r   r0   r  r   r   r   rj  s              r   rl   z_StoreAction.__init__  ss     A: K L L (!2?(JKKlD*) 	+ 
	r   c                 2    t        || j                  |       y r   )rl  r&  rU  s        r   rY  z_StoreAction.__call__  s    	499f-r   rZ  r   r1   rF   rG   rl   rY  rn  ro  s   @r   rq  rq    s'    
 :.r   rq  c                   2     e Zd Z	 	 	 	 	 d fd	ZddZ xZS )_StoreConstActionc           	      :    t         t        |   ||d||||       y )Nr   )r   r&  r   rK  r   r   r   )rg  rx  rl   	r8   r   r&  rK  r   r   r   r   rj  s	           r   rl   z_StoreConstAction.__init__  s/     	/) 	0 	r   c                 F    t        || j                  | j                         y r   )rl  r&  rK  rU  s        r   rY  z_StoreConstAction.__call__  s    	499djj1r   NNFNNr   rv  ro  s   @r   rx  rx    s    
 "2r   rx  c                   &     e Zd Z	 	 	 d fd	Z xZS )_StoreTrueActionc                 8    t         t        |   ||d|||       y )NTr   r&  rK  r   r   r   )rg  r~  rl   r8   r   r&  r   r   r   rj  s         r   rl   z_StoreTrueAction.__init__  s,     	.) 	/ 	r   )FFNr1   rF   rG   rl   rn  ro  s   @r   r~  r~    s    
  r   r~  c                   &     e Zd Z	 	 	 d fd	Z xZS )_StoreFalseActionc                 8    t         t        |   ||d|||       y )NFr  )rg  r  rl   r  s         r   rl   z_StoreFalseAction.__init__  s,     	/) 	0 	r   )TFNr  ro  s   @r   r  r    s    
  r   r  c                   8     e Zd Z	 	 	 	 	 	 	 	 d fd	ZddZ xZS )_AppendActionc                     |dk(  rt        d      ||t        k7  rt        dt        z        t        t        |   |||||||||	|

       y )Nr   znargs for append actions must be != 0; if arg strings are not supplying the value to append, the append const action may be more appropriaters  rJ  )r   r   rg  r  rl   rt  s              r   rl   z_AppendAction.__init__  ss     A: O P P (!2?(JKKmT+) 	, 
	r   c                     t        || j                  d       }t        |      }|j                  |       t	        || j                  |       y r   )rN  r&  rL   r3   rl  r8   rV  rW  rX  r   rC   s         r   rY  z_AppendAction.__call__<  :    	499d3E"V	499e,r   rZ  r   rv  ro  s   @r   r  r    s'    
 :-r   r  c                   2     e Zd Z	 	 	 	 	 d fd	ZddZ xZS )_AppendConstActionc           
      <    t         t        |   ||d|||||       y )Nr   )r   r&  r   rK  r   r   r   r   )rg  r  rl   rz  s	           r   rl   z_AppendConstAction.__init__E  s2     	 $0) 	1 	r   c                     t        || j                  d       }t        |      }|j                  | j                         t        || j                  |       y r   )rN  r&  rL   r3   rK  rl  r  s         r   rY  z_AppendConstAction.__call__W  s>    	499d3E"TZZ 	499e,r   r|  r   rv  ro  s   @r   r  r  C  s    
 $-r   r  c                   .     e Zd Z	 	 	 d fd	ZddZ xZS )_CountActionc                 8    t         t        |   ||d|||       y )Nr   )r   r&  r   r   r   r   )rg  r  rl   r  s         r   rl   z_CountAction.__init__`  s+     	lD*) 	+ 	r   c                 n    t        || j                  d       }|d}t        || j                  |dz          y )Nr   r    )rN  r&  rl  )r8   rV  rW  rX  r   counts         r   rY  z_CountAction.__call__n  s2    	499d3=E	499eai0r   )NFNr   rv  ro  s   @r   r  r  ^  s    
 1r   r  c                   .     e Zd Zeedf fd	ZddZ xZS )_HelpActionNc                 6    t         t        |   |||d|       y )Nr   r   r&  r   r   r   )rg  r  rl   )r8   r   r&  r   r   rj  s        r   rl   z_HelpAction.__init__w  s(    
 	k4)) 	* 	r   c                 D    |j                          |j                          y r   )
print_helpexitrU  s        r   rY  z_HelpAction.__call__  s    r   r   r1   rF   rG   r   rl   rY  rn  ro  s   @r   r  r  u  s     !	
r   r  c                   0     e Zd Zdeedf fd	ZddZ xZS )_VersionActionNc                 ^    |t        d      }t        t        |   |||d|       || _        y )Nz&show program's version number and exitr   r  )r   rg  r  rl   version)r8   r   r  r&  r   r   rj  s         r   rl   z_VersionAction.__init__  sA     <=>Dnd,) 	- 	 r   c                     | j                   }||j                   }|j                         }|j                  |       |j                  |j	                         t
        j                         |j                          y r   )r  _get_formatterr   _print_messager   _sysstdoutr  )r8   rV  rW  rX  r   r  ru   s          r   rY  z_VersionAction.__call__  s[    ,,?nnG))+	7#i335t{{Cr   r   r  ro  s   @r   r  r    s     ! r   r  c                   R     e Zd Z G d de      Zedddf fd	Zd Zd Zd	dZ	 xZ
S )
_SubParsersActionc                        e Zd Z fdZ xZS )&_SubParsersAction._ChoicesPseudoActionc                     |x}}|r|ddj                  |      z  z  }t        t        j                  |       }|j	                  g |||       y )Nr   r.   )r   r&  r   r   )r7   rg  r  _ChoicesPseudoActionrl   )r8   r=   aliasesr   r   r&  suprj  s          r   rl   z/_SubParsersAction._ChoicesPseudoAction.__init__  sU    !!Gd7TYYw%777)>>ECLLD!(  *r   r  ro  s   @r   r  r    s    	* 	*r   r  FNc           	          || _         || _        i | _        g | _        t        t
        |   ||t        | j                  |||       y )N)r   r&  r   r  r   r   r   )_prog_prefix_parser_class_name_parser_map_choices_actionsrg  r  rl   r   )	r8   r   rg   parser_classr&  r   r   r   rj  s	           r   rl   z_SubParsersAction.__init__  sU     !) " "/))) 	0 	r   c                    |j                  d      | j                  d||d<   |j                  dd      }|| j                  v rt	        | t        d      |z        |D ](  }|| j                  v st	        | t        d      |z         d|v r?|j                  d      }| j                  |||      }| j                  j                  |        | j                  di |}|| j                  |<   |D ]  }|| j                  |<    |S )Nrg   r   r  r   zconflicting subparser: %szconflicting subparser alias: %sr   )
r   r  r   r  r   r   r  r  r3   r  )r8   r=   kwargsr  aliasr   choice_actionrV  s           r   
add_parserz_SubParsersAction.add_parser  s(   ::f%(,(9(94@F6N**Y+4(((a(C&Dt&KLL 	HE---#!=>FH H	H V::f%D 55dGTJM!!((7 $##-f-&,d#  	2E+1D!!%(	2 r   c                     | j                   S r   )r  rD   s    r   r  z!_SubParsersAction._get_subactions  s    $$$r   c                    |d   }|dd  }| j                   t        urt        || j                   |       	 | j                  |   }|j                  |d       \  }	}t        |	      j                         D ]  \  }
}t        ||
|        |r?t        |      j                  t        g        t        |t              j                  |       y y # t        $ r9 |dj                  | j                        d}t        d      |z  }t        | |      w xY w)Nr   r    r.   )parser_namer  z5unknown parser %(parser_name)r (choices: %(choices)s))r&  r   rl  r  KeyErrorr7   r   r   parse_known_argsr  rC   
setdefault_UNRECOGNIZED_ARGS_ATTRrN  r   )r8   rV  rW  rX  r   r  r:   r   msgsubnamespacekeyr>   s               r   rY  z_SubParsersAction.__call__  s   QiQRj 99H$Ityy+6	+**;7F %+$;$;K$N!k|,224 	+JCIsE*	+ O&&'>CI67>>{K #  	+#.#yy)>)>?ADKLtSCc**		+s   C	 	ADr   )r1   rF   rG   r   r  r   rl   r  r  rY  rn  ro  s   @r   r  r    s2    *v * .<%Lr   r  c                       e Zd ZddZy)_ExtendActionNc                     t        || j                  d       }t        |      }|j                  |       t	        || j                  |       y r   )rN  r&  rL   r   rl  r  s         r   rY  z_ExtendAction.__call__	  r  r   r   )r1   rF   rG   rY  r   r   r   r  r    s    -r   r  c                   $    e Zd ZdZddZd Zd Zy)r   a  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.
    Nc                 <    || _         || _        || _        || _        y r   )_mode_bufsize	_encoding_errors)r8   modebufsizeencodingerrorss        r   rl   zFileType.__init__$  s    
!r   c                 F    |dk(  rd j                   v r8d j                   v rt        j                  j                  S t        j                  S t	         fddD              r8d j                   v rt        j
                  j                  S t        j
                  S t        d       j                   z  }t        |      	 t        | j                    j                   j                   j                        S # t        $ r#}||d}t        d      }t        ||z        d }~ww xY w)	N-rbc              3   :   K   | ]  }|j                   v   y wr   )r  )r.  r  r8   s     r   r/  z$FileType.__call__.<locals>.<genexpr>/  s     4Q$**_4s   waxzargument "-" with mode %r)filenameerrorz$can't open '%(filename)s': %(error)s)r  r  stdinbufferanyr  r   r   r   r  r  r  OSErrorr   )r8   stringr  er   r   s   `     r   rY  zFileType.__call__*  s    S=djj ,/4::,=tzz((M4::M4e44-0DJJ->t{{))ODKKO34tzzA o%	4

DMM4>>& & 	4 &3D>?G#GdN33	4s   =6C4 4	D =DD c           
      L   | j                   | j                  f}d| j                  fd| j                  fg}dj	                  |D cg c]  }|dk7  s	t        |       c}|D cg c]  \  }}||d| c}}z         }t        |       j                  d|dS c c}w c c}}w )Nr  r  r.   r   r,   r-   r/   )r  r  r  r  r7   r4   r0   r1   )r8   r   r  r<   kwargs_strs         r   r?   zFileType.__repr__>  s    zz4==(t~~.4<<0HI994EC3"9d3iEAG 2gb#!$ *,S1 22 3  :..99 F2s   
BB#B )r  r   NN)r1   rF   rG   rH   rl   rY  r?   r   r   r   r   r     s     4(:r   r   c                   "    e Zd ZdZd Zd Zd Zy)r   zSimple object for storing attributes.

    Implements equality by attribute names and values, and provides a simple
    string representation.
    c                 2    |D ]  }t        | |||           y r   )rl  )r8   r  r=   s      r   rl   zNamespace.__init__Q  s!     	.DD$t-	.r   c                 \    t        |t              st        S t        |       t        |      k(  S r   )r  r   NotImplementedr  )r8   others     r   __eq__zNamespace.__eq__U  s%    %+!!DzT%[((r   c                     || j                   v S r   )rB   )r8   r  s     r   __contains__zNamespace.__contains__Z  s    dmm##r   N)r1   rF   rG   rH   rl   r  r  r   r   r   r   r   J  s    .)
$r   r   c                        e Zd Z fdZd ZddZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZddZd Zd Zd Zd Z xZS )_ActionsContainerc                 @   t         t        |           || _        || _        || _        || _        i | _        | j                  dd t               | j                  ddt               | j                  ddt               | j                  ddt               | j                  ddt               | j                  ddt               | j                  ddt               | j                  ddt               | j                  dd	t                | j                  dd
t"               | j                  ddt$               | j                  ddt&               | j)                          g | _        i | _        g | _        g | _        i | _        t5        j6                  d      | _        g | _        y )Nr   storestore_const
store_truestore_falser3   append_constr  r   r  parsersr   z^-\d+$|^-\d*\.\d+$)rg  r  rl   descriptionargument_defaultprefix_charsconflict_handler_registriesregisterrq  rx  r~  r  r  r  r  r  r  r  r  _get_handler_actions_option_string_actions_action_groups_mutually_exclusive_groups	_defaultsrb   rc   _negative_number_matcher_has_negative_number_optionals)r8   r  r  r  r  rj  s        r   rl   z_ActionsContainer.__init__`  s\   
 	/1& 0( 0  	hl3h6h/@Ah.>?h/@Ah-8h0BCh6h4h	>:h	+<=h-8 	 &(# !*,'  ),4I(J% /1+r   c                 F    | j                   j                  |i       }|||<   y r   )r  r  )r8   registry_namer>   r*  registrys        r   r  z_ActionsContainer.register  s#    ##..}bA r   c                 @    | j                   |   j                  ||      S r   )r  r   )r8   r  r>   r   s       r   _registry_getz_ActionsContainer._registry_get  s     .225'BBr   c                     | j                   j                  |       | j                  D ]%  }|j                  |v s||j                     |_        ' y r   )r  updater  r&  r   )r8   r  r   s      r   set_defaultsz_ActionsContainer.set_defaults  sE    f% mm 	5F{{f$!'!4	5r   c                     | j                   D ],  }|j                  |k(  s|j                   |j                  c S  | j                  j	                  |d       S r   )r  r&  r   r  r   )r8   r&  r   s      r   get_defaultz_ActionsContainer.get_default  sM    mm 	&F{{d"v~~'A~~%	& ~~!!$--r   c                    | j                   }|rt        |      dk(  r.|d   d   |vr$|rd|v rt        d       | j                  |i |}n | j                  |i |}d|vrA|d   }|| j
                  v r| j
                  |   |d<   n| j                  | j                  |d<   | j                  |      }t        |      st        d|d       |di |}| j                  d	|j                  |j                        }t        |      st        |d
      |t        u rt        |d      t        | d      r!	 | j                         j                  |d       | j!                  |      S # t        $ r t        d      w xY w)z
        add_argument(dest, ..., name=value, ...)
        add_argument(option_string, option_string, ..., name=value, ...)
        r    r   r&  z+dest supplied twice for positional argumentr   Nzunknown action ""r0   z is not callablez: is a FileType class object, instance of it must be passedr  z,length of metavar tuple does not match nargsr   )r  r   r   _get_positional_kwargs_get_optional_kwargsr  r  _pop_action_classcallabler  r0   r   r  r  r   r  _add_action)r8   r   r  charsr&  action_classr   	type_funcs           r   r   z_ActionsContainer.add_argument  s    !!s4yA~$q'!*E*A&( !NOO0T00$A&AF /T..??F F"&>Dt~~%$(NN4$8y!&&2$($9$9y! --f5%lDEE'' &&vv{{FKKH		"Y@AA 2;> ? ? 4)*Q##%2264@ ''  Q !OPPQs   8 E) )E>c                 Z    t        | g|i |}| j                  j                  |       |S r   )_ArgumentGroupr  r3   )r8   r   r  r   s       r   add_argument_groupz$_ActionsContainer.add_argument_group  s/    t5d5f5""5)r   c                 T    t        | fi |}| j                  j                  |       |S r   )_MutuallyExclusiveGroupr  r3   )r8   r  r   s      r   add_mutually_exclusive_groupz._ActionsContainer.add_mutually_exclusive_group  s*    '77''..u5r   c                 V   | j                  |       | j                  j                  |       | |_        |j                  D ]  }|| j
                  |<    |j                  D ]F  }| j                  j                  |      s| j                  r,| j                  j                  d       H |S )NT)	_check_conflictr  r3   	containerr   r  r  matchr  )r8   r   r   s      r   r  z_ActionsContainer._add_action  s    V$ 	V$ $22 	@M9?D''6	@ $22 	EM,,22=A::77>>tD	E r   c                 :    | j                   j                  |       y r   )r  ra  r#  s     r   _remove_actionz _ActionsContainer._remove_action  s    V$r   c                    i }| j                   D ]B  }|j                  |v r#t        d      }t        ||j                  z        |||j                  <   D i }|j                   D ]r  }|j                  |vr?| j	                  |j                  |j
                  |j                        ||j                  <   |j                  D ]  }||j                     ||<    t |j                  D ]4  }| j                  |j                        }|j                  D ]  }|||<   	 6 |j                  D ]#  }|j                  ||       j                  |       % y )Nz.cannot merge actions - two groups are named %r)titler  r  )r   )r  r!  r   r   r  r  r  r   r  r  r   r  r   r  )r8   r  title_group_mapr   r  	group_mapr   mutex_groups           r   _add_container_actionsz(_ActionsContainer._add_container_actions  si   (( 	1E{{o-HI !455+0OEKK(		1 	-- 	AE {{/1/3/F/F++ % 1 1%*%;%; 0G 0=,  .. A$3EKK$@	&!A	A" 99 	0E;; < )K  .. 0$/	&!0	0  (( 	<FMM&$'33F;	<r   c                     d|v rt        d      }t        |      |j                  d      t        t        fvrd|d<   |j                  d      t        k(  r	d|vrd|d<   t        ||g       S )Nr   z1'required' is an invalid argument for positionalsr   Tr   r&  r   )r   r  r   r   r   r}   )r8   r&  r  r  s       r   r  z(_ActionsContainer._get_positional_kwargs/  st    GHCC.  ::gx&>>!%F:::g,.9F3J!%F: Fb99r   c                    g }g }|D ]~  }|d   | j                   vr(|| j                   d}t        d      }t        ||z        |j                  |       t	        |      dkD  s\|d   | j                   v sn|j                  |        |j                  dd       }|U|r|d   }n|d   }|j                  | j                         }|st        d      }t        |z        |j                  dd      }t        |||	      S )
Nr   )optionr  zNinvalid option string %(option)r: must start with a character %(prefix_chars)rr    r&  z%dest= is required for options like %rr  r   r'  )	r  r   r   r3   r   r   lstripreplacer}   )	r8   r   r  r   long_option_stringsr   r  r&  dest_option_strings	            r   r  z&_ActionsContainer._get_optional_kwargs?  s$    ! 	:M #t'8'88"/(,(9(9; G H t,, !!-0=!A%-*:d>O>O*O#**=9	: zz&$'<"%8%;"%3A%6"%,,T->->?D?@ }!455<<S)D FnEEr   c                 L    |j                  d|      }| j                  d||      S )Nr   )r   r  )r8   r  r   r   s       r   r  z#_ActionsContainer._pop_action_classa  s'    Hg.!!(FF;;r   c                     d| j                   z  }	 t        | |      S # t        $ r$ t        d      }t	        || j                   z        w xY w)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)r  rN  r  r   r   )r8   handler_func_namer  s      r   r  z_ActionsContainer._get_handlere  sV    1D4I4II	:4!233 	:;<CS4#8#8899	:s	    -A
c                     g }|j                   D ]3  }|| j                  v s| j                  |   }|j                  ||f       5 |r| j                         } |||       y y r   )r   r  r3   r  )r8   r   confl_optionalsr   confl_optionalr  s         r   r  z!_ActionsContainer._check_conflictn  st     #22 	HM ; ;;!%!<!<]!K&&~'FG	H #002V_5 r   c                     t        ddt        |            }dj                  |D cg c]  \  }}|	 c}}      }t        ||z        c c}}w )Nzconflicting option string: %szconflicting option strings: %sr.   )r   r   r7   r   )r8   r   conflicting_actionsr   r   conflict_strings         r   _handle_conflict_errorz(_ActionsContainer._handle_conflict_error|  s^    :;235 ))(;%=)> &3 %= > FGo$=>>%=s   A

c                     |D ]d  \  }}|j                   j                  |       | j                  j                  |d        |j                   rJ|j                  j                  |       f y r   )r   ra  r  r   r  r  )r8   r   r5  r   s       r   _handle_conflict_resolvez*_ActionsContainer._handle_conflict_resolve  sc     &9 		8!M6 !!((7''++M4@ ((  //7		8r   r   )r1   rF   rG   rl   r  r  r  r	  r   r  r  r  r  r%  r  r  r  r  r  r7  r9  rn  ro  s   @r   r  r  ^  sc    01j!C5.1(f

*%&<P:  FD<:6?8r   r  c                   >     e Zd Zd fd	Z fdZ fdZ fdZ xZS )r  c                    |j                   } |d|j                          |d|j                          |d|j                         t        t
        |   } |dd|i| || _        g | _        |j                  | _	        |j                  | _
        |j                  | _        |j                  | _        |j                  | _        |j                  | _        y )Nr  r  r  r  r   )r  r  r  r  rg  r  rl   r!  r   r  r  r  r  r  r  )r8   r  r!  r  r  r  
super_initrj  s          r   rl   z_ArgumentGroup.__init__  s    ""!9#=#=>~y556!9#=#=>>49
5{5f5 
  %00!**&/&F&F#",,44 	+*3*N*N'r   c                 d    t         t        |   |      }| j                  j	                  |       |S r   )rg  r  r  r   r3   r8   r   rj  s     r   r  z_ArgumentGroup._add_action  s-    ~t8@""6*r   c                 b    t         t        |   |       | j                  j	                  |       y r   )rg  r  r  r   ra  r>  s     r   r  z_ArgumentGroup._remove_action  s&    nd26:""6*r   c                 Z    t        j                  dt        d       t        |   |i |S )Nz&Nesting argument groups is deprecated.rO   category
stacklevel)re  warnDeprecationWarningrg  r  r8   r   r  rj  s      r   r  z!_ArgumentGroup.add_argument_group  s/    4'	

 w)4:6::r   NN)r1   rF   rG   rl   r  r  r  rn  ro  s   @r   r  r    s    O,
+; ;r   r  c                   6     e Zd Zd fd	Zd Zd Z fdZ xZS )r  c                 H    t         t        |   |       || _        || _        y r   )rg  r  rl   r   
_container)r8   r  r   rj  s      r   rl   z _MutuallyExclusiveGroup.__init__  s!    %t5i@ #r   c                     |j                   rt        d      }t        |      | j                  j	                  |      }| j
                  j                  |       |S )Nz-mutually exclusive arguments must be optional)r   r   r   rJ  r  r   r3   )r8   r   r  s      r   r  z#_MutuallyExclusiveGroup._add_action  sK    ??CDCS/!,,V4""6*r   c                 p    | j                   j                  |       | j                  j                  |       y r   )rJ  r  r   ra  r#  s     r   r  z&_MutuallyExclusiveGroup._remove_action  s(    &&v.""6*r   c                 Z    t        j                  dt        d       t        |   |i |S )Nz0Nesting mutually exclusive groups is deprecated.rO   rA  )re  rD  rE  rg  r  rF  s      r   r  z4_MutuallyExclusiveGroup.add_mutually_exclusive_group  s/    >'	

 w3TDVDDr   )F)r1   rF   rG   rl   r  r  r  rn  ro  s   @r   r  r    s    $
+E Er   r  c                        e Zd ZdZddddg edddddddf fd	Zd Zd Zd	 Zd
 Z	d Z
d#dZd#dZd Zd Zd Zd Zd Zd Zd Zd Zd#dZd#dZd Zd Zd Zd Zd Zd Zd$dZd$dZd$d Zd%d!Z d" Z! xZ"S )&r   aK  Object for parsing command line strings into Python objects.

    Keyword Arguments:
        - prog -- The name of the program (default:
            ``os.path.basename(sys.argv[0])``)
        - usage -- A usage message (default: auto-generated from arguments)
        - description -- A description of what the program does
        - epilog -- Text following the argument descriptions
        - parents -- Parsers whose arguments should be copied into this one
        - formatter_class -- HelpFormatter class for printing help messages
        - prefix_chars -- Characters that prefix optional arguments
        - fromfile_prefix_chars -- Characters that prefix files containing
            additional arguments
        - argument_default -- The default value for all arguments
        - conflict_handler -- String indicating how to handle conflicts
        - add_help -- Add a -h/-help option
        - allow_abbrev -- Allow long options to be abbreviated unambiguously
        - exit_on_error -- Determines whether or not ArgumentParser exits with
            error info when an error occurs
    Nr  r  Tc           	         t         t        | 
  } ||||	|
       |0t        j                  j                  t        j                  d         }|| _        || _	        || _
        || _        || _        || _        || _        || _        | j                   } |t#        d            | _         |t#        d            | _        d | _        d }| j+                  dd |       d|v rdn|d   }| j                  r,| j-                  |dz   |d	z  d
z   d
t.        t#        d             |D ];  }| j1                  |       	 |j2                  }| j2                  j5                  |       = y # t6        $ r Y Jw xY w)N)r  r  r  r  r   zpositional argumentsoptionsc                     | S r   r   )r  s    r   identityz)ArgumentParser.__init__.<locals>.identity  s    Mr   r0   r  hrO   r   zshow this help message and exit)r   r   r   )rg  r   rl   _ospathbasenamer  argvrg   r   epilogformatter_classfromfile_prefix_charsadd_helpallow_abbrevexit_on_errorr  r   _positionals
_optionals_subparsersr  r   r   r%  r  r  r  )r8   rg   r   r  rX  parentsrY  r  rZ  r  r  r[  r\  r]  	superinit	add_grouprR  default_prefixrv   defaultsrj  s                       r   rl   zArgumentParser.__init__  su    .$8	k+#3#3	5 <88$$TYYq\2D	
.%:" (*++	%a(>&?@#AiL1	fdH- !$| 3a==s"N1$4V$;x89  ;  	0F''/0!++ %%h/	0 " s   5E	E+*E+c                 L    g d}|D cg c]  }|t        | |      f c}S c c}w )N)rg   r   r  rY  r  r[  rM  rO  s      r   r5   zArgumentParser._get_kwargs2  s+    
 9>>wtT*+>>>rQ  c                    | j                   | j                  t        d             |j                  dt	        |              d|v sd|v rNt        |j                  dd            }t        |j                  dd             }| j                  ||      | _         n| j                  | _         |j                  d      k| j                         }| j                         }| j                  }|j                  | j                  ||d       |j                         j                         |d<   | j!                  |d      } |d
d	g i|}| j                   j#                  |       |S )Nz(cannot have multiple subparser argumentsr  r!  r  subcommandsrg   ry   r  r   r   )r`  r  r   r  r0   r   r  r^  r   r  _get_positional_actionsr  r   r   r   r   r  r  )	r8   r  r!  r  ru   r   r   parsers_classr   s	            r   add_subparserszArgumentParser.add_subparsers@  s>   'JJqCDE 	.$t*5f 7fjj-89EFJJ}d;<K#66ukJD#00D ::f%++-I668K44F

KD&224::<F6N ..vyA;b;F;$$V, r   c                     |j                   r| j                  j                  |       |S | j                  j                  |       |S r   )r   r_  r  r^  r#  s     r   r  zArgumentParser._add_action_  s?      OO''/  ))&1r   c                 X    | j                   D cg c]  }|j                  r| c}S c c}w r   r  r   r#  s     r   _get_optional_actionsz$ArgumentParser._get_optional_actionsf  s/    "mm*((  * 	* *   'c                 X    | j                   D cg c]  }|j                  s| c}S c c}w r   rn  r#  s     r   ri  z&ArgumentParser._get_positional_actionsk  s/    "mm.,,  . 	. .rp  c                     | j                  ||      \  }}|r.t        d      }| j                  |dj                  |      z         |S Nzunrecognized arguments: %sr   )r  r   r  r7   r8   r   rW  rW  r  s        r   
parse_argszArgumentParser.parse_argss  sD    **4;
d01CJJsSXXd^+,r   c                     |t         j                  dd  }nt        |      }|
t               }| j                  D ]`  }|j
                  t        ust        ||j
                        r-|j                  t        us@t        ||j
                  |j                         b | j                  D ])  }t        ||      rt        ||| j                  |          + | j                  r	 | j                  ||      \  }}n| j                  ||      \  }}t        |t               r/|j#                  t%        |t                      t'        |t                ||fS # t        $ r$}| j                  t        |             Y d }~kd }~ww xY wr   )r  rW  rA   r   r  r&  r   r  r   rl  r  r]  _parse_known_argsr   r  r  r  r   rN  delattr)r8   r   rW  r   r&  errs         r   r  zArgumentParser.parse_known_argsz  sL   <99QR=D :D !I mm 	HF{{(*y&++6~~X5	6;;G		H NN 	?D9d+	4)=>	?
 %"&"8"8y"I	4 #44T9EOIt956KK	+BCDI67$ ! %

3s8$$%s   "E 	E=E88E=c           	      X    !"  j                    j                        i  j                  D ]h  }|j                  }t	        |j                        D ]B  \  }}j                  |g       }|j                  |d |        |j                  ||dz   d         D j i g }t              }	t	        |	      D ]b  \  }}
|
dk(  r*|j                  d       |	D ]  }
|j                  d        5 j                  |
      }|d}n||<   d}|j                  |       d dj                  |      t                t               !d ! fd	" "fd} j                          "fd	}g d
}rt              }nd}||k  r_t        D cg c]	  }||k\  r| c}      }||k7  r ||      }||kD  r|}8|}|vr|| }j                  |       |} ||      }||k  r_ ||      }j                  |d         g } j                  D ]  }| vs|j                   r|j                  t#        |             /|j$                  <t'        |j$                  t(              sWt+        |j,                        sn|j$                  t/        |j,                        u st1        |j,                   j3                  ||j$                                |r, j5                  t7        d      dj                  |      z          j                  D ]  }|j                   s|j                  D ]  }|!v s & |j                  D cg c]  }|j8                  t:        urt#        |      ! }}t7        d      } j5                  |dj                  |      z          fS c c}w c c}w )Nr    r]  r  AOry   c                 2   	j                  |        j                  | |      }|| j                  urQ
j                  |        j                  | g       D ]+  }|
v st	        d      }t        |      }t        | ||z         |t        ur | ||       y y )Nznot allowed with argument %s)r   _get_valuesr   r   r   rA  r   r   )r   argument_stringsr   argument_valuesconflict_actionr  action_nameaction_conflictsrW  seen_actionsseen_non_default_actionsr8   s          r   take_actionz5ArgumentParser._parse_known_args.<locals>.take_action  s    V$"..v7GHO
 fnn4(,,V4'7';';FB'G GO&*BB >?&6&G+FC+4EFF	G h.tYG /r   c                    |    }|\  }}}}j                   }g }	 |j                  |           | dz   S | ||d      }j                  }	|dk(  r|d   |	vr|dk7  r|s|d   |	v rt        d      }
t	        ||
|z        |j                  |g |f       |d   }||d   z   }j
                  }||v r$||   }|dd  }|sd x}}n|d   dk(  rd}|dd  }nd}nj                  ||z          | dz   }np|dk(  r| dz   }|g}|j                  |||f       nNt        d      }
t	        ||
|z        | dz   }|d  } |||      }||z   }|| }|j                  |||f       nE|sJ |D ]  \  }}} |||        |S )Nr    r{  r   ry   zignored explicit argument %rr,   )_match_argumentr3   r  r   r   r  )start_indexoption_tupler   r   sepexplicit_argmatch_argumentaction_tuples	arg_countr  r  charoptionals_mapstopr   r   selected_patternsr:   arg_strings_patternextrasoption_string_indicesr8   r  s                    r   consume_optionalz:ArgumentParser._parse_known_args.<locals>.consume_optional  s9    1=L7C4FM3 "11NM >MM+k":;&?*  + .vs ;I
 !--E!Q)!,E9(B.,q/U":"#$B"CC"/l8J"KK%,,fb--HI,Q/(,|A(>(,(C(C(M9%2=%AF+7+;L#/59 9l!-aC!7&)/;AB/?&("MM$*=>#.?D! #a*Q ,~%,,fdM-JK
   >?+FC,4FGG (!OE(;EF(C% .v7H II 9,D&uT2D!((&$)FGE L ! =/< 9+mFD-89Kr   c                     
j                   }| d  } |	|      }t        	|      D ]  \  }}| | |z    }| |z  }  ||        	t        |      d  	d d  | S r   )_match_arguments_partialzipr   )r  match_partialselected_pattern
arg_countsr   r  r   r:   r  r   r8   r  s          r   consume_positionalsz=ArgumentParser._parse_known_args.<locals>.consume_positionals>  s     99M2;<@&{4DEJ &)j%A *!	";i0GHy(FD)* )Z)9:KNr   r   r   z(the following arguments are required: %sr.   z#one of the arguments %s is requiredr   r   )rZ  _read_args_from_filesr  r   r   r  r   iterr3   _parse_optionalr7   r   ri  rY   rX   r  r   rA  r   r  r  r  r&  rN  rl  
_get_valuer  r   r   r   )#r8   r:   rW  r$  r   r   mutex_action	conflictsarg_string_pattern_partsarg_strings_iter
arg_stringr  patternr  r  r  max_option_string_indexr   next_option_string_indexpositionals_end_indexstrings
stop_indexrequired_actionsr   r   rP  r  r  r  r  r  r   r  r  r  s#   ```                        @@@@@@@@r   rw  z ArgumentParser._parse_known_args  s   %%144[AK :: 	8K'66M#,[-G-G#H 8<,77bI	  r!23  q1uv!678	8 !##% ,&'78 	9MAz T!(//4"2 9J,33C89  $33J?'!G/;)!,!G(//8#	9( !gg&>? u#&5 	H 	H*S	 S	n 224	 	(  &)*?&@#&(#44 (+2,)K' ,) (*$ 66(;K(H% );6"7K"7K "77%k2JKg&6 +;7K5 44: )5
 	k*+./ mm 	IF\)??$++,<V,DE 2"6>>37	6;;7')V[[*II	6;; $ GI	I  JJqCDyy!123 4 44 	6E~~#22 
6F!99
6 ,1+?+?=!' &8 ; .f5 =E = ABCJJsSXXe_45	6 &  M,)~=s   N"$N'c                 6   g }|D ]  }|r|d   | j                   vr|j                  |       (	 t        |dd  t        j                         t        j
                               5 }g }|j                         j                         D ])  }| j                  |      D ]  }|j                  |        + | j                  |      }|j                  |       d d d         |S # 1 sw Y   xY w# t        $ r%}| j                  t        |             Y d }~d }~ww xY w)Nr   r    )r  r  )rZ  r3   r   r  getfilesystemencodinggetfilesystemencodeerrorsreadr1  convert_arg_line_to_argsr  r   r  r  r  )r8   r:   new_arg_stringsr  	args_filearg_liner<   ry  s           r   r  z$ArgumentParser._read_args_from_files  s   % 	)J Ad6P6P!P&&z2)jn'+'A'A'C%)%C%C%EG <JS&((1(8(C(C(E 8H'+'D'DX'N 8 + 2 23 788 '+&@&@&M'..{;<	), < <  )JJs3x(()s0   5C*#A/CC*C'	#C**	D3DDc                     |gS r   r   )r8   r  s     r   r  z'ArgumentParser.convert_arg_line_to_args  s
    zr   c                 x   | j                  |      }t        j                  ||      }|xd t        d      t        t        d      t
        t        d      i}|j                  |j                        }|$t        dd|j                        |j                  z  }t        ||      t        |j                  d            S )Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsr    )_get_nargs_patternrb   r  r   r   r   r   r   r   r   r   r   )r8   r   r  nargs_patternr  nargs_errorsr  s          r   r  zArgumentParser._match_argument  s    //7		-)<= =a/0!;<Q?@L
 ""6<<0C{56%||-/5||<  ,, 5;;q>""r   c           	      \   g }t        t        |      dd      D ]  }|d | }dj                  |D cg c]  }| j                  |       c}      }t	        j
                  ||      }|O|j                  |j                         D 	cg c]  }	t        |	       c}	        |S  |S c c}w c c}	w )Nr   r   ry   )r   r   r7   r  rb   r  r   r   )
r8   r   r  r  r   actions_slicer   r  r  r  s
             r   r  z'ArgumentParser._match_arguments_partial  s     s7|Q+ 	A#BQKMgg-:<#)  $66v> < =GIIg':;E Hvs6{HI 	 < Is   B$
B)
c                 ~   |sy |d   | j                   vry || j                  v r| j                  |   }||d d fS t        |      dk(  ry |j                  d      \  }}}|r#|| j                  v r| j                  |   }||||fS | j	                  |      }t        |      dkD  rOdj                  |D cg c]	  \  }}}}| c}}}}      }||d}t        d      }	| j                  |	|z         nt        |      dk(  r|\  }
|
S | j                  j                  |      r| j                  sy d|v ry d |d d fS c c}}}}w )Nr   r    r,   r.   )r)  matchesz4ambiguous option: %(option)s could match %(matches)sr   )r  r  r   	partition_get_option_tuplesr7   r   r  r  r  r  )r8   r  r   r   r  r  option_tuplesrP  r   r  r  s              r   r  zArgumentParser._parse_optional  s    !} 1 11 44400<F:tT11 z?a ,6+?+?+D(sL=D$?$??00?F=#|;; //
; }!ii@M!O !O<FM3 "/ !O PG(W=DJKCJJsTz" 1$)ML
 ((..z:66 * Zt++3!Os   3D7c                 ~   g }| j                   }|d   |v ry|d   |v rr| j                  rd|j                  d      \  }}}|sd x}}| j                  D ]:  }|j	                  |      s| j                  |   }||||f}|j                  |       < |S |d   |v r|d   |vr|}|d d }	|dd  }
| j                  D ]f  }||	k(  r'| j                  |   }||d|
f}|j                  |       /|j	                  |      sA| j                  |   }||d d f}|j                  |       h |S | j                  t        d      |z         |S )Nr   r    r,   rO   ry   zunexpected option string: %s)r  r\  r  r  rb  r3   r  r   )r8   r   r  r  option_prefixr  r  r   r   short_option_prefixshort_explicit_args              r   r  z!ArgumentParser._get_option_tuples 	  s    !!u$q)9U)B  3@3J3J33O0sL)--C,%)%@%@ +M$//>!%!<!<]!K$mS,Fc*	+: ) 1&=+;5+H)M"/"3!.qr!2!%!<!< ' $77!88GF -5GGCMM#&"--m<!88GF -t;CMM#&'  JJq78=HI r   c                 F   |j                   }|d}n_|t        k(  rd}nS|t        k(  rd}nG|t        k(  rd}n;|t        k(  rd}n/|t
        k(  rd}n#|t        k(  rd}ndd	j                  d
|z        z  }|j                  r$|j                  d	d      }|j                  dd      }|S )Nz(-*A-*)z(-*A?-*)z	(-*[A-]*)z
(-*A[A-]*)z([-AO]*)z(-*A[-AO]*)z(-*-*)z(-*%s-*)z-*r{  ry   r  )
r   r   r   r   r   r   r   r7   r   r+  )r8   r   r   r  s       r   r  z!ArgumentParser._get_nargs_patternJ	  s      =%M h&M l"'M k!(M i&M f_)M h$M '3;)??M   )11$;M)11#r:M r   c                     | j                  ||      \  }}|r.t        d      }| j                  |dj                  |      z         |S rs  )parse_known_intermixed_argsr   r  r7   rt  s        r   parse_intermixed_argsz$ArgumentParser.parse_intermixed_args{	  sD    55dIF
d01CJJsSXXd^+,r   c                    | j                         }|D cg c]  }|j                  t        t        fv r| }}|rt	        d|d   j                  z        | j
                  D cg c]#  }|j                  D ]  }||v r|j                   % c}}rt	        d      	 | j                  }	 | j                  | j                         dd  | _        |D ]:  }|j                  |_
        t        |_        |j                  |_        t        |_        < | j                  ||      \  }}|D ]g  }t        ||j                        st!        ||j                        g k(  s4ddlm}	  |	d|j                  d|       t'        ||j                         i 	 |D ]$  }|j                  |_        |j                  |_        & 	 | j)                         }
	 |
D ]  }|j*                  |_        d|_         | j
                  D ]  }|j*                  |_        d|_         | j                  ||      \  }}|
D ]  }|j,                  |_         | j
                  D ]  }|j,                  |_         	 || _        ||fS c c}w c c}}w # |D ]$  }|j                  |_        |j                  |_        & w xY w# |
D ]  }|j,                  |_         | j
                  D ]  }|j,                  |_         w xY w# | _        w xY w)	Nz3parse_intermixed_args: positional arg with nargs=%sr   z;parse_intermixed_args: positional in mutuallyExclusiveGroup   )rD  zDo not expect z in F)ri  r   r   r   r  r  r   r&  r   r   
save_nargsr   r   save_defaultr  r  rN  re  rD  rx  ro  r   save_required)r8   r   rW  r   r   ar   
save_usageremaining_argsrD  r   r  s               r   r  z*ArgumentParser.parse_known_intermixed_args	  s    224"- 5 33  5 5 --.qTZZ8 9 9 &*%D%D IE..I&K2G KK IK I 6 7 7.	$J9::%!%!2!2!4QR!8DJ) .F(.F%#+FL*0..F'%-FN. -1,A,A$BK-M)	>) 8F	6;;7 '	6;; ? C1iPQ	6;;78 * 9F#)#4#4FL%+%8%8FN9 224I9 ( ,F+1??F(&+FO, "<< +E*/..E'%*EN+ %)$9$9.:C%E!	6 ( ;F&,&:&:FO;!<< 9E%*%8%8EN9 $DJ&  u5I: * 9F#)#4#4FL%+%8%8FN9" ( ;F&,&:&:FO;!<< 9E%*%8%8EN9 $DJsU   !I,$(I1K$ )BI7 =I7 6I7 :K$ 	AJ% &:K$ 7+J""K$ %<K!!K$ $	K-c                 j   |j                   s*|j                  t        t        fvr	 |j	                  d       |sn|j                  t        k(  r[|j                   r|j                  }n|j                  }t        |t              r$| j                  ||      }| j                  ||       |S |sO|j                  t        k(  r<|j                   s0|j                   |j                  }| j                  ||       |S |}|S t        |      dk(  r>|j                  d t        fv r*|\  }| j                  ||      }| j                  ||       |S |j                  t        k(  r!|D cg c]  }| j                  ||       }}|S |j                  t        k(  r6|D cg c]  }| j                  ||       }}| j                  ||d          |S |j                  t        k(  rt        }|S |D cg c]  }| j                  ||       }}|D ]  }| j                  ||        |S # t
        $ r Y w xY wc c}w c c}w c c}w )Nr]  r    r   )r   r   r   r   ra  r   r   rK  r   r  r  r  _check_valuer   r   r   )r8   r   r:   r>   r  vs         r   r~  zArgumentParser._get_values	  s-   $$fi=P)P""4(
 v||x7$$%%6!!&%0P I &,,,">''~~)!!&%0@ 9 $8 3 "v||h7G'G%KJOOFJ7Efe,, ' \\Y&9DEAT__VQ/EEE$  \\V#9DEAT__VQ/EEEfeAh/  \\X%E  :EEAT__VQ/EEE -!!&!,- g  B F F Fs#   H H&H+ H0	H#"H#c                    | j                  d|j                  |j                        }t        |      st        d      }t	        |||z        	  ||      }|S # t
        $ r}t        |      }t	        ||      d }~wt        t        f$ rJ t        |j                  dt        |j                              }||d}t        d      }t	        |||z        w xY w)Nr0   z%r is not callabler1   )r0   r>   z!invalid %(type)s value: %(value)r)r  r0   r  r   r   r   r  r  r   rN  r4   )	r8   r   r  r  r  r  ry  r=   r   s	            r   r  zArgumentParser._get_value	
  s    &&vv{{FKKH		"()Ci88	4z*F  ! 	-c(C,, :& 	46;;
D4EFD :6D78Cd
33		4s   A 	C!A88ACc                     |j                   U||j                   vrF|dj                  t        t        |j                               d}t	        d      }t        |||z        y y )Nr.   )r>   r  z3invalid choice: %(value)r (choose from %(choices)s))r  r7   r   r4   r   r   )r8   r   r>   r   r  s        r   r  zArgumentParser._check_value"
  s^    >>%%v~~*E"#yyT6>>)BCEDIJCd
33	 +F%r   c                     | j                         }|j                  | j                  | j                  | j                         |j                         S r   )r  r   r   r  r  r   )r8   ru   s     r   r   zArgumentParser.format_usage-
  sB    '')	DJJ ;;	=$$&&r   c                    | j                         }|j                  | j                  | j                  | j                         |j                  | j                         | j                  D ]c  }|j                  |j                         |j                  |j                         |j                  |j                         |j                          e |j                  | j                         |j                         S r   )r  r   r   r  r  r   r  r  r   r!  r   r   r   rX  r   )r8   ru   action_groups      r   r   zArgumentParser.format_help3
  s    '')	 	DJJ ;;	= 	4++, !// 	$L##L$6$67|778##L$?$?@!!#		$ 	4;;' $$&&r   c                 :    | j                  | j                        S )Nr   )rY  rg   rD   s    r   r  zArgumentParser._get_formatterJ
  s    ###33r   c                 h    |t         j                  }| j                  | j                         |       y r   )r  r  r  r   r8   files     r   print_usagezArgumentParser.print_usageP
  s)    <;;DD--/6r   c                 h    |t         j                  }| j                  | j                         |       y r   )r  r  r  r   r  s     r   r  zArgumentParser.print_helpU
  s)    <;;DD,,.5r   c                     |r'|xs t         j                  }	 |j                  |       y y # t        t        f$ r Y y w xY wr   )r  stderrwriter  r  )r8   r   r  s      r   r  zArgumentParser._print_messageZ
  sB    &4;;D

7#  #G, s   + ==c                 r    |r | j                  |t        j                         t        j                  |       y r   )r  r  r  r  )r8   statusr   s      r   r  zArgumentParser.exite
  s%    5		&r   c                     | j                  t        j                         | j                  |d}| j	                  dt        d      |z         y)zerror(message: string)

        Prints a usage message incorporating the message to stderr and
        exits.

        If you override this in a subclass, it should not return -- it
        should either exit or raise an exception.
        )rg   r   rO   z%(prog)s: error: %(message)s
N)r  r  r  rg   r  r   )r8   r   r   s      r   r  zArgumentParser.errorj
  s=     	%		g6		!Q784?@r   rG  r   )r   N)#r1   rF   rG   rH   r   rl   r5   rk  r  ro  ri  ru  r  rw  r  r  r  r  r  r  r  r  r  r~  r  r  r   r   r  r  r  r  r  r  rn  ro  s   @r   r   r     s    , !!.!'+"&")"#=0D	?>*
.$LA!F6#, 7,r(T+bH!Z8t24''.47
6

Ar   r   )5rH   __version____all__osrT  rerb   sysr  re  r   r   r   rU   r   r   r   r   r   r   r  r*  r*   rL   r   r	   r
   r   r   rA  	Exceptionr   r   r   rd  r   rq  rx  r~  r  r  r  r  r  r  r  r  r   r   r  r  r  r   r   r   r   <module>r     s  ;z ,    	. 		. v >	"KF K\Q- Q!6 !M :$} $&?I ?(		 	\@ \@@ h 6/F 6/r .6  .F2 2.( ") "#-F #-L- -616 1.& &V 8bL bLH-M -1:v 1:n$  $(s8 s8l	';& ';TEn E8[A%'8 [Au3  s   E( (E76E7