Mini Shell

Direktori : /lib64/python3.6/site-packages/pyanaconda/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/pyanaconda/__pycache__/argument_parsing.cpython-36.pyc

3

C��eXg�@s�dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZmZmZddlmZee�ZdZdZd	Zd
d�ZGdd
�d
e�Zdd�ZGdd�de �Z!ddd�Z"dS)zkAnaconda is the installation program used by Fedora, Red Hat Enterprise Linux and some other distributions.�N)�ArgumentParser�
ArgumentError�
HelpFormatter�	Namespace�Action)�flags)�KernelArguments)�DisplayModes�	X_TIMEOUT�VIRTIO_PORT)�get_module_logger��PcCs�tj�djd�}|rtSy*tjtjtj	d�}t
tjd|�d�}Wn8t
tfk
r|}ztjd|�td�tSd}~XnXtjd	|�|t}|d
kr�|}nt}|S)z�
    Try to detect the terminal window width size and use it to
    compute optimal help text width. If it can't be detected
    a default values is returned.

    :returns: optimal help text width in number of characters
    :rtype: int
    �Zs390Z1234Zhh�z&Unable to determine terminal width: %sz3terminal size detection failed, using default widthNzdetected window size of %sr)�os�uname�
startswith�DEFAULT_HELP_WIDTH�fcntlZioctl�sys�stdout�termiosZ
TIOCGWINSZ�int�struct�unpack�IOError�
ValueError�log�info�print�debug�
RIGHT_PADDING)Zis_s390�data�columns�e�
help_width�r'�(/usr/lib64/python3.6/argument_parsing.py�get_help_width-s r)csFeZdZdZdd�Z�fdd�Zdd�Zdd	�Zd
�fdd�	Z�Z	S)�AnacondaArgumentParserzG
    Subclass of ArgumentParser that also examines boot arguments.
    csXt��t�|_g|_|jdd�|_|jdd�|_tj|f|�t	�fdd�d�|��dS)	a2
        If the "bootarg_prefix" keyword argument is set, it's assumed that all
        bootargs will start with that prefix.

        "require_prefix" is a bool:
            False: accept the argument with or without the prefix.
            True: ignore the argument without the prefix. (default)
        �bootarg_prefix��require_prefixTcst|t�d�S)N)Zmax_help_position�width)r�LEFT_PADDING)�prog)r&r'r(�<lambda>hsz1AnacondaArgumentParser.__init__.<locals>.<lambda>)�descriptionZformatter_classN)
r)�dict�	_boot_arg�deprecated_bootargs�popr+r-r�__init__�DESCRIPTION)�self�args�kwargsr')r&r(r7Ys	zAnacondaArgumentParser.__init__c	s�dd�|D�}dd�|D�}|jdd�}t�j||�}dd�|jD�}|dd�|D�7}|r�x0|D](}||jkr�td	||��qb||j|<qbW|S)
a�
        Add a new option - like ArgumentParser.add_argument.

        The long options will be added to the list of boot args, unless
        the keyword argument 'bootarg' is set to False.

        Positional arguments that don't start with '-' are considered extra
        boot args to look for.

        NOTE: conflict_handler is currently ignored for boot args - they will
        always raise ArgumentError if they conflict.
        cSsg|]}|jd�r|�qS)�-)r)�.0�ar'r'r(�
<listcomp>zsz7AnacondaArgumentParser.add_argument.<locals>.<listcomp>cSsg|]}|jd�s|�qS)r<)r)r=r>r'r'r(r?{sZbootargTcss$|]}|jd�r|dd�VqdS)z--�N)r)r=�or'r'r(�	<genexpr>sz6AnacondaArgumentParser.add_argument.<locals>.<genexpr>css|]
}|VqdS)Nr')r=�flagr'r'r(rB�szconflicting bootopt string: %s)r6�super�add_argumentZoption_stringsr4r)	r9r:r;r�bootargsZ
do_bootarg�optionZ	long_opts�b)�	__class__r'r(rEls

z#AnacondaArgumentParser.add_argumentcCs~|dks|dkrdS|jr>|j|j�r>d}|t|j�d�}nd}|jj|�}|jr^|r^dS|rz|jrz|rz|jj|�|S)z�
        Find the correct Option for a given bootarg (if one exists)

        :param string arg: boot option

        :returns: argparse option object or None if no suitable option is found
        :rtype argparse option or None
        �version�helpNTF)r+r�lenr4�getr-r5�append)r9�argZprefixed_optionrGr'r'r(�_get_bootarg_option�s	z*AnacondaArgumentParser._get_bootarg_optioncCst�}|dkrtj�}nt|t�r.tj|�}n|}g|_x�|j�D]�\}}|j|�}|dkr^qB|j	dkr�|dkr�t
jd|�qBnr|j	dkr�|jdk	r�|jdkr�|d	kr�t
||jd�qBt
||j|j�qBn(t|�tkr�x|D]}||||�q�WqB||||�qBW|S)
a�
        Parse the boot cmdline and create an appropriate Namespace instance
        according to the option definitions set by add_argument.

        boot_cmdline can be given as a string (to be parsed by KernelArguments), or a
        dict (or any object with .items()) of {bootarg:value} pairs.

        If boot_cmdline is None, the boot_cmdline data will be whatever KernelArguments reads
        by default (/proc/cmdline, /run/initramfs/etc/cmdline, /etc/cmdline).

        If an option requires a value but the boot arg doesn't provide one,
        we'll quietly not set anything in the Namespace. We also skip any boot options
        that were not specified by add_argument as we don't care about them
        (there will usually be quite a lot of them (rd.*, etc.).

        :param boot_cmdline: the Anaconda boot command line arguments
        :type boot_cmdline: string, dict or None

        :returns: an argparse Namespace instance
        :rtype: Namespace
        NrzRboot option specified without expected number of arguments and will be ignored: %sT�0�no�offF)rQrRrS)rrZ
from_defaults�
isinstance�strZfrom_stringr5Z	items_rawrP�nargsrZwarning�const�setattr�dest�type�list)r9�boot_cmdline�	namespacerFrO�valrG�itemr'r'r(�parse_boot_cmdline�s4



z)AnacondaArgumentParser.parse_boot_cmdlineNcs|j|�}t�j||�}|S)a�
        Like ArgumentParser.parse_args(), but also parses the boot cmdline.
        (see parse_boot_cmdline for details on that process.)
        Program cmdline arguments will override boot cmdline arguments.

        :param args: program command line arguments
        :type args: string or None

        :param boot_cmdline: the Anaconda boot command line arguments
        :type boot_cmdline: string, dict or None

        :returns: an argparse Namespace instance
        :rtype: Namespace
        )r`rD�
parse_args)r9r:r\r])rIr'r(ra�s
z!AnacondaArgumentParser.parse_args)NN)
�__name__�
__module__�__qualname__�__doc__r7rErPr`ra�
__classcell__r'r')rIr(r*TsGr*c#s$dd�|D�}dd�|D�}g}g�x�|D]�\}�|dkrBtd��tjj|�}tjj|�sftd|��tjj|�r~td|��||kr�td|��|j|��r�d	�kr�td
����s�tjjtjj|��d���k�r�fdd�t	j
�D�}tt	j�fd
d�|����j���|fVq*WdS)awProcesses and verifies image file specifications. Generates pairs
       of names and paths.

       :param image_specs: a list of image specifications
       :type image_specs: list of str

       Each image spec in image_specs has format <path>[:<name>] where
       <path> is the path to a local file and <name> is an optional
       name used to identify the disk in UI. <name> may not contain colons
       or slashes.

       If no name given in specification, synthesizes name from basename
       of path. Since two distinct paths may have the same basename, handles
       name collisions by synthesizing a different name for the colliding
       name.

       Raises an exception if:
         * A path is empty
         * A path specifies a non-existant file
         * A path specifies a directory
         * Duplicate paths are specified
         * A name contains a "/"
    css|]}|jdd�VqdS)�:rN)�rsplit)r=�specr'r'r(rBsz"name_path_pairs.<locals>.<genexpr>css2|]*}|dt|�dkr$|dj�ndfVqdS)rr@rN)rL�strip)r=Z
image_specr'r'r(rBsr,z#empty path specified for image filez-non-existant path %s specified for image filez*directory path %s specified for image filez&path %s specified twice for image file�/z9improperly formatted image file name %s, includes slashesrc3s|]}d�|fVqdS)z%s_%dNr')r=�n)�namer'r(rB2scs|�kS)Nr')rl)�
names_seenr'r(r13sz!name_path_pairs.<locals>.<lambda>N)
rr�path�abspath�exists�isdirrN�splitext�basename�	itertools�count�next�	dropwhile)Zimage_specsZpath_name_pairsZ
paths_seenro�namesr')rmrnr(�name_path_pairss0


rzc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�HelpTextParserzVClass to parse help text from file and make it available to option
       parser.
    cCs||_d|_dS)zV Initializer
            :param path: The absolute path to the help text file
        N)�_path�
_help_text)r9ror'r'r(r7>szHelpTextParser.__init__ccs~|sdSd}d}g}xTdd�|D�D]B}|dkr6d}q$|r\|rN|dj|�fV|}g}d}q$|j|�q$W|dj|�fVdS)aReads option, help text pairs from a text file.

           Each pair is separated from the next by an empty line.
           The option comes first, followed by any number of lines of help text.

           :param lines: a sequence of lines of text
        NTcss|]}|j�VqdS)N)rj)r=�liner'r'r(rBSsz&HelpTextParser.read.<locals>.<genexpr>r,� F)�joinrN)r9�linesZ
expect_optionrG�textr~r'r'r(�readFs zHelpTextParser.readcCs�|jdkr�i|_y<t|j��(}x |j|�D]\}}||j|<q*WWdQRXWn2tk
r~}ztjd|j|�WYdd}~XnX|jj|d�S)z�
        Returns the help text corresponding to the given command-line option.
        If no help text is available, returns the empty string.

        :param str option: The name of the option

        :rtype: str
        Nz#error reading help text file %s: %sr,)r}�openr|r�rr�errorrM)r9rGr�Z
parsed_optionZparsed_textr%r'r'r(�	help_text`s	
"zHelpTextParser.help_textN)rbrcrdrer7r�r�r'r'r'r(r{9sr{c
	s�tjjdd�}tddd�}ttjj|d��}|jddd	|d
�Gdd�dt�}|jd
dddt	j
t	j
|jd�d�|jddddt	j|jd�d�|jdd|d|jd�d�|jddd|jd�d�|jd d!d"d#|jd$�d%�|jd&d'd(d#|jd)�d%�|jd*d+|jd,�d-�Gd.d/�d/t�}|jd0d1d2||jd1�d3�|jd4d5d6dd|jd6�d7�|jd8d9dd:d;|jd<�d=�|jd>d9d?|jd@�dA�|jdBdCdd|jdC�d7�|jdDdEdd|jdE�d7�|jdFdGt
dHdIdJ�|jdKdLdd|jdM�d7�|jdNdOdPdQdR|jdP�dS�|jdTdPdQdU|jdV�dS�|jdWdXdQdY|jdX�dS�|jdZd[gd\d]|jd^�d_�|jd`dd|jda�db�|jdcdd|jdd�db�|jdedfdQdg|jdh�dS�|jdidjddk|jdl�d�|jdmdd|jdn�db�|jdodp|jdq�d-�|jdrd#ds|jdt�du�|jdvdjdwt
dQdx|jdj�dy�|jdzd{dwttd2|jd{�dy�|jd|d}|jd~�d-�|jdd�|jd��d-�|jd�dd|jd��db�|jd�d�|jd��d-�|jd�d�|jd��d-�|jd�dp|jd��d-�|jd�d�t|jd��d��dd�lm�m�dd�lm}|jd�d�d�||jd��d�G��fd�d��d�t�}|jd�|d�|jd��d�|jd�d�d�d�|jd��d7�|jd�d|jd��d��|jd�dd|jd��db�|jd�d�d�d�|jd��d7�|jd�d|jd��d��|jd�d�d�d�|jd��d7�|jd�d|jd��d��|jd�dd|jd��db�|jd�d�|jd��d-�|jd�dd|jd��db�Gd�d��d�t�}	|jd�|	d�|jd��d�|jd�d�dd|jd��d7�|jd�d�dwt
d�|jd��d��|jd�d]d�gd�|jd��d��|jd�d�tjjd�dă|jdŃdƍ|jd�dd�|jdȃdb�|jd�d�d�|jdʃdˍ|jd�dd|jd̓db�|jd�d�d�d�|jdЃdэ|jd�dd|jdӃdb�|jd�dd|jdՃdb�|jd�d�dd�|jd؃d7�|jd�dd|jdڃdb�|dQk	�r�d�|k�r�|jt	jd܍|S)�z�Return the anaconda argument parser.

       :param str version_string: The version string, e.g. 23.19.5.
       :param KernelArguments boot_cmdline: The boot command line options
       :rtype: AnacondaArgumentParser
    ZANACONDA_DATADIRz/usr/share/anacondazinst.F)r+r-zanaconda_options.txtz	--versionrJz	%(prog)s )�actionrJc@seZdZddd�ZdS)z)getArgumentParser.<locals>.SetCmdlineModeNcSst|dtj�t|dd�dS)N�display_mode�noninteractiveT)rXr	�TUI)r9�parserr]�values�
option_stringr'r'r(�__call__�sz2getArgumentParser.<locals>.SetCmdlineMode.__call__)N)rbrcrdr�r'r'r'r(�SetCmdlineMode�sr�z-Gz--graphicalr��store_constZ	graphical)rYr�rW�defaultrKz-Tz--textr�)rYr�rWrKz-Cz	--cmdlinerZcmdline)r�rVrKz--noninteractiver��
store_true)rYr�rKz	--productZproduct_nameZPRODUCT_NAMEr,�product)rY�metavarr�rKz	--variantZvariant_nameZVARIANT_NAMEZvariantz--proxyZ	PROXY_URL�proxy)r�rKc@seZdZddd�ZdS)z(getArgumentParser.<locals>.SetWaitfornetNcSsPd}yt|�}Wntk
r$YnX|dkr2|}|dkr>d}t||j|�dS)Nr)rrrXrY)r9r�r]r�r��valueZivaluer'r'r(r��sz1getArgumentParser.<locals>.SetWaitfornet.__call__)N)rbrcrdr�r'r'r'r(�
SetWaitfornet�sr�z--waitfornetZ
waitfornetZTIMEOUT_IN_SECONDS)rYr�r�rKz-dz--debugr!)rYr�r�rKz--ksZksfileZ
KICKSTART_URLz/run/install/ks.cfgZks)rYr�r�rWrKz--kickstartZKICKSTART_PATHZ	kickstart)rYr�rKz
--ksstrictZksstrictz--rescueZrescuez
--armplatformZarmPlatformZPLATFORM_IDzThis option is deprecated.)rYrZr�rKz
--multilibZmultiLibZmultilibz-mz--method�methodNZMETHOD)rYr�r�rKz--repoZREPO_URLZrepoz--stage2Zstage2Z
STAGE2_URLz	--addrepoZaddRepozNAME,ADDITIONAL_REPO_URLrNZaddrepo)rYr�r�r�rKz
--noverifysslZnoverifyssl)r�r�rKz
--liveinstZliveinstz--resolutionZrunresZWIDTHxHEIGHTZ
resolutionz--usefbxZxdriverZfbdevZusefbxz--vncZvncz--vncconnectz	HOST:PORTZ
vncconnectz
--vncpasswordZPASSWORDZvncpassword)r�r�rKz	--xdriverZstoreZDRIVER)rYr�rZr�r�rKz
--xtimeoutZxtimeoutz--keymapZKEYMAPZkeymapz--langZLANGZlangz--singlelangZ
singlelangz
--loglevelZLEVELZloglevelz--syslogzHOST[:PORT]Zsyslogz--remotelogZ	remotelogz--virtiologz/dev/virtio-ports/NAMEZ	virtiolog)r�r�rK)�SELINUX_DISABLED�SELINUX_ENFORCING)�SELINUX_DEFAULTz--noselinuxZselinuxZ	noselinuxcseZdZd��fdd�	ZdS)z'getArgumentParser.<locals>.ParseSelinuxNcs*|dkrt||j��nt||j��dS)NrQ)rXrY)r9r�r]r�r�)r�r�r'r(r�sz0getArgumentParser.<locals>.ParseSelinux.__call__)N)rbrcrdr�r')r�r�r'r(�ParseSelinux�sr�z	--selinux�?z	--nompathZmpathZstore_falseTZnompathz--mpath)r�rKz--gptZgptz
--nodmraidZdmraidZnodmraidz--dmraidz--noibftZibftZnoibftz--ibftz--nonibftiscsibootZnonibftiscsibootz--geolocZPROVIDER_IDZgeolocz--geoloc-use-with-kszgeoloc-use-with-ksc@seZdZddd�ZdS)z&getArgumentParser.<locals>.ParseNosaveNcSsrg}|r|jd�}d|kr.dt_dt_dt_n@d|krDdt_dt_nd|krRdt_d|kr`dt_d|krndt_dS)N�,�allTZall_ksZinput_ksZ	output_ksZlogs)�split�flags_instanceZnosave_input_ksZnosave_output_ksZnosave_logs)r9r�r]r�r�Zoptionsr'r'r(r� s 
z/getArgumentParser.<locals>.ParseNosave.__call__)N)rbrcrdr�r'r'r'r(�ParseNosavesr�z--nosaveZnosavez	--nomountZrescue_nomountZnomountz	--updatesZ	updateSrcZUPDATES_URLZupdates)rYr�rZr�rKz--imageZimagesZ
IMAGE_SPECZimage)r�rYr�r�rKz--dirinstallZANACONDA_ROOT_PATHz
/mnt/sysimageZ
dirinstall)rVrWrKz
--memcheckZmemcheckz--nomemcheckZ
nomemcheck)r�rYrKz--leavebootorderZleavebootorderz	--noejectZejectZnoeject)r�rYr�rKz
--extlinuxZextlinuxz--nombrZnombrz--mpathfriendlynamesZmultipath_friendly_namesZmpathfriendlynamesz--kexecZkexecZconsole)r�)r�environrMr*r{ror�rErr	ZGUIr�r�rUrr
rZpykickstart.constantsr�r��pyanaconda.core.constantsr�Zset_defaults)
Zversion_stringr\ZdatadirZapZhelp_parserr�r�r�r�r�r')r�r�r(�getArgumentParserus�
























r�)N)#r8rurrrrr�argparserrrrrZpyanaconda.flagsrr�Zpyanaconda.core.kernelrr�r	r
rZpyanaconda.anaconda_loggersrrbrr/r"rr)r*rz�objectr{r�r'r'r'r(�<module>s*'/7<