v_c@sSddlZddlZddlZddlZddlZddlZddlZddlZddlTddl Z ddl m Z m Z ddl Z ddl mZddlmZddlZddlmZddlmZddlmZd Zd efd YZd Zd Zed ZeefZidd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d!d#6d!d$6d!d%6d!d&6d'd(6d'd)6d*d+6d*d,6d-d.6d/d06Ze ej!Z"d1e#fd2YZ$d3dFd4YZ%d5dGd6YZ&ddHd7YZ'de'fd8YZ(de(fd9YZ)de'fd:YZ*de*fd;YZ+de*fd<YZ,de,fd=YZ-de-fd>YZ.d!e-fd?YZ/d'e/fd@YZ0d-e/fdAYZ1d*e/fdBYZ2d/e/fdCYZ3dDZ4dEZ5dS(IiN(t*(t ParsingErrort ConfigParser(tConfigPreProcessor(tfill(tproxy(t_(t utf8_widths2.7t DeprecatedIntcBseZdZRS(sXA simple int subclass that is used to check when a deprecated constant is used. (t__name__t __module__t__doc__(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRDsiitConfigPluginConduittconfigtPostConfigPluginConduitt postconfigtInitPluginConduittinittArgsPluginConduittargstDownloadPluginConduitt predownloadt postdownloadtPreRepoSetupPluginConduittprelistenabledrepost prereposetuptPostRepoSetupPluginConduitt postreposetupt PluginConduittclosetcleantMainPluginConduittpretranst posttranstpreverifytranstpostverifytranstexcludetDepsolvePluginConduitt preresolvet postresolvetHistoryPluginConduitt historybegint historyendtCompareProvidersPluginConduittcompare_providerstVerifyPluginConduittverify_packaget PluginYumExitcBs&eZdZdddZdZRS(sGException that can be raised by plugins to signal that yum should stop.tcCs||_||_dS(N(tvaluettranslation_domain(tselfR1R2((s//usr/lib/python2.7/site-packages/yum/plugins.pyt__init__os cCs*|jrtj|j|jS|jSdS(N(R2tgettexttdgettextR1(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt__str__rs (R R R R4R7(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR/lst YumPluginscBsbeZdZddddddZdZdZedZdZ dZ dZ RS( sManager class for Yum plugins.c Cs|sdg}n||_||_t||_||_d|_tjd|_ ||_ ||_ |dkr~t }nt |ttfs|f}nttg|D]}t|^qkr|j jtjdn|j|i|_tj|jd|jddS(svInitialise the instance. @param base: The @param searchpath: A list of paths to look for plugin modules. @param optparser: The OptionParser instance for this run (optional). Use to allow plugins to extend command line options. @param types: A sequence specifying the types of plugins to load. This should be sequnce containing one or more of the TYPE_... constants. If None (the default), all plugins will be loaded. @param pluginconfpath: A list of paths to look for plugin configuration files. Defaults to "/etc/yum/pluginconf.d". s/etc/yum/pluginconf.dsyum.verbose.YumPluginsseDeprecated constant TYPE_INTERFACE during plugin initialization. Please use TYPE_INTERACTIVE instead.RR N(NN(t searchpathtpluginconfpathtweakreftbaset optparsertNonetcmdlinetloggingt getLoggertverbose_loggertdisabledPluginstenabledPluginst ALL_TYPESt isinstancetlistttupletidtTYPE_INTERFACEtlogt logginglevelstINFO_2t_importpluginstcmdlinestatexittregistertrun( R3R<R9R=ttypesR:tdisabledtenabledtt((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4{s*          +   cKstj|d}|dkr1td|nt|}xf|j|D]W\}}|jjtj d|||j |\}}||||j ||qKWdS(sRun all plugin functions for the given slot. :param slotname: a string representing the name of the slot to run the plugins for :param kwargs: keyword arguments that will be simply passed on to the plugins sunknown slot name "%s"s$Running "%s" handler for "%s" pluginN( tSLOT_TO_CONDUITtgetR>t ValueErrortevalt _pluginfuncsRBRKRLtDEBUG_4t_pluginsR<(R3tslotnametkwargst conduitclstmodnametfuncRtconf((s//usr/lib/python2.7/site-packages/yum/plugins.pyRRs    c Csi|_i|_xtD]}g|j|tFalsetfnmatchtaddtTrue(RatpluginstusedR~((s//usr/lib/python2.7/site-packages/yum/plugins.pyt_plugin_cmdline_matchs   c Cstjj|\}}|jdd}|j||j|jrf|j||j|j rfdS|j|}| st j |ddt j t  r|j||j|j r|j jtd|dSyLtj||g\}}}ztj||||} Wd|jXWn=|j jtjrDn|j jtd|dSXt| ds|j jtd |dStt| js|j jtd || jtfdSt| d t} t| tt fs| f} nt!| d krdSxR| D]J} t"| t"t#krV|j j$tj%d |n| |krdSqW|j j$tj&td|||j'kr| |f|j'|RRtreadfpRRRtstr(R3RaRyt conffilenametparsert confpp_objte((s//usr/lib/python2.7/site-packages/yum/plugins.pyRRs $   cCs||f|_dS(sSet the parsed command line options so that plugins can access them. :param opts: a dictionary containing the values of the command line options :param commands: a list of command line arguments passed to yum N(R?(R3toptstcommands((s//usr/lib/python2.7/site-packages/yum/plugins.pyt setCmdLineksN( R R R R>R4RRRNt staticmethodRRrRR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR8xs,  . X tDummyYumPluginscBs eZdZdZdZRS(sThis class provides basic emulation of the :class:`YumPlugins` class. It exists so that calls to plugins.run() don't fail if plugins aren't in use. cOsdS(s&Do nothing. All arguments are unused.N((R3RR_((s//usr/lib/python2.7/site-packages/yum/plugins.pyRR{scOsdS(s&Do nothing. All arguments are unused.N((R3RR_((s//usr/lib/python2.7/site-packages/yum/plugins.pyRs(R R R RRR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRvs cBseZdZdZdZdZd dZdZdZ d dZ d dZ d d Z d d Z d d Zd ZRS(sLA conduit class to transfer information between yum and the plugin. cCsC||_||_||_tjd|_tjd|_dS(Ns yum.pluginsyum.verbose.plugin(t_parentt_baset_confR@RAtloggerRB(R3tparentR<Rc((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4s    cCs&tj|}|jj||dS(sSend an info message to the logger. :param level: the level of the message to send :param msg: the message to send N(RLtlogLevelFromDebugLevelRBRK(R3tleveltmsgtconverted_level((s//usr/lib/python2.7/site-packages/yum/plugins.pytinfoscCs&tj|}|jj||dS(sSend an error message to the logger. :param level: the level of the message to send :param msg: the message to send N(RLtlogLevelFromErrorLevelRRK(R3RRR((s//usr/lib/python2.7/site-packages/yum/plugins.pyRscCsi|jd||jjjr#tS|jjjr6tS|rIi|d6ni}t|jj|SdS(sOReturn a yes or no response, either from assumeyes already being set, or from prompting the user. :param msg: the message to show to the user :param prompt: the question to ask the user (optional); defaults to 'Is this ok [y/N]: ' :return: 1 if the response is yes, and 0 if the response is no itpromptN( RRRctassumenoRt assumeyesRtboolt userconfirm(R3RRR_((s//usr/lib/python2.7/site-packages/yum/plugins.pytpromptYNscCsddl}|jS(s8Return a string representing the current version of yum.iN(tyumt __version__(R3R((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getYumVersions cCs |jjS(sReturn the :class:`optparse.OptionParser` instance for this execution of Yum. In the "config" and "init" slots a plugin may add extra options to this instance to extend the command line options that Yum exposes. In all other slots a plugin may only read the :class:`OptionParser` instance. Any modification of the instance at this point will have no effect. See the :func:`PreRepoSetupPluginConduit.getCmdLine` method for details on how to retrieve the parsed values of command line options. :return: the global :class:`optparse.OptionParser` instance used by Yum. May be None if an OptionParser isn't in use (RR=(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getOptParserscCs"tj|j||tj|S(s5Read a string value from the plugin's own configuration file. :param section: configuration file section to read :param opt: option name to read :param default: value to read if the option is missing :return: string option value read, or default if option was missing (R RRtOption(R3tsectiontopttdefault((s//usr/lib/python2.7/site-packages/yum/plugins.pyt confStrings cCs"tj|j||tj|S(sfRead an integer value from the plugin's own configuration file. :param section: configuration file section to read :param opt: option name to read :param default: value to read if the option is missing :return: the integer option value read, or *default* if the option was missing or could not be parsed (R RRt IntOption(R3RRR((s//usr/lib/python2.7/site-packages/yum/plugins.pytconfInts cCs"tj|j||tj|S(s\Read a float value from the plugin's own configuration file. :param section: configuration file section to read :param opt: option name to read :param default: value to read if the option is missing :return: float option value read, or *default* if the option was missing or could not be parsed (R RRt FloatOption(R3RRR((s//usr/lib/python2.7/site-packages/yum/plugins.pyt confFloats cCs"tj|j||tj|S(s_Read a boolean value from the plugin's own configuration file :param section: configuration file section to read :param opt: option name to read :param default: value to read if the option is missing :return: boolean option value read, or *default* if the option was missing or could not be parsed (R RRR(R3RRR((s//usr/lib/python2.7/site-packages/yum/plugins.pytconfBools cCs"tj|j||tj|S(s_Read a boolean value from the plugin's own configuration file :param section: configuration file section to read :param opt: option name to read :param default: value to read if the option is missing :return: boolean option value read, or *default* if the option was missing or could not be parsed (R RRt ListOption(R3RRR((s//usr/lib/python2.7/site-packages/yum/plugins.pytconfLists cCs|jjj|dS(siRegister the name of a package to use. :param name: the name of the package to register N(Rtrun_with_package_namesR(R3tname((s//usr/lib/python2.7/site-packages/yum/plugins.pytregisterPackageNamesN(R R R R4RRR>RRRRRRRRR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRs     cBs eZdZdZdZRS(s%A conduit for use in the config slot.cCstjdtitjt6tjt6tjt 6tj t 6}|t krjt tj||||nz|tkrt tj||||nN|tkr|||}t tj||t tj|tj|ndS(sDeprecated. Register a yum configuration file option. :param name: name of the new option :param valuetype: option type (PLUG_OPT_BOOL, PLUG_OPT_STRING, etc.) :param where: where the option should be available in the config file (PLUG_OPT_WHERE_MAIN, PLUG_OPT_WHERE_REPO, etc) :param default: default value for the option if it is not set by the user suregisterOpt() will go away in a future version of Yum. Please manipulate config.YumConf and config.RepoConf directly.N(twarningstwarntDeprecationWarningR RtPLUG_OPT_STRINGRt PLUG_OPT_INTRt PLUG_OPT_BOOLRtPLUG_OPT_FLOATtPLUG_OPT_WHERE_MAINtsetattrtYumConftPLUG_OPT_WHERE_REPOtRepoConftPLUG_OPT_WHERE_ALLtInherit(R3Rt valuetypetwhereRttype2opttoption((s//usr/lib/python2.7/site-packages/yum/plugins.pyt registerOpts          cCs>t|jdr%|jj|ntjtddS(sRegister a new command. :param command: the command to register :raises: :class:`yum.Errors.ConfigError` if the registration of commands is not supported tregisterCommands&registration of commands not supportedN(RvRRRRR(R3tcommand((s//usr/lib/python2.7/site-packages/yum/plugins.pyR0s(R R R RR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR s cBseZdZdZRS(s'Conduit for use in the postconfig slot.cCs |jjS(sReturn a dictionary containing the values of the configuration options. :return: a dictionary containing the values of the configuration options (RRc(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetConf?s(R R R R(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR<scBs eZdZdZdZRS(s!Conduit for use in the init slot.cCs |jjS(sReturn a dictionary containing the values of the configuration options. :return: a dictionary containing the values of the configuration options (RRc(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyRKscCs |jjS(sReturn Yum's container object for all configured repositories. :return: Yum's :class:`yum.repos.RepoStorage` instance (Rtrepos(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetReposTs(R R R RR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRHs cBs eZdZdZdZRS(s0Conduit for dealing with command line arguments.cCs#tj||||||_dS(N(RR4t_args(R3RR<RcR((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4^scCs|jS(sReturn a list of the command line arguments passed to yum. :return: a list of the command line arguments passed to yum (R(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetArgsbs(R R R R4R(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR[s cBs eZdZdZdZRS(s)Conduit for use in the prererosetup slot.cCs |jjS(sReturn parsed command line options. :return: (options, commands) as returned by :class:`OptionParser.parse_args()` (RR?(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getCmdLinemscCs |jjS(sReturn a representation of the local RPM database. This allows querying of installed packages. :return: a :class:`yum.rpmUtils.RpmDBHolder` instance (Rtrpmdb(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetRpmDBts(R R R RR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRis cBseZdZdZRS(s*Conduit for use in the postreposetup slot.cCs |jjS(sVReturn group information. :return: :class:`yum.comps.Comps` instance (Rtcomps(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getGroupss(R R R R(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR|scBs,eZdZddZdZdZRS(s&Conduit for use in the download slots.cCs,tj||||||_||_dS(N(RR4t_pkglistt_errors(R3RR<Rctpkglistterrors((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4s cCs|jS(sReturn a list of package objects representing packages to be downloaded. :return: a list of package object representing packages to be downloaded (R(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetDownloadPackagesscCs|js iS|jS(sReturn a dictionary of download errors. :return: a dictionary of download errors. This dictionary is indexed by package object. Each element is a list of strings describing the error (R(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getErrorss N(R R R R>R4RR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRs  cBs5eZdZddZdZdZdZRS(sbMain conduit class for plugins. Many other conduit classes will inherit from this class. cCs+|r|j}nd}|jjj|S(sReturn a list of packages. :param repo: the repo to return a packages from :return: a list of package objects N(RIR>RtpkgSacktreturnPackages(R3trepotarg((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getPackagess cCs|jj|S(s Retrieve a package object from the packages loaded by Yum using nevra information. :param nevra: a tuple holding (name, epoch, version, release, arch) for a package :return: a :class:`yum.packages.PackageObject` instance (or subclass) (RtgetPackageObject(R3tnevra((s//usr/lib/python2.7/site-packages/yum/plugins.pytgetPackageByNevrascCs|jjj|dS(siDelete the given package from the package sack. :param po: the package object to delete N(Rtsackt delPackage(R3tpo((s//usr/lib/python2.7/site-packages/yum/plugins.pyRscCs |jjS(sFReturn transaction set. :return: the transaction set (RttsInfo(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyt getTsInfosN(R R R R>RRRR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyRs  cBs5eZdZdgdZedZdZRS(s(Conduit for use in solving dependencies.cCs,tj||||||_||_dS(N(RR4t resultcodet resultstring(R3RR<Rctrescodetrestring((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4s cCs |jjS(sDBoolean indicating if depsolving failed due to missing dependencies.(Rt_missing_requires(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pytmissing_requiresscCs&djd|jj|jDS(Ns css|]\}}||VqdS(N((t.0tprefixR((s//usr/lib/python2.7/site-packages/yum/plugins.pys s(RuRtpretty_output_restringR(R3((s//usr/lib/python2.7/site-packages/yum/plugins.pyR sN(R R R R>R4tpropertyR R (((s//usr/lib/python2.7/site-packages/yum/plugins.pyR%scBseZdZiddZRS(s3Conduit to compare different providers of packages.cCs,tj||||||_||_dS(N(RR4tpackagestreqpo(R3RR<Rctproviders_dictR((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4s N(R R R R>R4(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR+scBseZdZdgdZRS(s4Conduit to access information about the yum history.cCs)tj|||||jj|_dS(N(RR4Rthistory(R3RR<RcRR((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4sN(R R R R>R4(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR(scBseZdZdZRS(sConduit to verify packages.cCs#tj||||||_dS(N(RR4R.(R3RR<RcR.((s//usr/lib/python2.7/site-packages/yum/plugins.pyR4s(R R R R4(((s//usr/lib/python2.7/site-packages/yum/plugins.pyR-scCs+|jd\}}t|t|fS(sParse a string representing an api version. :param apiver: a string representing an api version :return: a tuple containing the major and minor version numbers t.(Rtint(tapivertmajtmin((s//usr/lib/python2.7/site-packages/yum/plugins.pytparseverscCsLt|}t|}|d|dkr0dS|d|dkrHdSdS(sReturn true if API version "a" supports API version "b" :param a: a string representing an api version :param b: a string representing an api version :return: whether version *a* supports version *b* ii(R(tatb((s//usr/lib/python2.7/site-packages/yum/plugins.pyRs  ((((6RmRqRRRPR5R@RLt constantsR RRRRRttextwrapRRR;RRRtyum.i18nRRRRt TYPE_COREtTYPE_INTERACTIVERJRERWRptkeysRit ExceptionR/R8RRR RRRRRRRR%R+R(R-RR(((s//usr/lib/python2.7/site-packages/yum/plugins.pyts                .  (