3 ft`l&@sddlmZddlmZmZddlZddlZddlZddlZddl Z ddl Z ddl Z e j dZ GdddeZGdddejejZdS) )commands)_ucdNdnfc@seZdZdZdZdZdZdS)ShellDemandSheetTN)__name__ __module__ __qualname__Zavailable_reposZ resolvingZ root_userZsack_activationr r /usr/lib/python3.6/shell.pyr%src @seZdZd*ZedjejjdZ dddddddd d d d Z d dZ e ddZ ddZddZddZddZd+ddZd,ddZd-ddZd.d d!Zd"d#Zd/d$d%Zd0d&d'Zd1d(d)ZdS)2 ShellCommandshellshzrun an interactive {prog} shell)progrepoquitZts_run transactionconfigresolvehelp) r repositoryexitrruntsrr resolvedeprcCs$tjj||tjj|d|_dS)Nz> )rCommand__init__cmdCmdprompt)selfclir r r r=s zShellCommand.__init__cCs*|jddtdtdjtjjdddS)Nscript?ZSCRIPTzScript to run in {prog} shell)r)nargsmetavarr) add_argumentrformatrutilMAIN_PROG_UPPER)parserr r r set_argparserBszShellCommand.set_argparserc Csr|jj}t|j_xZt|D]N}|jdr,qyt|jj|Wqtk rht|jj|t||YqXqWdS)N__)r!demandsrdir startswithgetattrAttributeErrorsetattr)r Zdefault_demandsattrr r r configureHs  zShellCommand.configurecCs$|jjr|j|jjn|jdS)N)optsr" _run_scriptZcmdloop)r r r r rUszShellCommand.runcCs |jjd|j_|jjdS)N)baseZ_finalize_base _transaction fill_sack)r r r r _clean[s zShellCommand._cleancCs`| s|dkrdS|dkrd}ytj|}Wn|jdS|jjjdd|jjj|}|jdkrldS|j|jkrt |d|j|j|ddn|jj j |j}|dk rT||j}y|jjj ||}Wnt k rdSXy&tj|jj|j_|j|jWn@tjjk rP}ztjtd d t|dSd}~XnXn|jdS) N ZEOFrF)Z reset_usager rzError: )shlexsplit_helpr! optparserrZparse_main_argsZcommandMAPPINGr0Z cli_commandsgetZparse_command_args SystemExitcopydeepcopyr-r4rr exceptionsErrorloggererrorrr)r lineZs_liner5Zcmd_clsrer r r onecmd`s<  $   zShellCommand.onecmdNc Csdd}| st|dkr(|jddS|d}t|dkrD|dnd}|jd}|d kr|d|}||dd}|jjj|}x|D]}||||qW|stjtd|n||||jj dS) Nc SsP|rt|||n:ytdj|t|t|WntjtdYnXdS)Nz{}: {}zUnsupported key value.)r2printr'r0strrIwarningr)keyvalconfr r r print_or_sets z*ShellCommand._config..print_or_setrrr<.zCould not find repository: %s) lenr@findr7repos get_matchingrIrPrrS) r argsrTrQrRZperiodZ repo_namerZrr r r _configs"      zShellCommand._configcCst|trt|dkr|dn|}d}|r|dkrBtdj|}n|dkrZtdj|}nv|dkrrtd j|}n^|d krtd j|}nF|dkrtdj|}n.|dkrtdj|}n|dkrtdj|}|s|jjjtd}td|dS)zOutput 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 shellaShell 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) isinstancelistrXrr'r!rAZ print_helprN)r r\argmsgr r r r@s:"  zShellCommand._helpcCs|r |dnd}|d kr6|jddj|ddn|dkr|jjj}d}x\|ddD]L}|j|}|r~t||d }qZtjt d dt d |jj j j |qZW|r|jj d|j_n |jd dS)Nrr_z repolist r=r<enabledisableFTzError:zUnknown repo: '%s'r)r_N)rbrc)rMjoinr!r7rZr[r0rIZcriticalroutputtermboldr9Z_compsr@)r r\rrZr9rrr r r _repos"     zShellCommand._repocCsLy|jjj|jjjWn.tjjk rF}zt|WYdd}~XnXdS)N) r!r7rr-Z allow_erasingrrGZ DepsolveErrorrN)r r\rLr r r _resolveszShellCommand._resolvecCsyDt|d0}|j}x |D]}|jds|j|qWWdQRXWn:tk r~tjtd|jj j j |t j dYnXdS)Nrh#z!Error: Cannot open %s for readingr<)open readlinesr/rMIOErrorrIinforr7rerfrgsysr)r filefdlinesrKr r r r6s   zShellCommand._run_scriptcCs|r |dnd}|dkr$|jdS|j|d krZ|jjr|jjj|jj}tj|nz|dkry|jjWn@t j j k r}z tj t ddt|WYdd}~XnXtjt d|jn |jddS) Nrresetr_rzError:r=z Complete!r)r_N)r:rjr7r8reZlist_transactionrIroZdo_transactionrrGrHrJrrr@)r r\routrLr r r r8 s" , zShellCommand._transactioncCs|jdgdS)Nr)r8)r r\r r r _ts_run"szShellCommand._ts_runcCstjtdtjddS)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 r r ,s4  &  ;    r )Zdnf.clirZdnf.i18nrrZdnf.utilrrrEZloggingr>rpZ getLoggerrIobjectrrrr r r r r s