<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
ft`l&                 @   s   d dl mZ d dlmZmZ d dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZe	jdZG dd deZG dd dejejZdS )	    )commands)_ucdNdnfc               @   s   e Zd ZdZdZdZdZdS )ShellDemandSheetTN)__name__
__module____qualname__Zavailable_reposZ	resolvingZ	root_userZsack_activation r
   r
   /usr/lib/python3.6/shell.pyr   %   s   r   c               @   s   e Zd Zd*ZedjejjdZ	dddddddd	d
dd
Z
dd Zedd Zdd Zdd Zdd Zdd Zd+ddZd,ddZd-ddZd.d d!Zd"d# Zd/d$d%Zd0d&d'Zd1d(d)ZdS )2ShellCommandshellshzrun an interactive {prog} shell)progrepoquitZts_runtransactionconfigresolvehelp)
r   
repositoryexitr   runtsr   r   
resolvedepr   c             C   s$   t jj| | tjj|  d| _d S )Nz> )r   Command__init__cmdCmdprompt)selfclir
   r
   r   r   =   s    zShellCommand.__init__c             C   s*   | j ddtdtdjtjjdd d S )Nscript?ZSCRIPTzScript to run in {prog} shell)r   )nargsmetavarr   )add_argumentr   formatr   utilMAIN_PROG_UPPER)parserr
   r
   r   set_argparserB   s    zShellCommand.set_argparserc             C   sr   | j j}t | j _xZt|D ]N}|jdr,qyt| j j| W q tk
rh   t| j j|t|| Y qX qW d S )N__)r!   demandsr   dir
startswithgetattrAttributeErrorsetattr)r    Zdefault_demandsattrr
   r
   r   	configureH   s    

zShellCommand.configurec             C   s$   | j jr| j| j j n| j  d S )N)optsr"   _run_scriptZcmdloop)r    r
   r
   r   r   U   s    zShellCommand.runc             C   s    | j j  d | j _| j j  d S )N)baseZ_finalize_base_transaction	fill_sack)r    r
   r
   r   _clean[   s    
zShellCommand._cleanc             C   s`  | s|dkrd S |dkrd}yt j|}W n   | j  d S | jjjdd | jjj|}|jdkrld S |j| jkrt	| d| j|j  |dd   n| jj
j|j}|d k	rT|| j}y| jjj||}W n tk
r   d S X y&tj| jj|j_|j  |j  W n@ tjjk
rP } ztjtd	d
 t|  d S d }~X nX n| j  d S )N
ZEOFr   F)Zreset_usager   r      zError: )shlexsplit_helpr!   	optparserr   Zparse_main_argsZcommandMAPPINGr0   Zcli_commandsgetZparse_command_args
SystemExitcopydeepcopyr-   r4   r   r   
exceptionsErrorloggererrorr   r   )r    lineZs_liner5   Zcmd_clsr   er
   r
   r   onecmd`   s<    
$

zShellCommand.onecmdNc       	      C   s   dd }| st |dkr(| jd d S |d }t |dkrD|d nd }|jd}|d	kr|d | }||d d  }| jjj|}x|D ]}|||| qW |stjtd| n|||| jj	 d S )
Nc             S   sP   |rt || | n:ytdj| t|t|  W n   tjtd Y nX d S )Nz{}: {}zUnsupported key value.)r2   printr'   r0   strrI   warningr   )keyvalconfr
   r
   r   print_or_set   s    z*ShellCommand._config.<locals>.print_or_set   r   r   r<   .zCould not find repository: %s)
lenr@   findr7   reposget_matchingrI   rP   r   rS   )	r    argsrT   rQ   rR   ZperiodZ	repo_namerZ   r   r
   r
   r   _config   s"    	



zShellCommand._configc             C   s   t |trt|dkr|d n|}d}|r|dkrBtdj|}n|dkrZtdj|}nv|dkrrtd	j|}n^|d
krtdj|}nF|dkrtdj|}n.|dkrtdj|}n|dkrtdj|}|s| jjj  td}td|  dS )zOutput help information.

        :param args: the command to output help information about. If
           *args* is an empty, general help will be output.
        r   Nr   z{} 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.r   z{} [command]
    print helpr   r   z{} arg [option]
  list: lists repositories and their status. option = [all | id | glob]
  enable: enable repositories. option = repository id
  disable: disable repositories. option = repository idr   z"{}
    resolve the transaction setr   r   zy{} arg
  list: lists the contents of the transaction
  reset: reset (zero-out) the transaction
  run: run the transactionr   z{}
    run the transactionr   r   z{}
    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;   )r   r   )r   r   )r   r   )	
isinstancelistrX   r   r'   r!   rA   Z
print_helprN   )r    r\   argmsgr
   r
   r   r@      s:    "zShellCommand._helpc             C   s   |r|d nd }|dkr6| j ddj|dd    n|dkr| jjj}d}x\|dd  D ]L}|j|}|r~t||  d	}qZtjt	d
d t	d | jj
jj| qZW |r| jj  d | j_n
| jd d S )Nr   r_   z	repolist r=   r<   enabledisableFTzError:zUnknown repo: '%s'r   )r_   N)rb   rc   )rM   joinr!   r7   rZ   r[   r0   rI   Zcriticalr   outputtermboldr9   Z_compsr@   )r    r\   r   rZ   r9   r   rr
   r
   r   _repo   s"    



zShellCommand._repoc             C   sL   y| j jj| j jj W n. tjjk
rF } zt| W Y d d }~X nX d S )N)	r!   r7   r   r-   Zallow_erasingr   rG   ZDepsolveErrorrN   )r    r\   rL   r
   r
   r   _resolve   s    zShellCommand._resolvec             C   s   yDt |d0}|j }x |D ]}|jds| j| qW W d Q R X W n: tk
r~   tjtd| jj	j
j| tjd Y nX d S )Nrh   #z!Error: Cannot open %s for readingr<   )open	readlinesr/   rM   IOErrorrI   infor   r7   re   rf   rg   sysr   )r    filefdlinesrK   r
   r
   r   r6      s    

zShellCommand._run_scriptc             C   s   |r|d nd }|dkr$| j   d S | j  |d	krZ| jjr| jjj| jj}tj| nz|dkry| jj  W n@ t	j
jk
r } z tjtdd t|  W Y d d }~X nX tjtd | j   n
| jd d S )
Nr   resetr_   r   zError:r=   z	Complete!r   )r_   N)r:   rj   r7   r8   re   Zlist_transactionrI   ro   Zdo_transactionr   rG   rH   rJ   r   r   r@   )r    r\   r   outrL   r
   r
   r   r8   	  s"    ,
zShellCommand._transactionc             C   s   | j dg d S )Nr   )r8   )r    r\   r
   r
   r   _ts_run"  s    zShellCommand._ts_runc             C   s   t jtd tjd d S )NzLeaving Shellr   )rI   ro   r   rp   r   )r    r\   r
   r
   r   _quit%  s    zShellCommand._quit)r   r   )N)N)N)N)N)N)N)r   r   r	   aliasesr   r'   r   r(   r)   ZsummaryrB   r   staticmethodr+   r4   r   r:   rM   r]   r@   ri   rj   r6   r8   rv   rw   r
   r
   r
   r   r   ,   s4   &

;



r   )Zdnf.clir   Zdnf.i18nr   r   Zdnf.utilr   r   rE   Zloggingr>   rp   Z	getLoggerrI   objectr   r   r   r   r
   r
   r
   r   <module>   s   
