ó ¾[/\c@@s¨ddlmZddlmZddlmZddlmZmZddlm Z ddl Z ddl Z ddl Z ddlZ ddlZ ddlZ ddlZddlZddlZddlZddlZejjjZejjjZejjjZejjjZejjj Z!ejjj"Z#ejjj$Z%ejjj&Z'ejjj(Z)ej*dƒZ+de,fd „ƒYZ-d e,fd „ƒYZd efd „ƒYZ.defd„ƒYZ/defd„ƒYZ0defd„ƒYZ1defd„ƒYZ2defd„ƒYZ3defd„ƒYZ4defd„ƒYZ5de,fd„ƒYZ6de6fd„ƒYZ7d e6fd!„ƒYZ8d"e6fd#„ƒYZ9dS($i(tabsolute_import(tunicode_literals(tmisc(tucdt_(t basestringNudnftValuecB@s eZdZd„Zd„ZRS(uEValue of an Option consists of an actual value and its priority. cC@s||_||_dS(N(tvaluetpriority(tselfRR((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt__init__7s cC@sd|jj|j|jfS(Nu%s(value=%r, priority=%r)(t __class__t__name__RR(R ((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt__repr__;s (R t __module__t__doc__R R (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR4s tOptioncB@s5eZdZd„Zd„Zd„Zed„ZRS(uˆ This class handles a single configuration file option. Create subclasses for each type of supported configuration option. Each option remembers its default value and can inherit from a parent option (e.g. repo.gpgcheck inherits from main.gpgcheck). Some options can may be runtimeonly which means they are not read from or written to config file. cC@s:t|tjjƒr!||_ntjj|ƒ|_dS(N(t isinstancetlibdnftconfRt_optiont OptionString(R toption((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR Hs cC@s |jjƒS(uGet option's value.(RtgetValue(R ((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_getNscC@s |jjƒS(uGet option's priority.(Rt getPriority(R ((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt _get_priorityRscC@s:|dkr:y|jj||ƒWq6tk r6q6Xnüy²t|tƒs[t|tƒr}|jj|tjj |ƒƒnnt|jtjj ƒs­t|jtjj ƒrØt|t ƒrØ|jj|t |ƒƒn|jj||ƒWnGtk r5}tjjtdƒ|t|ƒfdt|ƒƒ‚nXdS(uRSet option's value if priority is equal or higher than curent priority.uError parsing '%s': %st raw_errorN(tNoneRtsett ExceptionRtlistttupleRRt VectorStringt OptionBooltOptionChildBooltinttboolt RuntimeErrortdnft exceptionst ConfigErrorRtstr(R RRte((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_setVs"  "(R RRR RRt PRIO_RUNTIMER,(((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR@s    t IntOptioncB@seZdd„ZRS(icC@s,tjj|ƒ}tt|ƒj|ƒdS(N(RRtOptionNumberInt32tsuperR.R (R tdefaultR((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR os(R RR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR.nst LongOptioncB@seZdd„ZRS(icC@s,tjj|ƒ}tt|ƒj|ƒdS(N(RRtOptionNumberInt64R0R2R (R R1R((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR us(R RR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR2tst BoolOptioncB@seZed„ZRS(cC@s,tjj|ƒ}tt|ƒj|ƒdS(N(RRR"R0R4R (R R1R((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR {s(R RtFalseR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR4zstSelectionOptioncB@seZdZddd„ZRS(u=Handles string values where only specific values are allowed.cC@s;tjj|tjj|ƒƒ}tt|ƒj|ƒdS(N(RRtOptionEnumStringR!R0R6R (R R1tchoicesR((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR ‚s!N((R RRRR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR6€st ListOptioncB@seZdZdd„ZRS(u=Handles string values where only specific values are allowed.cC@s8tjjtjj|ƒƒ}tt|ƒj|ƒdS(N(RRtOptionStringListR!R0R9R (R R1R((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR ‰sN(R RRRR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR9‡st SecondsOptioncB@seZdd„ZRS(icC@s,tjj|ƒ}tt|ƒj|ƒdS(N(RRt OptionSecondsR0R;R (R R1R((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR s(R RR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR;Žst StringOptioncB@seZdd„ZRS(ucC@s,tjj|ƒ}tt|ƒj|ƒdS(N(RRRR0R=R (R R1R((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR •s(R RR (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR=”st PathOptioncB@seZdeed„ZRS(ucC@s2tjj|||ƒ}tt|ƒj|ƒdS(N(RRt OptionPathR0R>R (R R1texiststabsPathR((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR ›s(R RR5R (((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR>šst BaseConfigcB@sŒeZdZd d d d„Zd„Zd„Zd„Zd„Zd„Z e d„Z e d„Z d „Zd d d „Zed „ƒZRS(ulBase class for storing configuration definitions. Subclass when creating your own definitions. cC@s#||jd<||_||_dS(Nu_config(t__dict__t_sectiont_parser(R tconfigtsectiontparser((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR §s  cC@s–d|jkr-tdj|j|ƒƒ‚nt|j|ƒ}|dkrOdSy|ƒjƒ}Wntk rx}dSXt |t ƒr’t |ƒS|S(Nu_configu!'{}' object has no attribute '{}'( RCtAttributeErrortformatR tgetattrt_configRRRRR*R(R tnameRRtex((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt __getattr__¬s  cC@sžt|j|dƒ}|dkr:tt|ƒj||ƒSt|tƒr^|j}|j }nt }|dkržy|ƒj ||ƒWqšt k ršqšXnüy²t|t ƒs¿t|tƒrá|ƒj |tjj|ƒƒnnt|ƒtjjƒst|ƒtjjƒr<t|tƒr<|ƒj |t|ƒƒn|ƒj ||ƒWnGtk r™}tjjtdƒ|t|ƒfdt|ƒƒ‚nXdS(NuError parsing '%s': %sR(RKRLRR0RBt __setattr__RRRRR-RRRR RRR!R"R#R$R%R&R'R(R)RR*(R RMRRRR+((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyRPºs.     "'cC@s”g}|jd|jƒ|jr‡xa|jjƒD]M}y|jjƒ}Wntk red}nX|jd|j|fƒq3Wndj|ƒS(Nu[%s]uu%s: %su ( tappendRDRLtoptBindstsecondtgetValueStringR&tfirsttjoin(R touttoptBindR((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt__str__×s   !cC@s2t|j|dƒ}|dkr%dSt|ƒƒS(N(RKRLRR(R RMtmethod((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt _get_optionãs cC@s)|j|ƒ}|dkrdS|jƒS(N(R[RR(R RMtopt((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt _get_valueés cC@sB|j|ƒ}|dkr2td|dƒ‚n|j||ƒS(NuOption udoes not exists(R[RRR,(R RMRRR\((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt _set_valueïs c C@sC|j|ƒr?x-|jƒ|D]}|j||ƒ}| sK|dkrTd}nt|j|ƒrÜy&|jjƒj|ƒj||ƒWq8tk rØ}t j t dƒt |ƒt |ƒt |ƒt |ƒƒq8Xq |dkr t||ƒr t|||ƒq t j t dƒt |ƒt |ƒt |ƒƒq WndS(u+Set option values from an INI file section.uNoneuu,Unknown configuration value: %s=%s in %s; %suarchu+Unknown configuration option: %s = %s in %sN(t hasSectiontgetDatatgetSubstitutedValuethasattrRLRRtatt newStringR&tloggertdebugRRR*tsetattr(R RHRGtfilenameRRMRR+((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt _populateõs  &/ cC@s‚d|jg}|jrqxU|jjƒD]A}y'|jd|j|jjƒfƒWq)tk riq)Xq)Wndj|ƒdS(u]Return a string representing the values of all the configuration options. u[%s]u%s = %su ( RDRLRRRQRURSRTR&RV(R toutputRX((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pytdump s '  cC@sæ|dkr6|jdkr*tdƒ‚n|j}n|jj|ƒ}|jrÒx~|jjƒD]j}|dks¦|j|ks¦|jj ƒt ks¦|j|kra|jj ||j|jj ƒƒqaqaWn|jj |ƒdS(uÅWrite out the configuration to a file-like object. :param fileobj: File-like object to write to :param section: Section name to use. If not specified, the section name used during parsing will be used :param always: A sequence of option names to always write out. Options not listed here will only be written out if they are at non-default values. Set to None to dump out all options u!not populated, don't know sectionN(RRDt ValueErrorREtoptionsRLRRRURSRt PRIO_DEFAULTRRTtwrite(R tfileobjRGtalwayst cfg_optionsRX((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_writes   ,c C@sæt|ƒ}tj|ƒ}WdQX||krkx8|D]-}tjjj||ƒ|kr7|}q7q7WnxI|jƒD];\}}t|t ƒr¥dj |ƒ}n||||tTruet modulesdirtmoduledefaultsdir(R RGRHRFR“R”R+tmsg((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR Xs&""  cC@sld}x3|jdƒD]"}tjj|ƒr|}PqqW|sh|jdƒd}tjj|ƒn|S(uReturns the value of reposdirureposdiriN(RR]tostpathR@R'Rt ensure_dir(R t myrepodirtrdir((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt get_reposdirtsc@sóˆj|ƒ}|jƒ}|tkr+dS|jƒ}t|tƒs t‡fd†|Dƒƒrï|jtj j g|D]}ˆj |ƒ^qxƒ|ƒqïnOt j jt j jˆjdƒ|jdƒƒƒrï|jˆj |ƒ|ƒndS(Nc3@sB|]8}tjjtjjˆjdƒ|jdƒƒƒVqdS(u installrootu/N(R™RšR@RVR]tlstrip(t.0tp(R (s3/usr/lib/python2.7/site-packages/dnf/conf/config.pys Žsu installrootu/(R[RtPRIO_COMMANDLINERRR*tanyR,RRR!t_prepend_installroot_pathR™RšR@RVR]RŸ(R toptnameR\tpriotvalR¡((R s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_search_inside_installroot„s    1 cC@sD|j|ƒ}|jƒ}|j|jƒƒ}|j||ƒdS(N(R[RR¤RR,(R R¥R\R¦tnew_path((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pytprepend_installroot–s cC@s@tjj|jdƒ|jdƒƒ}tjjj||j ƒS(Nu installrootu/( R™RšRVR]RŸRRRwRxR{(R Ršt root_path((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyR¤s'c C@s(ddddddddd d d d dd dddddddddddddg}x|D]y}t||d!ƒ}|d!k r^|gkr^|j|ƒ}|d!k rt}|jrñy"|jjƒj|ƒjƒ}Wqñtk ríqñXn|rtt j j }||j ƒkr$|j ƒ}nxc|D]B}|rW|j |jƒ|g|ƒq+|j gt j j ƒq+WqÔ|j |t j j ƒq×t||ƒr¯t|||ƒq×tjtdƒt|ƒt|ƒƒq^q^Wt|d d!ƒtkr|jdƒ}|j tt j j ƒnt|dƒr$x÷|jjƒD]ã\}} xÔ| D]Ì} t|j|ƒrÛy&|jjƒj|ƒjt | ƒWqtk r×} t jjtdƒ|| t| ƒfdt| ƒƒ‚qXqMt||ƒrýt||| ƒqMtd ƒ} tj| |ƒqMWq:Wnd!S("u%Configure parts of CLI from the opts upluginsuversionuconfig_file_pathu debuglevelu errorlevelu installrootubestu assumeyesuassumenouclean_requirements_on_removeugpgcheckushowdupesfromreposu ip_resolveu rpmverbosityudisable_excludesucoloru downloadonlyuexcludeu excludepkgsu skip_brokenutsflagsuarchubasearchu ignorearchu cacheonlyucommentu%Unknown configuration option: %s = %sulocalpkg_gpgchecku main_setoptsu4Error parsing --setopt with key '%s', value '%s': %sRu1Main config did not have a %s attr. before setoptN(RKRR[R5RLRRRct getAddValueR&R'RR¢RR,RRbRgRetwarningRRt main_setoptsRyRdR(R)R*( R toptst config_argsRMRR\t appendValuet add_prioritytitemtvaluesR§R+R˜((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_configure_from_options¡s`        "     &  , cC@sxd}|dk rt|gkrt|j|ƒ}|rL|j|tjjƒqttjtdƒt |ƒt |ƒƒndS(Nu excludepkgsu%Unknown configuration option: %s = %s( RR[R,R'RR¢ReR­RR(R tpkgsRMtconfopt((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt exclude_pkgsâscC@sN|jdƒ}|jƒ}|rJ|jdƒ}|j| |jƒƒndS(u Adjust conf options interactionsu skip_brokenustrictN(R[RR,R(R t skip_brokentskip_broken_valtstrict((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt_adjust_conf_optionsîs  cC@s|jjdƒS(Nu releasever(R{tget(R ((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pyt releasever÷scC@s:|dkr#|jjddƒdSt|ƒ|jdRBR‚RÉRÏ(((s3/usr/lib/python2.7/site-packages/dnf/conf/config.pytsN            .µç$