AlkantarClanX12

Your IP : 18.119.106.66


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/optparse.cpython-37.opt-2.pyc

B

YI~d���@s�dZddddddddd	d
ddd
ddddgZdZddlZddlZddlZdd�ZyddlmZmZWn$e	k
r�dd�Zdd�ZYnXeZ
Gdd�de�ZGdd
�d
e�Z
Gdd�de
�ZGdd�de�ZGd d�de�ZGd!d"�d"e�ZGd#d	�d	�ZGd$d
�d
e�ZGd%d�de�Zd&d'�Zd(d)�Zee
d*�fee
d*�fee
d+�fee
d,�fd-�Zd.d/�Zd0d�Zd1ZGd2d�d�Zd3Zd4ZGd5d�d�Z Gd6d�d�Z!Gd7d�de!�Z"Gd8d�de!�Z#d9d:�Z$eZ%dS);z1.5.3�Option�make_option�
SUPPRESS_HELP�SUPPRESS_USAGE�Values�OptionContainer�OptionGroup�OptionParser�
HelpFormatter�IndentedHelpFormatter�TitledHelpFormatter�
OptParseError�OptionError�OptionConflictError�OptionValueError�BadOptionError�check_choicea"
Copyright (c) 2001-2006 Gregory P. Ward.  All rights reserved.
Copyright (c) 2002-2006 Python Software Foundation.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

  * Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

  * Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.

  * Neither the name of the author nor the names of its
    contributors may be used to endorse or promote products derived from
    this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
�NcCsd|jjt|�|fS)Nz<%s at 0x%x: %s>)�	__class__�__name__�id)�self�r�-/opt/alt/python37/lib64/python3.7/optparse.py�_reprOsr)�gettext�ngettextcCs|S)Nr)�messagerrrr\srcCs|dkr|S|S)N�r)Zsingular�plural�nrrrr_src@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�msg)rr rrr�__init__hszOptParseError.__init__cCs|jS)N)r )rrrr�__str__kszOptParseError.__str__N)r�
__module__�__qualname__r!r"rrrrrgsc@seZdZdd�Zdd�ZdS)r
cCs||_t|�|_dS)N)r �str�	option_id)rr �optionrrrr!uszOptionError.__init__cCs |jrd|j|jfS|jSdS)Nz
option %s: %s)r&r )rrrrr"yszOptionError.__str__N)rr#r$r!r"rrrrr
osc@seZdZdS)rN)rr#r$rrrrrsc@seZdZdS)rN)rr#r$rrrrr�sc@seZdZdd�Zdd�ZdS)rcCs
||_dS)N)�opt_str)rr(rrrr!�szBadOptionError.__init__cCstd�|jS)Nzno such option: %s)�_r()rrrrr"�szBadOptionError.__str__N)rr#r$r!r"rrrrr�sc@seZdZdd�Zdd�ZdS)�AmbiguousOptionErrorcCst�||�||_dS)N)rr!�
possibilities)rr(r+rrrr!�szAmbiguousOptionError.__init__cCstd�|jd�|j�fS)Nzambiguous option: %s (%s?)z, )r)r(�joinr+)rrrrr"�szAmbiguousOptionError.__str__N)rr#r$r!r"rrrrr*�sr*c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!r	Znonec	Cs�d|_||_|dkrLyttjd�}Wnttfk
rBd}YnX|d8}||_t|t	|d|d��|_
|_d|_d|_
d|_||_d|_i|_d|_d|_dS)	N�COLUMNS�P��rz%defaultz%s %sz%s=%s)�parser�indent_increment�int�os�environ�KeyError�
ValueError�width�min�max�
help_position�max_help_position�current_indent�level�
help_width�short_first�default_tag�option_strings�_short_opt_fmt�
_long_opt_fmt)rr2r<r8r@rrrr!�s$
 zHelpFormatter.__init__cCs
||_dS)N)r1)rr1rrr�
set_parser�szHelpFormatter.set_parsercCs&|dkrtd|��d|d|_dS)N)�� z/invalid metavar delimiter for short options: %rz%s)r7rC)r�delimrrr�set_short_opt_delimiter�s
z%HelpFormatter.set_short_opt_delimitercCs&|dkrtd|��d|d|_dS)N)�=rGz.invalid metavar delimiter for long options: %rz%s)r7rD)rrHrrr�set_long_opt_delimiter�s
z$HelpFormatter.set_long_opt_delimitercCs"|j|j7_|jd7_dS)Nr)r=r2r>)rrrr�indent�szHelpFormatter.indentcCs"|j|j8_|jd8_dS)Nr)r=r2r>)rrrr�dedent�szHelpFormatter.dedentcCstd��dS)Nzsubclasses must implement)�NotImplementedError)r�usagerrr�format_usage�szHelpFormatter.format_usagecCstd��dS)Nzsubclasses must implement)rN)r�headingrrr�format_headingszHelpFormatter.format_headingcCs.t|j|jd�}d|j}tj||||d�S)N�rG)�initial_indent�subsequent_indent)r:r8r=�textwrap�fill)r�text�
text_widthrLrrr�_format_texts
zHelpFormatter._format_textcCs|r|�|�dSdSdS)N�
rF)rZ)r�descriptionrrr�format_descriptionsz HelpFormatter.format_descriptioncCs|rd|�|�dSdSdS)Nr[rF)rZ)r�epilogrrr�
format_epilogszHelpFormatter.format_epilogcCsP|jdks|js|jS|jj�|j�}|tks6|dkr<|j}|j�|jt	|��S)N)
r1rA�help�defaults�get�dest�
NO_DEFAULT�NO_DEFAULT_VALUE�replacer%)rr'Z
default_valuerrr�expand_defaultszHelpFormatter.expand_defaultcs�g}�j|}�j�jd}t|�|krBd�jd|f}�j}nd�jd||f}d}|�|�|jr���|�}t�|�j	�}|�d|d|df�|�
�fdd�|dd�D��n|d	d
kr�|�d
�d�|�S)Nr/z%*s%s
rFz	%*s%-*s  rcsg|]}d�jd|f�qS)z%*s%s
rF)r;)�.0�line)rrr�
<listcomp>Esz/HelpFormatter.format_option.<locals>.<listcomp>r���r[)rBr;r=�len�appendr`rgrV�wrapr?�extendr,)rr'�result�optsZ	opt_width�indent_first�	help_text�
help_linesr)rr�
format_option(s$



zHelpFormatter.format_optioncCs�|��d}x6|jD],}|�|�}||j|<t|t|�|j�}qW|��xF|jD]<}x6|jD],}|�|�}||j|<t|t|�|j�}q`WqTW|��|��t	|d|j
�|_t|j|jd�|_
dS)Nrr/rS)rL�option_list�format_option_stringsrBr:rlr=�
option_groupsrMr9r<r;r8r?)rr1Zmax_len�opt�strings�grouprrr�store_option_stringsKs 



z"HelpFormatter.store_option_stringscst|��rF|jp|j�����fdd�|jD�}��fdd�|jD�}n|j}|j}�jrb||}n||}d�|�S)Ncsg|]}�j|�f�qSr)rC)rhZsopt)�metavarrrrrjasz7HelpFormatter.format_option_strings.<locals>.<listcomp>csg|]}�j|�f�qSr)rD)rhZlopt)r}rrrrjcsz, )�takes_valuer}rc�upper�_short_opts�
_long_optsr@r,)rr'Z
short_optsZ	long_optsrqr)r}rrrw]s

z#HelpFormatter.format_option_stringsN)rr#r$rer!rErIrKrLrMrPrRrZr]r_rgrur|rwrrrrr	�s +
#c@s&eZdZddd�Zdd�Zd	d
�ZdS)r
r/�NrcCst�|||||�dS)N)r	r!)rr2r<r8r@rrrr!tszIndentedHelpFormatter.__init__cCstd�|S)Nz
Usage: %s
)r))rrOrrrrP|sz"IndentedHelpFormatter.format_usagecCsd|jd|fS)Nz%*s%s:
rF)r=)rrQrrrrRsz$IndentedHelpFormatter.format_heading)r/r�Nr)rr#r$r!rPrRrrrrr
ps
c@s&eZdZd
dd�Zdd�Zdd	�ZdS)rrr�NcCst�|||||�dS)N)r	r!)rr2r<r8r@rrrr!�szTitledHelpFormatter.__init__cCsd|�td��|fS)Nz%s  %s
ZUsage)rRr))rrOrrrrP�sz TitledHelpFormatter.format_usagecCsd|d|jt|�fS)Nz%s
%s
z=-)r>rl)rrQrrrrR�sz"TitledHelpFormatter.format_heading)rr�Nr)rr#r$r!rPrRrrrrr�s
cCsh|dd���dkrd}nD|dd���dkrDd}|dd�p@d}n|dd�dkrZd}nd}|||�S)	Nr/�0x�Z0b�0r��
)�lower)�val�type�radixrrr�
_parse_num�sr�cCs
t|t�S)N)r�r3)r�rrr�
_parse_int�sr�Zintegerzfloating-point�complex)r3�long�floatr�cCsFt|j\}}y||�Stk
r@ttd�|||f��YnXdS)Nzoption %s: invalid %s value: %r)�_builtin_cvtr�r7rr))r'ry�valueZcvtZwhatrrr�
check_builtin�sr�cCs:||jkr|Sd�tt|j��}ttd�|||f��dS)Nz, z.option %s: invalid choice: %r (choose from %s))�choicesr,�map�reprrr))r'ryr�r�rrrr�s
)ZNOZDEFAULTc@s�eZdZddddddddd	d
ddgZd
ZdZdZdZdZdZ	e
e
e
e
ed�ZdZ
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZeeeeeeegZ
d+d,�ZeZd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Z d7d8�Z!dS)9r�actionr�rc�default�nargs�constr��callback�
callback_args�callback_kwargsr`r})
�store�store_const�
store_true�store_falserm�append_const�countr�r`�version)r�r�r�r�rmr�r�)r�rmr�)r�rm)r�r�)�stringr3r�r�r��choice)r3r�r�r�r�NcOsFg|_g|_|�|�}|�|�|�|�x|jD]}||�q2WdS)N)r�r��_check_opt_strings�_set_opt_strings�
_set_attrs�
CHECK_METHODS)rrq�attrs�checkerrrrr!4s


zOption.__init__cCsdd�|D�}|std��|S)NcSsg|]}|r|�qSrr)rhryrrrrjKsz-Option._check_opt_strings.<locals>.<listcomp>z+at least one option string must be supplied)�	TypeError)rrqrrrr�GszOption._check_opt_stringscCs�x�|D]�}t|�dkr&td||��qt|�dkrf|ddkrJ|ddksXtd||��|j�|�q|dd�dkr�|ddks�td||��|j�|�qWdS)	Nr/z>invalid option string %r: must be at least two characters longr�-rzMinvalid short option string %r: must be of the form -x, (x any non-dash char)z--zGinvalid long option string %r: must start with --, followed by non-dash)rlr
r�rmr�)rrqryrrrr�Ps$
zOption._set_opt_stringscCszxP|jD]F}||kr,t||||�||=q|dkrBt||t�qt||d�qW|rvt|���}tdd�|�|��dS)Nr�zinvalid keyword arguments: %sz, )�ATTRS�setattrrd�sorted�keysr
r,)rr��attrrrrr�eszOption._set_attrscCs2|jdkrd|_n|j|jkr.td|j|��dS)Nr�zinvalid action: %r)r��ACTIONSr
)rrrr�
_check_actionxs
zOption._check_actioncCs�|jdkr0|j|jkr�|jdk	r(d|_q�d|_n^t|jt�rF|jj|_|jdkrVd|_|j|jkrrtd|j|��|j|jkr�td|j|��dS)Nr�r�r%zinvalid option type: %rz$must not supply a type for action %r)	r�r��ALWAYS_TYPED_ACTIONSr��
isinstancer�TYPESr
�
TYPED_ACTIONS)rrrr�_check_type~s



zOption._check_typecCsr|jdkrT|jdkr td|��qnt|jttf�sntdtt|j���d�d|��n|jdk	rntd|j|��dS)Nr�z/must supply a list of choices for type 'choice'z1choices must be a list of strings ('%s' supplied)�'rz#must not supply choices for type %r)r�r�r
r��tuple�listr%�split)rrrr�
_check_choice�s


 
zOption._check_choicecCs\|j|jkp|jdk	}|jdkrX|rX|jrH|jddd��dd�|_n|jdd|_dS)Nrr/r�r)r)r��
STORE_ACTIONSr�rcr�rfr�)rr~rrr�_check_dest�s
zOption._check_destcCs*|j|jkr&|jdk	r&td|j|��dS)Nz*'const' must not be supplied for action %r)r��
CONST_ACTIONSr�r
)rrrr�_check_const�szOption._check_constcCs<|j|jkr|jdkr8d|_n|jdk	r8td|j|��dS)Nrz*'nargs' must not be supplied for action %r)r�r�r�r
)rrrr�_check_nargs�s

zOption._check_nargscCs�|jdkrrt|j�s$td|j|��|jdk	rJt|jt�sJtd|j|��|jdk	r�t|jt�s�td|j|��nB|jdk	r�td|j|��|jdk	r�td|��|jdk	r�td|��dS)Nr�zcallback not callable: %rz3callback_args, if supplied, must be a tuple: not %rz4callback_kwargs, if supplied, must be a dict: not %rz.callback supplied (%r) for non-callback optionz.callback_args supplied for non-callback optionz0callback_kwargs supplied for non-callback option)	r��callabler�r
r�r�r�r��dict)rrrr�_check_callback�s0






zOption._check_callbackcCsd�|j|j�S)N�/)r,r�r�)rrrrr"�szOption.__str__cCs
|jdk	S)N)r�)rrrrr~�szOption.takes_valuecCs|jr|jdS|jdSdS)Nr)r�r�)rrrr�get_opt_string�s
zOption.get_opt_stringcCs*|j�|j�}|dkr|S||||�SdS)N)�TYPE_CHECKERrbr�)rryr�r�rrr�check_value�szOption.check_valuecs:|dk	r6�jdkr���|�St��fdd�|D��SdS)Nrcsg|]}���|��qSr)r�)rh�v)ryrrrrjsz(Option.convert_value.<locals>.<listcomp>)r�r�r�)rryr�r)ryrr�
convert_values
zOption.convert_valuecCs$|�||�}|�|j|j||||�S)N)r��take_actionr�rc)rryr��valuesr1rrr�processszOption.processc	Cs:|dkrt|||��n|dkr2t|||j��n|dkrHt||d�n�|dkr^t||d�n�|dkrz|�|g��|�n�|dkr�|�|g��|j�n�|d	kr�t|||�|d
�d�n||dkr�|jp�d
}|jp�i}|j||||f|�|�nF|dk�r|��|��n*|dk�r(|�	�|��nt
d|j��dS)Nr�r�r�Tr�Frmr�r�rrr�rr`r�zunknown action %r)r�r��ensure_valuermr�r�r��
print_help�exit�
print_versionr7r�)	rr�rcryr�r�r1�args�kwargsrrrr�s4





zOption.take_action)"rr#r$r�r�r�r�r�r�r�r�rr�r�r!r�r�r�r�r�r�r�r�r�r�r"r�__repr__r~r�r�r�r�r�rrrrr�sd
	
		ZSUPPRESSHELPZ
SUPPRESSUSAGEc@s^eZdZddd�Zdd�ZeZdd�Zdd	�Zd
d�Z	dd
�Z
ddd�Zddd�Zdd�Z
dS)rNcCs*|r&x |��D]\}}t|||�qWdS)N)�itemsr�)rrar�r�rrrr!9szValues.__init__cCs
t|j�S)N)r%�__dict__)rrrrr">szValues.__str__cCs2t|t�r|j|jkSt|t�r*|j|kStSdS)N)r�rr�r��NotImplemented)r�otherrrr�__eq__Cs



z
Values.__eq__cCs:x4t|�D](}||kr
||}|dk	r
t|||�q
WdS)N)�dirr�)rr�r�Zdvalrrr�_update_carefulKs
zValues._update_carefulcCs|j�|�dS)N)r��update)rr�rrr�
_update_looseXszValues._update_loosecCs8|dkr|�|�n |dkr(|�|�ntd|��dS)N�carefulZloosezinvalid update mode: %r)r�r�r7)rr��moderrr�_update`s
zValues._updater�cCs&t|�tj|}|�t|�|�dS)N)�
__import__�sys�modulesr��vars)r�modnamer��modrrr�read_modulehs
zValues.read_modulecCs&i}tt|���|�|�||�dS)N)�exec�open�readr�)r�filenamer�r�rrr�	read_filemszValues.read_filecCs.t||�rt||�dkr$t|||�t||�S)N)�hasattr�getattrr�)rr�r�rrrr�rszValues.ensure_value)N)r�)r�)rr#r$r!r"rr�r�r�r�r�r�r�r�rrrrr7s



c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"rcCs&|��||_|�|�|�|�dS)N)�_create_option_list�option_class�set_conflict_handler�set_description)rr��conflict_handlerr\rrrr!�s
zOptionContainer.__init__cCsi|_i|_i|_dS)N)�
_short_opt�	_long_optra)rrrr�_create_option_mappings�sz'OptionContainer._create_option_mappingscCs|j|_|j|_|j|_dS)N)r�r�ra)rr1rrr�_share_option_mappings�sz&OptionContainer._share_option_mappingscCs|dkrtd|��||_dS)N)�error�resolvez$invalid conflict_resolution value %r)r7r�)r�handlerrrrr��sz$OptionContainer.set_conflict_handlercCs
||_dS)N)r\)rr\rrrr��szOptionContainer.set_descriptioncCs|jS)N)r\)rrrr�get_description�szOptionContainer.get_descriptioncCs|`|`|`dS)N)r�r�ra)rrrr�destroy�szOptionContainer.destroycCs�g}x,|jD]"}||jkr|�||j|f�qWx,|jD]"}||jkr:|�||j|f�q:W|r�|j}|dkr�tdd�dd�|D��|��nh|dkr�x^|D]V\}}|�d�r�|j�	|�|j|=n|j�	|�|j|=|js�|js�|j
j�	|�q�WdS)Nr�z conflicting option string(s): %sz, cSsg|]}|d�qS)rr)rh�corrrrj�sz3OptionContainer._check_conflict.<locals>.<listcomp>r�z--)r�r�rmr�r�r�rr,�
startswith�remove�	containerrv)rr'Z
conflict_optsryr�Zc_optionrrr�_check_conflict�s.



zOptionContainer._check_conflictcOs�t|dt�r|j||�}n8t|�dkrL|sL|d}t|t�sTtd|��ntd��|�|�|j�|�||_	x|j
D]}||j|<qxWx|jD]}||j
|<q�W|jdk	r�|jtk	r�|j|j|j<n|j|jkr�d|j|j<|S)Nrrznot an Option instance: %rzinvalid arguments)r�r%r�rlrr�rrvrmrr�r�r�r�rcr�rdra)rr�r�r'ryrrr�
add_option�s(



zOptionContainer.add_optioncCsx|D]}|�|�qWdS)N)r)rrvr'rrr�add_optionss
zOptionContainer.add_optionscCs|j�|�p|j�|�S)N)r�rbr�)rr(rrr�
get_optionszOptionContainer.get_optioncCs||jkp||jkS)N)r�r�)rr(rrr�
has_options
zOptionContainer.has_optioncCsv|j�|�}|dkr |j�|�}|dkr4td|��x|jD]}|j|=q<Wx|jD]}|j|=qTW|jj�|�dS)Nzno such option %r)	r�rbr�r7r�r�rrvr)rr(r'ryrrr�
remove_optionszOptionContainer.remove_optioncCsB|js
dSg}x(|jD]}|jtk	r|�|�|��qWd�|�S)NrF)rvr`rrmrur,)r�	formatterrpr'rrr�format_option_helps
z"OptionContainer.format_option_helpcCs|�|���S)N)r]r�)rr
rrrr](sz"OptionContainer.format_descriptioncCs:g}|jr|�|�|��|jr0|�|�|��d�|�S)Nr[)r\rmr]rvrr,)rr
rprrr�format_help+szOptionContainer.format_helpN)rr#r$r!r�r�r�r�r�r�rrrrrr	rr]rrrrrrxs  			c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rNcCs$||_t�||j|j|�||_dS)N)r1rr!r�r��title)rr1r
r\rrrr!6szOptionGroup.__init__cCsg|_|�|j�dS)N)rvr�r1)rrrrr�<szOptionGroup._create_option_listcCs
||_dS)N)r
)rr
rrr�	set_title@szOptionGroup.set_titlecCst�|�|`dS)N)rr�rv)rrrrr�Cs
zOptionGroup.destroycCs0|�|j�}|��|t�||�7}|��|S)N)rRr
rLrrrM)rr
rprrrrJs
zOptionGroup.format_help)N)rr#r$r!r�rr�rrrrrr4s

c
@s^eZdZgZddedddddddf
dd�Zdd�Zdd	�Zd
d�Zdd
�Z	dOdd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�ZdPd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdQd;d<�Z d=d>�Z!d?d@�Z"dRdAdB�Z#dCdD�Z$dSdEdF�Z%dTdGdH�Z&dIdJ�Z'dUdKdL�Z(dVdMdN�Z)dS)WrNr�TcCsrt�||||�|�|�|	|_||_d|_d|_|dkr@t�}||_|j�	|�|
|_
|j||d�|��dS)NT)�add_help)
rr!�	set_usage�progr��allow_interspersed_args�process_default_valuesr
r
rEr^�_populate_option_list�_init_parsing_state)rrOrvr�r�r�r\r
Zadd_help_optionrr^rrrr!�s
zOptionParser.__init__cCs2t�|�x|jD]}|��qW|`|`|`dS)N)rr�rxrvr
)rr{rrrr��s
zOptionParser.destroycCsg|_g|_|��dS)N)rvrxr�)rrrrr��sz OptionParser._create_option_listcCs|jdddtd�d�dS)Nz-hz--helpr`zshow this help message and exit)r�r`)rr))rrrr�_add_help_option�szOptionParser._add_help_optioncCs|jddtd�d�dS)Nz	--versionr�z&show program's version number and exit)r�r`)rr))rrrr�_add_version_option�sz OptionParser._add_version_optioncCs>|jr|�|j�|r |�|�|jr.|��|r:|��dS)N)�standard_option_listrr�rr)rrvrrrrr�s
z"OptionParser._populate_option_listcCsd|_d|_d|_dS)N)�rargs�largsr�)rrrrr�sz OptionParser._init_parsing_statecCsL|dkrtd�|_n4|tkr$d|_n$|���d�rB|dd�|_n||_dS)Nz%prog [options]zusage: �)r)rOrr�r)rrOrrrr�szOptionParser.set_usagecCs
d|_dS)NT)r)rrrr�enable_interspersed_args�sz%OptionParser.enable_interspersed_argscCs
d|_dS)NF)r)rrrr�disable_interspersed_argssz&OptionParser.disable_interspersed_argscCs
||_dS)N)r)rr�rrr�set_process_default_valuessz'OptionParser.set_process_default_valuescCs||j|<dS)N)ra)rrcr�rrr�set_defaultszOptionParser.set_defaultcKs|j�|�dS)N)rar�)rr�rrr�set_defaultsszOptionParser.set_defaultscCs.|jdd�}x|jD]}|�|j�qW|S)N)rvrxro)r�optionsr{rrr�_get_all_optionsszOptionParser._get_all_optionscCsd|jst|j�S|j��}x@|��D]4}|�|j�}t|t�r$|�	�}|�
||�||j<q$Wt|�S)N)rrra�copyr"rbrcr�r%r�r�)rrar'r�r(rrr�get_default_valuess


zOptionParser.get_default_valuescOszt|dt�r t|f|�|�}nJt|�dkrb|sb|d}t|t�sNtd|��|j|k	rjtd��ntd��|j�|�|S)Nrrznot an OptionGroup instance: %rz"invalid OptionGroup (wrong parser)zinvalid arguments)	r�r%rrlr�r1r7rxrm)rr�r�r{rrr�add_option_group+s


zOptionParser.add_option_groupcCs0|j�|�p|j�|�}|r,|j|k	r,|jSdS)N)r�rbr�r)rr(r'rrr�get_option_group;s
zOptionParser.get_option_groupcCs&|dkrtjdd�S|dd�SdS)Nr)r��argv)rr�rrr�	_get_argsEszOptionParser._get_argsc
Cs�|�|�}|dkr|��}||_g|_}||_y|�|||�}Wn4ttfk
rv}z|�t	|��Wdd}~XYnX||}|�
||�S)N)r(r$rrr��
_process_argsrrr�r%�check_values)rr�r�rr�stop�errrrr�
parse_argsKs

 zOptionParser.parse_argscCs||fS)Nr)rr�r�rrrr*rszOptionParser.check_valuescCs�x�|r�|d}|dkr |d=dS|dd�dkr>|�||�q|dd�dkrht|�dkrh|�||�q|jr�|�|�|d=qdSqWdS)Nrz--r/rr�)�_process_long_optrl�_process_short_optsrrm)rrrr��argrrrr)s

zOptionParser._process_argscCst||j�S)N)�
_match_abbrevr�)rryrrr�_match_long_opt�szOptionParser._match_long_optc
Cs�|�d�}d|kr4|�dd�\}}|�d|�d}n|}d}|�|�}|j|}|��r�|j}t|�|kr�|�t	dd|�||d��q�|dkr�|�d�}	q�t
|d|��}	|d|�=n|r�|�td	�|�nd}	|�||	||�dS)
NrrJrTFz.%(option)s option requires %(number)d argumentz/%(option)s option requires %(number)d arguments)r'�numberz%s option does not take a value)
�popr��insertr2r�r~r�rlr�rr�r)r�)
rrr�r0ryZnext_argZhad_explicit_valuer'r�r�rrrr.�s0


zOptionParser._process_long_optcCs�|�d�}d}d}x�|dd�D]�}d|}|j�|�}|d7}|sLt|��|��r�|t|�krx|�d||d��d}|j}	t|�|	kr�|�t	dd|	�||	d��q�|	dkr�|�d�}
q�t
|d|	��}
|d|	�=nd}
|�||
||�|r Pq WdS)	NrFrr�Tz.%(option)s option requires %(number)d argumentz/%(option)s option requires %(number)d arguments)r'r3)r4r�rbrr~rlr5r�r�rr�r�)rrr�r0r+�iZchryr'r�r�rrrr/�s6
z OptionParser._process_short_optscCs&|jdkrtj�tjd�S|jSdS)Nr)rr4�path�basenamer�r')rrrr�
get_prog_names
zOptionParser.get_prog_namecCs|�d|���S)Nz%prog)rfr9)r�srrr�expand_prog_nameszOptionParser.expand_prog_namecCs|�|j�S)N)r;r\)rrrrr�szOptionParser.get_descriptionrcCs|rtj�|�t�|�dS)N)r��stderr�writer�)r�statusr rrrr�szOptionParser.exitcCs(|�tj�|�dd|��|f�dS)Nr/z%s: error: %s
)�print_usager�r<r�r9)rr rrrr�szOptionParser.errorcCs"|jr|j�|�|j��SdSdS)NrF)rOr
rPr;)rrrr�	get_usage#szOptionParser.get_usagecCs|jrt|��|d�dS)N)�file)rO�printr@)rrArrrr?*s	zOptionParser.print_usagecCs|jr|�|j�SdSdS)NrF)r�r;)rrrr�get_version6szOptionParser.get_versioncCs|jrt|��|d�dS)N)rA)r�rBrC)rrArrrr�<szOptionParser.print_versioncCs�|dkr|j}|�|�g}|�|�td���|��|jrZ|�t�||��|�d�x(|j	D]}|�|�
|��|�d�qbW|��d�|dd��S)NZOptionsr[rFrk)
r
r|rmrRr)rLrvrrrxrrMr,)rr
rpr{rrrrGs

zOptionParser.format_option_helpcCs|�|j�S)N)r_r^)rr
rrrr_XszOptionParser.format_epilogcCsn|dkr|j}g}|jr*|�|��d�|jrD|�|�|�d�|�|�|��|�|�|��d�|�S)Nr[rF)	r
rOrmr@r\r]rr_r,)rr
rprrrr[szOptionParser.format_helpcCs |dkrtj}|�|���dS)N)r��stdoutr=r)rrArrrr�gszOptionParser.print_help)T)NN)rN)N)N)N)N)N)*rr#r$rrr!r�r�rrrrrrrrrr r"r$r%r&r(r-r*r)r2r.r/r9r;r�r�r�r@r?rCr�rr_rr�rrrrrRs^F

	

'
3	$)





csZ�|kr�S�fdd�|��D�}t|�dkr6|dS|sDt���n|��t�|��dS)Ncsg|]}|���r|�qSr)r)rhZword)r:rrrj�sz!_match_abbrev.<locals>.<listcomp>rr)r�rlr�sortr*)r:Zwordmapr+r)r:rr1ts
r1)&�__version__�__all__Z
__copyright__r�r4rVrrr�ImportErrorr)�	Exceptionrr
rrrr*r	r
rr�r�r�r�r�r�rrdrrrrrrrr1rrrrr�<module>s| 


P



uA=&