ó í€Rc@sKddlTddlZddlZddlZdZddd„ƒYZdS(iÿÿÿÿ(t*Nt1tyumCompscBsƒeZd d„Zd„Zd„Zd„Zed„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „ZRS(c Cs&||_d|_d|_|s*d}n||_tjj|ƒ}tjj|ƒsgtj |ƒni|_ t ddƒ}|j ƒ}x”|D]Œ}|j ddƒ}t|ƒdkrÂq’n|jdƒ}t|ƒdkréq’n|d jd ƒ}x|D]} |d|j | s$cCs±yH|jjƒtj|jƒtj|jƒ|_|jjƒ|_Wntk rb}|GHnKX|jj dƒ|jj dƒ|jj dt ƒ|jj ƒ|j ƒdS(s8 Setup a database for yum category and group informations\CREATE TABLE groups (name TEXT, category TEXT, groupid TEXT, group_enum TEXT, pkgtype Text);s$CREATE TABLE version (version TEXT);sINSERT INTO version values(?);N( R tcloseR tunlinkR RRR R R#R$tcommittrefresh(RR'((s-/usr/share/PackageKit/helpers/yum/yumComps.pyR%Ys   cCs&|jjd|||||fƒdS(s add an item into the database s)INSERT INTO groups values(?, ?, ?, ?, ?);N(R R#(Rtnametcategorytgroupidtpkgrouptpkgtype((s-/usr/share/PackageKit/helpers/yum/yumComps.pyt_add_dbiscsêyˆjjj}Wn-tjjk r/}tStk rB}tSXˆjjjdkr\tSˆj j dƒxN|D]F}t ‡fd†t ‡fd†|j ƒƒ}ˆj||jƒqsWˆjjƒdGHˆjƒˆjjƒtS(s+ get the data from yum (slow, REALLY SLOW) isDELETE FROM groups;csˆjjj|ƒS(N(Rtcompst return_group(tx(R(s-/usr/share/PackageKit/helpers/yum/yumComps.pyt}scsˆjjj|ƒS(N(RR4t has_group(R6(R(s-/usr/share/PackageKit/helpers/yum/yumComps.pyR7~ssNon Categorized groups(RR4t categoriestyumtErrorst RepoErrorR"R t compscountR R#tmaptfiltertgroupst_add_groups_to_dbt categoryidR R,t_add_non_catagorized_groupsR&(RtforcetcatsR'R/tgrps((Rs-/usr/share/PackageKit/helpers/yum/yumComps.pyR-ms$    cCs x|D]û}|j}|jddƒ}|jddƒ}d||f}t}|jj|ƒrr|j|}n dG|GHx*|jD]}|j||||dƒq…Wx*|jD]}|j||||dƒq²Wx*|jD]}|j||||dƒqßWqWdS( Nsrpmfusion_nonfree-Rsrpmfusion_free-s%s;%ssunknown group enumt mandatorytdefaulttoptional( R0Rt GROUP_OTHERRthas_keytmandatory_packagesR3tdefault_packagestoptional_packages(RRFtcat_idtgroupt group_nametgroup_idt group_enumtpackage((s-/usr/share/PackageKit/helpers/yum/yumComps.pyRAˆs   cCseg}xH|jjjD]7}|j|jƒr4qq|jr|j|ƒqqW|j|dƒdS(Ntother(RR4R@t get_categoryR0t user_visibletappendRA(Rtto_addtgrp((s-/usr/share/PackageKit/helpers/yum/yumComps.pyRCžs cCsEg}|jjd|gƒx"|jD]}|j|dƒq&W|S(s4 for a PK group, get the packagelist for this group s-SELECT name FROM groups WHERE group_enum = ?;i(R R#RX(Rt group_keyt all_packagesR)((s-/usr/share/PackageKit/helpers/yum/yumComps.pytget_package_listªs cCs>|jjd|gƒt}x|jD]}|d}q&W|S(s2 return the PackageKit group enum for the package s-SELECT group_enum FROM groups WHERE name = ?;i(R R#RJ(RtpkgnameRPR)((s-/usr/share/PackageKit/helpers/yum/yumComps.pyt get_group²s cCsHtƒ}|jjdƒx"|jD]}|j|dƒq#Wt|ƒS(s return all the group_id's sSELECT groupid FROM groupsi(tsetR R#taddtlist(RtmetapkgsR)((s-/usr/share/PackageKit/helpers/yum/yumComps.pytget_meta_packages»s  cCsEg}|jjd|gƒx"|jD]}|j|dƒq&W|S(sK for a comps group, get the packagelist for this group (mandatory, default)s+SELECT name FROM groups WHERE groupid = ? ;i(R R#RX(RR0R\R)((s-/usr/share/PackageKit/helpers/yum/yumComps.pytget_meta_package_listÃs cCs?d}|jjd|gƒx|jD]}|d}Pq&W|S(s1 for a comps group, get the category for a group s.SELECT category FROM groups WHERE groupid = ?;iN(RR R#(RR0R/R)((s-/usr/share/PackageKit/helpers/yum/yumComps.pyRVËs  cCsNtƒ}|jjd|gƒx"|jD]}|j|dƒq)Wt|ƒS(Ns-SELECT groupid FROM groups WHERE category = ?i(R`R R#RaRb(RRORFR)((s-/usr/share/PackageKit/helpers/yum/yumComps.pyt get_groupsÔs  N(t__name__t __module__RRRR%R3R"R-RARCR]R_RdReRVRf(((s-/usr/share/PackageKit/helpers/yum/yumComps.pyRs !         ((tpackagekit.enumsRR R:R$R(((s-/usr/share/PackageKit/helpers/yum/yumComps.pyts