Mini Shell

Direktori : /lib/python3.6/site-packages/pykickstart/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/pykickstart/__pycache__/options.cpython-36.opt-1.pyc

3

�
Ld/�@s�dZddlZddlZddlmZmZddlmZmZmZddl	m
Z
mZddlm
Z
mZddlmZdd	�Zd
d�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)a
Specialized option handling.

This module exports three classes:

    ExtendAction - A subclass of Action that appends a list of values to an
                   already existing list.  In this way, it's like the existing
                   "append" action except for lists instead of single values.

    ExtendConstAction - A subclass of Action that appends a list of constants
                        to an already existing list.  In this way, it's like the
                        existing "append_const" action except for lists instead
                        of single values.

    KSOptionParser - A specialized subclass of ArgumentParser to be used
                     in BaseHandler subclasses.

And it exports two functions:

    commaSplit - A function to be used as the type= argument to any arguments
                 that take a single string that may be split on commas, resulting
                 in a list of strings.

    ksboolean - A function to be used as the type= argument to any arguments
                that can take a boolean.
�N)�RawTextHelpFormatter�SUPPRESS)�Action�ArgumentParser�ArgumentTypeError)�KickstartParseError�KickstartDeprecationWarning)�versionToString�versionToLongString)�_cCsttddd�|jd�D���S)NcSsg|]}|j��qS�)�strip)�.0�vrr�/usr/lib/python3.6/options.py�
<listcomp>9szcommaSplit.<locals>.<listcomp>�,)�list�filter�split)�valuerrr�
commaSplit8srcCs^y4|j�dkrdS|j�d
kr"d
Sttd�|��Wn$tk
rXttd�|��YnXdS)N�on�yes�true�1T�off�no�false�0Fzinvalid boolean value: %r)rrrr)rrrr)�lowerrr�AttributeError)rrrr�	ksboolean;sr"cs4eZdZdZ�fdd�Z�fdd�Zdd�Z�ZS)�KSHelpFormatterz.
        Used in generating documentation
    csdtt|�j|||d�j�S)Nz
::

    %s�)�superr#�
_format_usager
)�selfZusageZactions�groups�prefix)�	__class__rrr&Ks
zKSHelpFormatter._format_usagecsntt|�j|�}|j�jd�}g}|jd|dj��x*|dd�D]}|rF|jd|j��qFW|j|�S)N�
z
``%s``
r�z    %s)r%r#�_format_actionr
r�append�lstrip�_join_parts)r'�action�text�partsZ	new_parts�p)r*rrr-RszKSHelpFormatter._format_actioncCsdjdd�|D��S)Nr+cSs"g|]}|r|tk	r|jd��qS)� )r�rstrip)r�partrrrr]sz/KSHelpFormatter._join_parts.<locals>.<listcomp>)�join)r'Zpart_stringsrrrr0\s
zKSHelpFormatter._join_parts)�__name__�
__module__�__qualname__�__doc__r&r-r0�
__classcell__rr)r*rr#Fs
r#c@seZdZddd�ZdS)�ExtendActionNcCs@t||jd�dk	r.t||jt||j�|�nt||j|�dS)N)�getattr�dest�setattr)r'�parser�	namespace�values�
option_stringrrr�__call__cszExtendAction.__call__)N)r9r:r;rFrrrrr>bsr>c@seZdZddd�ZdS)�ExtendConstActionNcCs<t||jd�dk	r(t||j|j|�nt||j|j�dS)N)r?r@rA�const)r'rBrCrDrErrrrFjszExtendConstAction.__call__)N)r9r:r;rFrrrrrGisrGc@sReZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zddd�Z	dd�Z
dd�Zd
S)�KSOptionParserz�A specialized subclass of argparse.ArgumentParser to handle extra option
       attribute checking, work error reporting into the KickstartParseError
       framework, and to turn off the default help.
    cOs�|jd�}t|�}|jdd�}tj|jd��|d<|rJd||df|d<tj|jdd��|d<|jd�|d<tj|jd��|d<tj|jdd��|d<|jd�|d<tj|f|�d	d
td�|��||_d|_dS)
a`Create a new KSOptionParser instance.  Each KickstartCommand
           subclass should create one instance of KSOptionParser, providing
           at least the lineno attribute.  version is not required.

           Instance attributes:

           version -- The version of the kickstart syntax we are checking
                      against.
        �version�
addVersionT�descriptionz
.. versionadded:: %s
%sZepilogr$�progFZresolve)Zadd_helpZconflict_handlerZformatter_classN)	�popr
�textwrap�dedentr�__init__r#rJ�lineno)r'�args�kwargsZint_versionrJrKrrrrQus 
zKSOptionParser.__init__cs4�fdd�}�fdd�}tj�|�}|dks8|ddkr<|S|d}||�r~|jdt|j�t�j�d�}�jtd�|�n�||�r�|jdt|j�t�j�d�}|j�jkrĈjtd	�|�n�jtd
�|�nX|j	dk�s
�j�r0t
|j	�tk�r0�j|j	k�r0�j|jdd�}t
jtd
�|t�|S)Ncs|jo|j�jkS)N)�
introducedrJ)r1)r'rr�
usedTooNew�sz2KSOptionParser._parse_optional.<locals>.usedTooNewcs|jo|j�jkS)N)�removedrJ)r1)r'rr�usedRemoved�sz3KSOptionParser._parse_optional.<locals>.usedRemovedr)�optionZintrorJzrThe %(option)s option was introduced in version %(intro)s, but you are using kickstart syntax version %(version)s.)rYrWrJz-The %(option)s option is no longer supported.zqThe %(option)s option was removed in version %(removed)s, but you are using kickstart syntax version %(version)s.T)rRrYa
Ignoring deprecated option on line %(lineno)s:  The %(option)s option has been deprecated and no longer has any effect.  It may be removed from future releases, which will result in a fatal error from kickstart.  Please modify your kickstart file to remove this option.)r�_parse_optional�option_stringsr	rUrJ�errorrrW�
deprecated�type�intrR�warnings�warnr)r'Z
arg_stringrVrXZoption_tupler1�mappingr)r'rrZ�s(2zKSOptionParser._parse_optionalcOs0|jdd�}|jdd�}|r&t|�}nt|p4|jd��}d}x,|jD]"}x|D]}||jkrN|}PqNWqDW|r�|r�|jpzd}	|	d|7}	|	|d<q�|jp�d}	|	d||jd�f7}	|	|d<n.|jd�}	|	d	|7}	|r�|	d|7}	|	|d<|jd
d�}
|jdd�}tj|f|�|�}||_||_|
|_	||_
|S)NrUr]FrJr$z

    .. deprecated:: %s�helpz 

    .. versionchanged:: %s

%sz

    .. versionadded:: %s�notestrW)rNr
�_actionsr[rcr�add_argumentr]rUrdrW)r'rSrTrUr]rJ�	candidater1�argZ_helprdrWrrrrf�s@








zKSOptionParser.add_argumentcKsjd}x|jD]}||jkr|}PqW|rf|js4d|_|jdt|jd��7_|j|�|jj|�dS)Nr$z

    .. versionremoved:: %srJ)rer[rcr
rNZ_remove_actionZ_option_string_actions)r'rhrTrgr1rrr�remove_argument�s

zKSOptionParser.remove_argumentcCs&|jdk	rt||jd��nt|��dS)N)rR)rRr)r'�messagerrrr\�s
zKSOptionParser.errorrNcCsdS)Nr)r'Zstatusrjrrr�exitszKSOptionParser.exitcOs&d|kr|jd�|_tj|f|�|�S)NrR)rNrRr�
parse_args)r'rSrTrrrrl
szKSOptionParser.parse_argscOs&d|kr|jd�|_tj|f|�|�S)NrR)rNrRr�parse_known_args)r'rSrTrrrrmszKSOptionParser.parse_known_args)rN)r9r:r;r<rQrZrfrir\rkrlrmrrrrrIps.-
rI)r<r`rO�argparserrrrrZpykickstart.errorsrrZpykickstart.versionr	r
Zpykickstart.i18nrrr"r#r>rGrIrrrr�<module>-s