grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a j£aã@sžddlmZddlmZddlmZddlZddlZddlZddl Zddl Zddl Z ddl Z ddlZddlZe  d¡ZGdd„dejƒZGdd „d ejƒZdS) é)Úunicode_literals)Ú_©Ú _parse_specsNÚdnfcseZdZ‡fdd„Z‡ZS)ÚMultilineHelpFormattercs"d|vr| ¡Stt|ƒ ||¡S)NÚ )Ú splitlinesÚsuperrÚ _split_lines)ÚselfÚtextÚwidth©Ú __class__©ú9/usr/lib/python3.9/site-packages/dnf/cli/option_parser.pyr 'sz#MultilineHelpFormatter._split_lines)Ú__name__Ú __module__Ú __qualname__r Ú __classcell__rrrrr&srcseZdZdZd.‡fdd„ Zdd„ZGdd„dejƒZGd d „d ejƒZ Gd d „d ej ƒZ Gd d„dejƒZ Gdd„dejƒZ Gdd„dejƒZGdd„dejƒZGdd„dejƒZdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd/‡fd*d+„ Zd0‡fd,d-„ Z‡ZS)1Ú OptionParserz5ArgumentParser like class to do things the "yum way".Tcs>tt|ƒjdtd�d|_d|_| ¡|r:i|_tƒ|_ dS)NF)Úadd_helpÚformatter_class) r rÚ__init__rÚcommand_positional_parserÚ command_groupÚ_add_general_optionsÚ _cmd_usageÚsetÚ _cmd_groups)r Z reset_usagerrrr/s ÿzOptionParser.__init__cCs&| ¡t tdƒ|¡t d¡dS)zØOutput an error message, and exit the program. This method overrides standard argparser's error so that error output goes to the logger. :param msg: the error message to output zCommand line error: %séN)Ú print_usageÚloggerZcriticalrÚsysÚexit)r ÚmsgrrrÚerror9szOptionParser.errorc@seZdZdd„ZdS)zOptionParser._RepoCallbackcs@|dkr dnd‰t||jƒ}| ‡fdd„t d|¡Dƒ¡dS)Nú --disablerepoÚdisableÚenablec3s|]}|ˆfVqdS©Nr)Ú.0Úx©Z operationrrÚ Hóz6OptionParser._RepoCallback.__call__..ú \s*[,\s]\s*)ÚgetattrÚdestÚextendÚreÚsplit)r ÚparserÚ namespaceÚvaluesÚopt_strÚlrr.rÚ__call__Es z#OptionParser._RepoCallback.__call__N©rrrr<rrrrÚ _RepoCallbackDsr>c@seZdZdd„ZdS)z OptionParser._RepoCallbackEnablecCs$|j |ddf¡t|d|ƒdS)Nrr*Zreponame)Úrepos_edÚappendÚsetattr©r r7r8r9r:rrrr<Ksz)OptionParser._RepoCallbackEnable.__call__Nr=rrrrÚ_RepoCallbackEnableJsrCcs$eZdZdZdZ‡fdd„Z‡ZS)zOptionParser._SplitCallbackzN Split all strings in seq, at "," and whitespace. Returns a new list. r1cs@d}t |j|¡D](}|s|r6ttj|ƒ ||||¡d}qdS)NTF)r5r6ÚSPLITTERr rÚ_SplitCallbackr<)r r7r8r9r:ÚfirstÚvalrrrr<Tsÿÿz$OptionParser._SplitCallback.__call__)rrrÚ__doc__rDr<rrrrrrEOsrEc@seZdZdZdd„ZdS)z%OptionParser._SplitExtendDictCallbackz[ Split string at "," or whitespace to (key, value). Extends dict with {key: value}.c Csbz| d¡\}}|r|st‚Wn*tyHtdƒ|}t ||¡‚Yn0t||jƒ}|||<dS)Nú,zbad format: %s)r6Ú ValueErrorrÚargparseÚ ArgumentErrorr2r3) r r7r8r9r:ÚkeyrGr&Zdctrrrr<bs   z.OptionParser._SplitExtendDictCallback.__call__N©rrrrHr<rrrrÚ_SplitExtendDictCallback_srOc@seZdZdZdd„ZdS)zOptionParser._SetoptsCallbackzY Parse setopts arguments and put them into main_ and repo_.c Cs| d¡}t|ƒdkr*t tdƒ|¡dSt|ƒdkrJt tdƒ|¡dS|\}}| d¡}|dkrÄ|d|…} ||dd…}t|dƒr’|j} ni} |  | i¡ |g¡  |¡t |d |j | ƒn:t|d ƒrÖ|j } ni} |  |g¡  |¡t |d |j | ƒdS) Nú=éz'Setopt argument has multiple values: %sz Setopt argument has no value: %sÚ.éÿÿÿÿr!Ú repo_setoptsZrepo_Ú main_setoptsZmain_) r6Úlenr#ZwarningrÚrfindÚhasattrrTÚ setdefaultr@rAr3rU) r r7r8r9r:ZvalsÚkÚvZperiodÚrepoZrepooptsZmainoptsrrrr<ps,       z&OptionParser._SetoptsCallback.__call__NrNrrrrÚ_SetoptsCallbackmsr]c@seZdZdd„ZdS)z'OptionParser.ParseSpecGroupFileCallbackcCst||ƒdSr+rrBrrrr<Œsz0OptionParser.ParseSpecGroupFileCallback.__call__Nr=rrrrÚParseSpecGroupFileCallback‹sr^cs$eZdZ‡fdd„Zdd„Z‡ZS)zOptionParser.PkgNarrowCallbackc s†i|_z"dD]}|||j|<||=q Wn8ty`}z td|jj|fƒ‚WYd}~n d}~00g|d<ttj|ƒj|i|¤ŽdS)N)ÚchoicesÚdefaultz"%s() missing mandatory argument %sr`) Ú pkgnarrowÚKeyErrorÚ TypeErrorrrr rÚPkgNarrowCallbackr)r ÚargsÚkwargsrZÚerrrr�s  ÿz'OptionParser.PkgNarrowCallback.__init__cCsT|jd}|r |d|jdvr,|jd}n | d¡}t|||ƒt||j|ƒdS)NÚ_actionrr_r`)r3raÚpoprA)r r7r8r9r:Z dest_actionZnarrowrrrr<œs     z'OptionParser.PkgNarrowCallback.__call__)rrrrr<rrrrrrd�s rdc@seZdZdd„ZdS)zOptionParser.ForceArchActioncCsd|_||_dS)NT)Z ignorearchZarchrBrrrr<¦sz%OptionParser.ForceArchAction.__call__Nr=rrrrÚForceArchAction¥srjc CsÀ| tdjtjjd�ƒ¡}|jdddddtdƒd �|jd d d d dtdƒd�|jddd dtdƒd�|jdd dtdƒjtjjd�d�|jdtdƒdd�|jdddgdtdƒd�|jd d!dd"td#ƒd$�|jd%d&g|jtd'ƒd(d)�|jd*d+g|jtd,ƒd(d)�|jd-dtd.ƒd/�|jd0dtd1ƒd/�|jd2dtd3ƒd/�|jd4d5g|jtd6ƒd7�|jd8d9d dtd:ƒd�|jd;dtd?ƒd@�|jdAd dtdBƒd�|  ¡}|jdCdDd dEdtdFƒdG�|jdHd!dEtdIƒd@�|jdJdKdLd dtdMƒd�|jdNdOdPt ddQtdRƒdS�|jdTdUdVdWdtdXƒt dY�|jdZd dtd[ƒd�|jd\d]d dtd^ƒd�|jd_d`dt tdaƒdb�|jdcdddd tdeƒjtjj d�df�|jdgdtdhƒdidj�|jdkdld dtdmƒd�|jdnd dtdoƒd�|jdp|j dqgdrtdsƒdt�|  ¡}|jdu|j dqgdrtdvƒdt�|jdwdxdrdy|jgtdzƒd{�|  ¡}|jd|d}d~d tdƒdf�|jd€d}d�d td‚ƒdf�|jdƒd„d…gd†|jtd‡ƒdˆd‰�|jdŠd‹gdŒ|jtd�ƒdŽd‰�|jd�i|j d�td‘ƒd’�|jd“d!dd”td•ƒd$�|jd–d!dd—td˜ƒd$�|jd™dšdtd›ƒdœ�|jd�džd tdŸƒd �|jd¡d¢dtd£ƒdd¤d¥�|jd¦d¢dtd§ƒdd¨d¥�|jd©dªd«dtd¬ƒdœ�|jd­d®d d}td¯ƒd�|jd°d±dd²dtd³ƒd´�|jdµd¶dtd·ƒdœ�|jd¸d td¹ƒdº�|jd»d td¼ƒdº�|jd½d td¾ƒdº�|jd¿d tdÀƒdº�|jdÁdÂdÃg|jtdăd7�|jdÅdÆgdÇ|jtdȃdf�|jdÉdÊgdË|jtd̃df�|jdÍdÎgdÏ¢gdÐ|jtdуdÒ�|jdÓdÔtj|jttjj ¡ƒtdÕƒdÖ�|jd×dØtjdÙ�dS)Úz0 Standard options known to all dnf subcommands. zGeneral {prog} options)Úprogz-cz--configZconfig_file_pathNZ CONFIG_FILEzconfig file location)r3r`ÚmetavarÚhelpz-qz--quietÚquietÚ store_truezquiet operation)r3Úactionr`rmz-vz --verbosezverbose operation)rpr`rmz --versionzshow {prog} version and exitz --installrootzset install rootÚPATH)rmrlz--nodocsÚ store_constZnodocsZtsflagszdo not install documentations)rpÚconstr3rmz --nopluginsÚ store_falseZpluginszdisable all plugins)rpr`r3rmz--enablepluginZ enablepluginzenable plugins by nameZPLUGIN)r3r`rprmrlz--disablepluginZ disablepluginzdisable plugins by namez --releaseverz:override the value of $releasever in config and repo files)r`rmz--releasever-majorz@override the value of $releasever_major in config and repo filesz--releasever-minorz@override the value of $releasever_minor in config and repo filesz--setoptZsetoptsz%set arbitrary config and repo options)r3r`rprmz --skip-brokenZ skip_brokenz.resolve depsolve problems by skipping packagesz-hz--helpz --help-cmdrmzshow command help)rpr3rmz--allowerasingz;allow erasing of installed packages to resolve dependenciesz-bz--bestZbestz8try the best available package versions in transactions.)rpr3r`rmz--nobestz2do not limit the transaction to the best candidatez-Cz --cacheonlyZ cacheonlyz2run entirely from system cache, don't update cachez-Rz --randomwaitZ sleeptimeZMINUTESzmaximum command wait time)r3Útyper`rlrmz-dz --debuglevelZ debuglevelZ DEBUG_LEVELzdebugging output level)r3rlr`rmruz --debugsolverz)dumps detailed solving results into filesz--showduplicatesZshowdupesfromreposz2show duplicates, in repos, in list/search commandsz-ez --errorlevelzerror output level)r`rurmz --obsoletesZ obsoletesz‡enables {prog}'s obsoletes processing logic for upgrade or display capabilities that the package obsoletes for info, list and repoquery)r`r3rprmz--rpmverbosityzdebugging output level for rpmZDEBUG_LEVEL_NAME)r`rmrlz-yz --assumeyesz*automatically answer yes for all questionsz --assumenoz)automatically answer no for all questionsz --enablerepor?ZREPOz¸Temporarily enable repositories for the purpose of the current dnf command. Accepts an id, a comma-separated list of ids, or a glob of ids. This option can be specified multiple times.)rpr3r`rlrmr(zéTemporarily disable active repositories for the purpose of the current dnf command. Accepts an id, a comma-separated list of ids, or a glob of ids. This option can be specified multiple times, but is mutually exclusive with `--repo`.z--repoz--repoidr\zUenable just specific repositories by an id or a glob, can be specified multiple times)rlr3rpr`rmz--enableFZ set_enabledz>enable repos with config-manager command (automatically saves)z --disableZ set_disabledz?disable repos with config-manager command (automatically saves)z-xz --excludez --excludepkgsZ excludepkgsz exclude packages by name or globZPACKAGE)r`r3rprmrlz--disableexcludesz--disableexcludepkgsZdisable_excludeszdisable excludepkgsz{all, main, REPOID}z--repofrompathz REPO,PATHzolabel and path to an additional repository to use (same path as in a baseurl), can be specified multiple times.)r`rprlrmz--noautoremoveZclean_requirements_on_removez7disable removal of dependencies that are no longer usedz --nogpgcheckZgpgcheckz5disable gpg signature checking (if RPM policy allows)z--colorZcolorzcontrol whether color is used)r3r`rmz --refreshZfreshest_metadataz2set metadata as expired before running the command)r3rprmz-4Z ip_resolvezresolve to IPv4 addresses onlyZipv4)r3r`rmrprsz-6zresolve to IPv6 addresses onlyZipv6z --destdirz --downloaddirZdestdirz!set directory to copy packages toz--downloadonlyZ downloadonlyzonly download packagesz --transientZ persistenceZ transientz2Use a transient overlay which will reset on reboot)r3rprsr`rmz --commentZcommentzadd a comment to transactionz--bugfixz,Include bugfix relevant packages, in updates)rprmz --enhancementz1Include enhancement relevant packages, in updatesz --newpackagez0Include newpackage relevant packages, in updatesz --securityz.Include security relevant packages, in updatesz --advisoryz --advisoriesZadvisoryz=Include packages needed to fix the given advisory, in updatesz--bzz--bzsZbugzillaz7Include packages needed to fix the given BZ, in updatesz--cvez--cvesZcvesz8Include packages needed to fix the given CVE, in updatesz--sec-severityz --secseverity)ZCriticalZ ImportantZModerateZLowZseverityzDInclude security relevant packages matching the severity, in updates)r_r`r3rprmz --forcearchZARCHz Force the use of an architecture)rlr3rpr_rmÚcommandú?)Únargsrm)Úadd_argument_grouprÚformatrÚutilZMAIN_PROG_UPPERÚ add_argumentrEr]Úadd_mutually_exclusive_groupÚintÚ MAIN_PROGr>rOrKÚSUPPRESSrjÚsortedZrpmZ _BASEARCH_MAPÚkeys)r Z general_grpZ best_groupZ repo_groupZ enable_grouprrrrªsÀ ÿ  þ þ ÿ ÿÿ ÿÿþýýÿÿÿ þ þ þþÿ ÿ þ þ þþþ ÿ ýþþ ÿÿ þ þ þþþ ýüýþþ ÿþ þ þ ÿþþ ÿÿÿÿÿ þ ÿÿ þÿýüz!OptionParser._add_general_optionscCsHtj |j¡}tj |jd¡}||jvrD||f|j|<|j |¡dS)z- store usage info about a single dnf command.rN)rZi18nZucdÚsummaryÚaliasesrr Úadd)r ÚcmdÚgrouprƒÚnamerrrÚ_add_cmd_usagers  zOptionParser._add_cmd_usagecCs"t| ¡ƒD]}| ||¡q dS)zž store name & summary for dnf commands The stored information is used build usage information grouped by build-in & plugin commands. N)rr9r‰)r Zcli_cmdsr‡r†rrrÚ add_commandszszOptionParser.add_commandscCs‚tdƒtdƒdœ}dtjj}dD]Z}||jvr2q"|d||7}t|j ¡ƒD]*}|j|\}}||krP|d||f7}qPq"|S)z- get the usage information to show the user. zList of Main Commands:zList of Plugin Commands:)ÚmainZpluginz%s [options] COMMAND z %s z %-25s %s )rrr{rr r�rr‚)r ZdescÚusageÚgrprˆr‡rƒrrrÚ get_usageƒsÿ  zOptionParser.get_usagecCs~dtjj|jf|_|j|_tj|jdd�|_ |j |j _ d|j j _ |  d |j ¡¡¡|_|j|j_|j|j_| |j¡dS)Nz%s %sF)rz{} command-specific options)rr{rÚ_basecmdrkrƒÚ descriptionrKÚArgumentParserrr"Ú _positionalsÚtitleryrzÚ capitalizerÚcmd_add_argumentr|Ú_commandZ set_argparser©r rvrrrÚ_add_command_options“s  ÿ  z!OptionParser._add_command_optionscsLt‡fdd„|Dƒƒr6tˆjƒjˆjg|¢Ri|¤ŽSˆjj|i|¤ŽSdS)Ncsg|]}|dˆjv‘qS)r)Ú prefix_chars)r,Úarg©r rrÚ  r0z1OptionParser.cmd_add_argument..)Úallrurr|r)r rerfrr›rr•Ÿs zOptionParser.cmd_add_argumentc Cs^|D]T}z| d¡WqtyV}z(tj tdƒ|t|ƒf¡‚WYd}~qd}~00qdS)Nzutf-8zCannot encode argument '%s': %s)ÚencodeÚUnicodeEncodeErrorrÚ exceptionsZ ConfigErrorrÚstr)r reršrgrrrÚ_check_encoding¥sÿzOptionParser._check_encodingcCs| |¡| |¡\}}|Sr+)r¢Úparse_known_args)r rer8Z _unused_argsrrrÚparse_main_args­s zOptionParser.parse_main_argscCs2| |¡| |¡\}}|j ||¡}||_|jSr+)r˜r£rÚ parse_argsZopts)r rvrer8Z unused_argsrrrÚparse_command_args²s  zOptionParser.parse_command_argsNcs,|jr|j|jj7_tt|ƒ |¡dSr+)rÚ_actionsr rr")r Zfile_rrrr"¹szOptionParser.print_usagecsb|rF|jr|jj|jkr"| |¡|j|jj7_|j |jj¡n |  ¡|_ t t |ƒ  ¡dSr+)rr–r�r˜r§rÚ_action_groupsr@r’rŽrŒr rÚ print_helpr—rrrr©¾s  zOptionParser.print_help)T)N)N)rrrrHrr'rKÚActionr>rCÚ _AppendActionrErOr]r^rdrjrr‰rŠrŽr˜r•r¢r¤r¦r"r©rrrrrr,s.  I  r)Z __future__rZdnf.i18nrZdnf.utilrrKZdnf.exceptionsrZdnf.rpmZ dnf.yum.miscZloggingZos.pathÚosr5r$Z getLoggerr#Ú HelpFormatterrr‘rrrrrÚs