ok

Mini Shell

Direktori : /lib/python3.6/site-packages/dnf/cli/commands/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/cli/commands/__pycache__/shell.cpython-36.pyc

3

�ft`l&�@s�ddlmZddlmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZe	jd�Z
Gdd�de�ZGdd�dejej�ZdS)	�)�commands)�_�ucdN�dnfc@seZdZdZdZdZdZdS)�ShellDemandSheetTN)�__name__�
__module__�__qualname__Zavailable_reposZ	resolvingZ	root_userZsack_activation�r
r
�/usr/lib/python3.6/shell.pyr%src@s�eZdZd*Zed�jejjd�Z	dddddddd	d
dd�
Z
d
d�Zedd��Z
dd�Zdd�Zdd�Zdd�Zd+dd�Zd,dd�Zd-dd�Zd.d d!�Zd"d#�Zd/d$d%�Zd0d&d'�Zd1d(d)�ZdS)2�ShellCommand�shell�shzrun an interactive {prog} shell)�prog�repo�quitZts_run�transaction�config�resolve�help)
r�
repository�exitr�run�tsrr�
resolvedeprcCs$tjj||�tjj|�d|_dS)Nz> )r�Command�__init__�cmd�Cmd�prompt)�self�clir
r
rr=szShellCommand.__init__cCs*|jddtd�td�jtjjd�d�dS)N�script�?ZSCRIPTzScript to run in {prog} shell)r)�nargs�metavarr)�add_argumentr�formatr�util�MAIN_PROG_UPPER)�parserr
r
r�
set_argparserBszShellCommand.set_argparserc
Csr|jj}t�|j_xZt|�D]N}|jd�r,qyt|jj|�Wqtk
rht|jj|t||��YqXqWdS)N�__)r!�demandsr�dir�
startswith�getattr�AttributeError�setattr)r Zdefault_demands�attrr
r
r�	configureHs

zShellCommand.configurecCs$|jjr|j|jj�n|j�dS)N)�optsr"�_run_scriptZcmdloop)r r
r
rrUszShellCommand.runcCs |jj�d|j_|jj�dS)N)�baseZ_finalize_base�_transaction�	fill_sack)r r
r
r�_clean[s
zShellCommand._cleancCs`|s|dkrdS|dkrd}ytj|�}Wn|j�dS|jjjdd�|jjj|�}|jdkrldS|j|jkr�t	|d|j|j�|dd��n�|jj
j|j�}|dk	�rT||j�}y|jjj||�}Wnt
k
r�dSXy&tj|jj�|j_|j�|j�Wn@tjjk
�rP}ztjtd	�d
t|��dSd}~XnXn|j�dS)N�
ZEOFrF)Zreset_usager
r�zError:� )�shlex�split�_helpr!�	optparserrZparse_main_argsZcommand�MAPPINGr0Zcli_commands�getZparse_command_args�
SystemExit�copy�deepcopyr-r4rr�
exceptions�Error�logger�errorrr)r �lineZs_liner5Zcmd_clsr�er
r
r�onecmd`s<
$

zShellCommand.onecmdNc	Cs�dd�}|st|�dkr(|jd�dS|d}t|�dkrD|dnd}|jd�}|d	kr�|d|�}||dd�}|jjj|�}x|D]}||||�q�W|s�tjtd�|�n||||jj	�dS)
Nc
SsP|rt|||�n:ytdj|t|t|����Wntjtd��YnXdS)Nz{}: {}zUnsupported key value.)r2�printr'r0�strrI�warningr)�key�val�confr
r
r�print_or_set�sz*ShellCommand._config.<locals>.print_or_set�rrr<�.zCould not find repository: %s���)
�lenr@�findr7�repos�get_matchingrIrPrrS)	r �argsrTrQrRZperiodZ	repo_namerZrr
r
r�_config�s"	



zShellCommand._configcCs�t|t�rt|�dkr|dn|}d}|r�|dkrBtd�j|�}n�|dkrZtd�j|�}nv|dkrrtd	�j|�}n^|d
kr�td�j|�}nF|dkr�td�j|�}n.|dkr�td�j|�}n|dkr�td�j|�}|s�|jjj�td�}td|�dS)z�Output help information.

        :param args: the command to output help information about. If
           *args* is an empty, general help will be output.
        rNrz�{} arg [value]
  arg: debuglevel, errorlevel, obsoletes, gpgcheck, assumeyes, exclude,
        repo_id.gpgcheck, repo_id.exclude
    If no value is given it prints the current value.
    If value is given it sets that value.rz{} [command]
    print helprrz�{} arg [option]
  list: lists repositories and their status. option = [all | id | glob]
  enable: enable repositories. option = repository id
  disable: disable repositories. option = repository idrz"{}
    resolve the transaction setrrzy{} arg
  list: lists the contents of the transaction
  reset: reset (zero-out) the transaction
  run: run the transactionrz{}
    run the transactionrrz{}
    exit the shella�Shell specific arguments:

config                   set config options
help                     print help
repository (or repo)     enable, disable or list repositories
resolvedep               resolve the transaction set
transaction (or ts)      list, reset or run the transaction set
run                      resolve and run the transaction set
exit (or quit)           exit the shellr;)rr)rr)rr)	�
isinstance�listrXrr'r!rAZ
print_helprN)r r\�arg�msgr
r
rr@�s:"zShellCommand._helpcCs�|r|dnd}|d
kr6|jddj|dd���n�|dkr�|jjj}d}x\|dd�D]L}|j|�}|r~t||��d	}qZtjt	d
�dt	d�|jj
jj|��qZW|r�|jj
�d|j_n
|jd�dS)Nrr_z	repolist r=r<�enable�disableFTzError:zUnknown repo: '%s'r)r_N)rbrc)rM�joinr!r7rZr[r0rIZcriticalr�output�term�boldr9Z_compsr@)r r\rrZr9r�rr
r
r�_repo�s"



zShellCommand._repocCsLy|jjj|jjj�Wn.tjjk
rF}zt|�WYdd}~XnXdS)N)	r!r7rr-Z
allow_erasingrrGZ
DepsolveErrorrN)r r\rLr
r
r�_resolve�szShellCommand._resolvecCs�yDt|d��0}|j�}x |D]}|jd�s|j|�qWWdQRXWn:tk
r~tjtd�|jj	j
j|��tj
d�YnXdS)Nrh�#z!Error: Cannot open %s for readingr<)�open�	readlinesr/rM�IOErrorrI�inforr7rerfrg�sysr)r �file�fd�linesrKr
r
rr6�s

zShellCommand._run_scriptcCs�|r|dnd}|dkr$|j�dS|j�|d	krZ|jjr�|jjj|jj�}tj|�nz|dkr�y|jj�Wn@t	j
jk
r�}z tjt
d�dt|��WYdd}~XnXtjt
d��|j�n
|jd�dS)
Nr�resetr_rzError:r=z	Complete!r)r_N)r:rjr7r8reZlist_transactionrIroZdo_transactionrrGrHrJrrr@)r r\r�outrLr
r
rr8	s",
zShellCommand._transactioncCs|jdg�dS)Nr)r8)r r\r
r
r�_ts_run"szShellCommand._ts_runcCstjtd��tjd�dS)Nz
Leaving Shellr)rIrorrpr)r r\r
r
r�_quit%szShellCommand._quit)r
r)N)N)N)N)N)N)N)rrr	�aliasesrr'rr(r)ZsummaryrBr�staticmethodr+r4rr:rMr]r@rirjr6r8rvrwr
r
r
rr,s4
&

;



r)Zdnf.clirZdnf.i18nrrZdnf.utilrrrEZloggingr>rpZ	getLoggerrI�objectrrrrr
r
r
r�<module>s


Zerion Mini Shell 1.0