Your IP : 3.147.69.25


Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/optparse.cpython-36.opt-2.pyc

3

��2a���@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�Zd=ZGd3d�d�Zd>Zd?ZGd7d�d�Z Gd8d�d�Z!Gd9d�de!�Z"Gd:d�de!�Z#d;d<�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/python36/lib64/python3.6/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)�AmbiguousOptionErrorcCstj||�||_dS)N)rr!�
possibilities)rr(r+rrrr!�szAmbiguousOptionError.__init__cCstd�|jdj|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	ZnonecCs�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)rFrG)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)rJrG)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|j|�dSdSdS)N�
rF)rZ)r�descriptionrrr�format_descriptionsz HelpFormatter.format_descriptioncCs|rd|j|�dSdSdS)Nr[rF)rZ)r�epilogrrr�
format_epilogszHelpFormatter.format_epilogcCsR|jdks|jr|jS|jjj|j�}|tks8|dkr>|j}|jj|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}|j|�|jr��j|�}tj|�j	�}|jd|d|df�|j
�fdd�|dd�D��n|d
d	kr�|jd	�dj|�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>rr[���)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�|j�d}x6|jD],}|j|�}||j|<t|t|�|j�}qW|j�xF|jD]<}x6|jD],}|j|�}||j|<t|t|�|j�}q`WqTW|j�|j�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|j�rF|jp|jj����fdd�|jD�}��fdd�|jD�}n|j}|j}�jrb||}n||}dj|�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/�NrcCstj|||||�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�NcCstj|||||�dS)N)r	r!)rr2r<r8r@rrrr!�szTitledHelpFormatter.__init__cCsd|jtd��|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�j�dkrd}nD|dd�j�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|Sdjtt|j��}ttd�|||f��dS)Nz, z.option %s: invalid choice: %r (choose from %s))�choicesr,�map�reprrr))r'ryr�r�rrrr�s
�NO�DEFAULTc@s�eZdZddddddddd	d
ddgZdAZdBZdCZdDZdEZdFZ	e
e
e
e
ed�ZdZ
dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�ZeeeeeeegZ
d3d4�ZeZd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dS)Gr�actionr�rc�default�nargs�constr��callback�
callback_args�callback_kwargsr`r}�store�store_const�
store_true�store_falserm�append_const�count�version�stringr3r�r�r��choice)r3r�r�r�r�NcOsFg|_g|_|j|�}|j|�|j|�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|ddkoH|ddksXtd||��|jj|�q|dd�dko�|ddks�td||��|jj|�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|j��}tddj|�|��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��jd�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�jdd�|_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�|jdkrvt|j�s$td|j|��|jdk	rLt|jt�rLtd|j|��|jdk	r�t|jt�r�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_callbackcCsdj|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*|jj|j�}|dkr|S||||�SdS)N)�TYPE_CHECKERrbr�)rryr�r�rrr�check_value�szOption.check_valuecs:|dk	r6�jdkr�j�|�St��fdd�|D��SdS)Nrcsg|]}�j�|��qSr)r�)rh�v)ryrrrrjsz(Option.convert_value.<locals>.<listcomp>)r�r�r�)rryr�r)ryrr�
convert_values
zOption.convert_valuecCs$|j||�}|j|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|j|g�j|�n�|dkr�|j|g�j|j�n�|d	kr�t|||j|d
�d�n||dkr�|jp�f}|jp�i}|j||||f|�|�nF|d
k�r|j�|j�n*|dk�r(|j	�|j�nt
d|j��dS)Nr�r�r�Tr�Frmr�r�rrr�r`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)
r�r�r�r�rmr�r�r�r`r�)r�r�r�r�rmr�r�)r�rmr�)r�rm)r�r�)r�r3r�r�r�r�)"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�s�	
		�SUPPRESSZHELPZUSAGEc@s^eZdZddd�Zdd�ZeZdd�Zdd	�Zd
d�Z	dd
�Z
ddd�Zddd�Zdd�Z
dS)rNcCs*|r&x |j�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|jj|�dS)N)r��update)rr�rrr�
_update_looseXszValues._update_loosecCs8|dkr|j|�n |dkr(|j|�ntd|��dS)N�carefulZloosezinvalid update mode: %r)r�r�r7)rr��moderrr�_update`s
zValues._updater�cCs&t|�tj|}|jt|�|�dS)N)�
__import__�sys�modulesr��vars)r�modnamer��modrrr�read_modulehs
zValues.read_modulecCs&i}tt|�j�|�|j||�dS)N)�exec�open�readr�)r�filenamer�r�rrr�	read_filemszValues.read_filecCs0t||�st||�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&|j�||_|j|�|j|�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)r�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||j|f�qWx,|jD]"}||jkr:|j||j|f�q:W|r�|j}|dkr�tddjdd�|D��|��nh|dkr�x^|D]V\}}|jd�r�|jj	|�|j|=n|jj	|�|j|=|jp�|js�|j
jj	|�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_optsryrZc_optionrrr�_check_conflict�s.



zOptionContainer._check_conflictcOs�t|dt�r|j||�}n:t|�dkrN|rN|d}t|t�sVtd|��ntd��|j|�|jj|�||_	x|j
D]}||j|<qzWx|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]}|j|�qWdS)N)r)rrvr'rrr�add_optionss
zOptionContainer.add_optionscCs|jj|�p|jj|�S)N)r�rbr�)rr(rrr�
get_optionszOptionContainer.get_optioncCs||jkp||jkS)N)r�r�)rr(rrr�
has_options
zOptionContainer.has_optioncCsv|jj|�}|dkr |jj|�}|dkr4td|��x|jD]}|j|=q<Wx|jD]}|j|=qTW|jjj|�dS)Nzno such option %r)	r�rbr�r7r�r�rrvr)rr(r'ryrrr�
remove_optionszOptionContainer.remove_optioncCsB|js
dSg}x(|jD]}|jtk	r|j|j|��qWdj|�S)NrF)rvr`rrmrur,)r�	formatterrpr'rrr�format_option_helps
z"OptionContainer.format_option_helpcCs|j|j��S)N)r]r)rr
rrrr](sz"OptionContainer.format_descriptioncCs:g}|jr|j|j|��|jr0|j|j|��dj|�S)Nr[)r\rmr]rvrr,)rr
rprrr�format_help+szOptionContainer.format_helpN)rr#r$r!r�r�r�r�rrrrr	r
rrrr]rrrrrrxs  			c@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rNcCs$||_tj||j|j|�||_dS)N)r1rr!r�r��title)rr1rr\rrrr!6szOptionGroup.__init__cCsg|_|j|j�dS)N)rvr�r1)rrrrr�<szOptionGroup._create_option_listcCs
||_dS)N)r)rrrrr�	set_title@szOptionGroup.set_titlecCstj|�|`dS)N)rrrv)rrrrrCs
zOptionGroup.destroycCs0|j|j�}|j�|tj||�7}|j�|S)N)rRrrLrrrM)rr
rprrrrJs
zOptionGroup.format_help)N)rr#r$r!r�rrrrrrrr4s

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�TcCsrtj||||�|j|�|	|_||_d|_d|_|dkr@t�}||_|jj	|�|
|_
|j||d�|j�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__cCs2tj|�x|jD]}|j�qW|`|`|`dS)N)rrrxrvr
)rr{rrrr�s
zOptionParser.destroycCsg|_g|_|j�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|j�|r |j|�|jr.|j�|r:|j�dS)N)�standard_option_listr	r�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$|j�jd�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|jj|�dS)N)rar�)rr�rrr�set_defaultsszOptionParser.set_defaultscCs.|jdd�}x|jD]}|j|j�qW|S)N)rvrxro)r�optionsr{rrr�_get_all_optionsszOptionParser._get_all_optionscCsd|jst|j�S|jj�}x@|j�D]4}|j|j�}t|t�r$|j	�}|j
||�||j<q$Wt|�S)N)rrra�copyr%rbrcr�r%r�r�)rrar'r�r(rrr�get_default_valuess


zOptionParser.get_default_valuescOs|t|dt�r t|f|�|�}nLt|�dkrd|rd|d}t|t�sPtd|��|j|k	rltd��ntd��|jj|�|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|jj|�p|jj|�}|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_argscCs�|j|�}|dkr|j�}||_g|_}||_y|j|||�}Wn4ttfk
rv}z|jt	|��WYdd}~XnX||}|j
||�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>|j||�q|dd�dkrht|�dkrh|j||�q|jr�|j|�|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�|jd�}d|kr4|jdd�\}}|jd|�d}n|}d}|j|�}|j|}|j�r�|j}t|�|kr�|jt	dd|�||d��q�|dkr�|jd�}	q�t
|d|��}	|d|�=n|r�|jtd	�|�nd}	|j||	||�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��insertr5r�r~r�rlr�rr�r)r�)
rrr�r3ryZnext_argZhad_explicit_valuer'r�r�rrrr1�s0


zOptionParser._process_long_optcCs�|jd�}d}d}x�|dd�D]�}d|}|jj|�}|d7}|sLt|��|j�r�|t|�krx|jd||d��d}|j}	t|�|	kr�|jt	dd|	�||	d��q�|	dkr�|jd�}
q�t
|d|	��}
|d|	�=nd}
|j||
||�|r Pq WdS)	NrFrr�Tz.%(option)s option requires %(number)d argumentz/%(option)s option requires %(number)d arguments)r'r6)r7r�rbrr~rlr8r�r�rr�r�)rrr�r3r.�iZchryr'r�r�rrrr2�s6
z OptionParser._process_short_optscCs&|jdkrtjjtjd�S|jSdS)Nr)rr4�path�basenamer�r*)rrrr�
get_prog_names
zOptionParser.get_prog_namecCs|jd|j��S)Nz%prog)rfr<)r�srrr�expand_prog_nameszOptionParser.expand_prog_namecCs|j|j�S)N)r>r\)rrrrrszOptionParser.get_descriptionrcCs|rtjj|�tj|�dS)N)r��stderr�writer�)r�statusr rrrr�szOptionParser.exitcCs(|jtj�|jdd|j�|f�dS)Nr/z%s: error: %s
)�print_usager�r?r�r<)rr rrrr�szOptionParser.errorcCs"|jr|jj|j|j��SdSdS)NrF)rOr
rPr>)rrrr�	get_usage#szOptionParser.get_usagecCs|jrt|j�|d�dS)N)�file)rO�printrC)rrDrrrrB*s	zOptionParser.print_usagecCs|jr|j|j�SdSdS)NrF)r�r>)rrrr�get_version6szOptionParser.get_versioncCs|jrt|j�|d�dS)N)rD)r�rErF)rrDrrrr�<szOptionParser.print_versioncCs�|dkr|j}|j|�g}|j|jtd���|j�|jrZ|jtj||��|jd�x(|j	D]}|j|j
|��|jd�qbW|j�dj|dd��S)NZOptionsr[rFrrk)
r
r|rmrRr)rLrvrrrxrrMr,)rr
rpr{rrrrGs

zOptionParser.format_option_helpcCs|j|j�S)N)r_r^)rr
rrrr_XszOptionParser.format_epilogcCsn|dkr|j}g}|jr*|j|j�d�|jrD|j|j|�d�|j|j|��|j|j|��dj|�S)Nr[rF)	r
rOrmrCr\r]rr_r,)rr
rprrrr[szOptionParser.format_helpcCs |dkrtj}|j|j��dS)N)r��stdoutr@r)rrDrrrr�gszOptionParser.print_help)T)NN)rN)N)N)N)N)N)*rr#r$rrr!rr�rrrrrrr r!r"r#r%r'r(r)r+r0r-r,r5r1r2r<r>rr�r�rCrBrFr�rr_rr�rrrrrRs^F

	

'
3	$)





csZ�|kr�S�fdd�|j�D�}t|�dkr6|dS|sDt���n|j�t�|��dS)Ncsg|]}|j��r|�qSr)r)rhZword)r=rrrj�sz!_match_abbrev.<locals>.<listcomp>rr)r�rlr�sortr*)r=Zwordmapr+r)r=rr4ts
r4)r�r�ZSUPPRESSHELPZ
SUPPRESSUSAGE)&�__version__�__all__Z
__copyright__r�r4rVrrr�ImportErrorr)�	Exceptionrr
rrrr*r	r
rr�r�r�r�r�r�rrdrrrrrrrr4rrrrr�<module>s| 


P



uA=&

?>