K-Rc@sddlmZddlTddlZddlZddlZddlZddlZddlZ ddl Z ddl Z dd/dYZ e Z dZdZeZgagadd d d d d dgZiadZdadZddZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%ddZ&dZ'd Z(dd!Z)dd"Z*d#Z+d$Z,d%d0d&YZ-d'd1d(YZ.d)d2d*YZ/d+d3d,YZ0d-d4d.YZ1dS(5i(t TYPE_CORE(t*Nt_lazy_import_langtablecBseZdZdZRS(cCs d|_dS(N(tNonetmod(tself((s!/usr/lib/yum-plugins/langpacks.pyt__init__$scCs7|jdkr'ddl}||_nt|j|S(Ni(RRt langtabletgetattr(RtnameR((s!/usr/lib/yum-plugins/langpacks.pyt __getattr__'s  (t__name__t __module__RR (((s!/usr/lib/yum-plugins/langpacks.pyR"s ccs]y&xtjj|D] }|VqWWn0tk rX}tjd|t|fIJnXdS(Ns%s: %s(tyumtmisctcElementTree_iterparset SyntaxErrortsyststderrtstr(tfilenamete((s!/usr/lib/yum-plugins/langpacks.pyt iterparse/s  s2.5ten_AUten_CAten_GBtpt_BRtpt_PTtzh_CNtzh_TWcCstst|ndS(N(tconditional_pkgstmy_postreposetup_hook(trepos((s!/usr/lib/yum-plugins/langpacks.pyt_setup_conditional_pkgs>scCsg}d}d}x|D]}|jds@t|dkr|d}tjd|ddjd}t|dkr|j|n||kr|j|q|d}q||kr|j|q|d}qWt|S( Nit_iit languageIdtlanguageIdQuerytensUTF-8(tcounttlenRt language_nametencodetappendtsorted(t alllanglisttuniq_lang_listtdupt processedtitemtlangname((s!/usr/lib/yum-plugins/langpacks.pytget_unique_language_namesEs  ! !   c Cs|}g}ddddddddd d g }g}t}xEtD]=}t|}|d }|jd sF|j|d qFqFW|jdg|} t| dd} x|D]} | } x| D]\} } | j|kr| jj| r| jd}| jjd}||}|jdr?|d}n|j | j||kr}||krz|j|qzq}qqqWqW||fS(Ntdeveltbrowsert debuginfotmusict overridestBraziltBritishtFarsitLowSaxontcs_CZistesseract-langpack-iR tkeycSs|dS(Ni((tx((s!/usr/lib/yum-plugins/langpacks.pytmst-talphabet_sounds_i( tsetRt startswithR*tsearchGeneratorR+R R&tsplittadd(tbasetybt srchpkglistt skip_pkg_listtlanglisttseentbasepkgtcondstpkg_pattresR0tsrchpkgtpkgtvaluestlidxt langsplittlname((s!/usr/lib/yum-plugins/langpacks.pytread_available_langpacks]s6$         !cCstjd|ddjdS(NR#R$R%sUTF-8(RR(R)(tlc((s!/usr/lib/yum-plugins/langpacks.pytlc_to_langnamescCstjd|S(Nt languageName(RR#(R1((s!/usr/lib/yum-plugins/langpacks.pytlangname_to_lcscCsts gSg}y)ttd}|j}|jWnttfk rU}gSXx'|D]}|j}|j|q]W|S(Ntr(tconffiletopent readlinestclosetIOErrortOSErrortstripR*(trettftlistRR0((s!/usr/lib/yum-plugins/langpacks.pytread_installed_langpackss   cCsts dStjjt}tjj|sbytj|dWqbttfk r^}dSXnyWttdd}x|D]}|j |dqW|j tj tdtWnttfk r}dSXdS(Nis.tmpsw+s ( R]tostpathtdirnametexiststmakedirsRaRbR^twriteR`trename(RftdirRttmptline((s!/usr/lib/yum-plugins/langpacks.pytwrite_installed_langpackss   cCsYd}t}x0|D](}||kr|j|d}qqW|rUt|ndS(Nii(RgR*Rr(tlangstmodifiedRftlang((s!/usr/lib/yum-plugins/langpacks.pytadd_langpack_to_installed_lists     cCsd}d}t}xl|D]d}t|dkrX|jddkrXt|}n|}||kr|j|d}qqW|rt|ndS(NitiR"ii(RgR'tfindR[tremoveRr(RsRtt removelangRfRu((s!/usr/lib/yum-plugins/langpacks.pyt#remove_langpack_from_installed_lists  '   cCstj\}}|dkr'd}n|jddd|}|r|jd}xA|D]6}|j}|jdd|ftj|q[Wnt j j drt j djd }xA|D]6}|j}|jdd|ftj|qWn|j }|sdSt |d r5|j}nt |jd r|jt|jt|jt|jt|jtndS( NR%tmaintlangpack_localestdefaultt,isAdding %s to language listtLANGUAGEt:tplugin_option_grouptregisterCommand(tlocaletgetdefaultlocaleRt confStringRERctinfoRsR*Rhtenvironthas_keyt getOptParserthasattrRt_baseRtLanginstallCommandtLangremoveCommandtLanglistCommandtLanginfoCommandtLangavailableCommand(tconduitRutencodingtconflistRptconfitemRftparser((s!/usr/lib/yum-plugins/langpacks.pyt config_hooks6        cCsm|j}|jjdat}xD|D]<}|jds)|jdd|ftj|q)q)WdS(Ns&/plugins/langpacks/installed_langpackst#isAdding %s to language list( Rtconft persistdirR]RgRCRRsR*(RRHRfRu((s!/usr/lib/yum-plugins/langpacks.pyt init_hooks   cCs x|D]}y|j}Wntjjk r9qnX|sFqntjj|dt}xt|D]\}}|jdkrkxt|j D]c}|jdkrqn|j d}|j d}|t krgt |(Ru(s!/usr/lib/yum-plugins/langpacks.pyR?QsR"ics |fS(N((R>(t shortlang(s!/usr/lib/yum-plugins/langpacks.pyR?Ts( tpkgSackRtrpmdbt searchNevrattsInfot matchNaevrtmapRER*RR( RuRGRHRt pkgmatchesRMRNtpatternsRRt pkgs_uniq((RuRs!/usr/lib/yum-plugins/langpacks.pytget_matches_from_tsIs   *     cst|j}|jj}|j}xUtD]Mt|dtfd|}| rdkrjddt|dtfd|}nx|D]}|j j d|jrqn|j j d|jrqnt |dr|jd ny3|jd |jtkr@tjnWqtjjk rw|jd d |jfqqXqWq/WdS( NRfcs |fS(N((R>(Ru(s!/usr/lib/yum-plugins/langpacks.pyR?dsRR"ics |fS(N((R>(R(s!/usr/lib/yum-plugins/langpacks.pyR?gsR tregisterPackageNames yum-langpackstpatternisFailed to install package %s(RR tgetRepostgetPackageSackRRsRRRERRRRRRRt langinstalledR*R RRR(RtpoRNRRHRRR((RuRs!/usr/lib/yum-plugins/langpacks.pytadd_deps_to_ts]s,   $'  c Cst|j}|j}g}xZ|D]R}xItD]A}|j||f|jdd}|j||fq0Wq#W|sdSxt|j|D]s}t|dr|j dny|j d|jWqt j j k r|jdd|jfqqXqWdS(NR"iRs yum-langpacksRisFailed to remove package %s(RR RRsR*RERRRRRyR RRR( RRRNRHRtcRuRRR((s!/usr/lib/yum-plugins/langpacks.pytremove_deps_from_tsws$    c s|r$|j}|jj}n|}|j}g}xtD]}|jjd|sp|jjd|r@t|}t fd|}j ddkr|t fd|}nx-|D]"} | |kr|j | qqWq@q@Wt ||} x| D]} |jjd| j r>qn|jjd| j r\qn|rt|dr|jdny3|jd| j tkrtj nWqtjjk r|r|jd d | j fqqqXqWdS( NR cs |fS(N((R>(Ru(s!/usr/lib/yum-plugins/langpacks.pyR?sR"ics |fS(N((R>(R(s!/usr/lib/yum-plugins/langpacks.pyR?sRs yum-langpacksRisFailed to install package %s(RRRRRRRRRRRER*RR RRRRR RRR( RRuRGRHRRRMRNRRRRR((RuRs!/usr/lib/yum-plugins/langpacks.pytadd_matches_from_tss@   *      c s[|r|j}n|}g}xtjD]}tfd|}jddkr|tfd|}nx*|D]"}||kr|j|qqWq+Wt|j|}x|D]} |rt|dr|j dny|j d| j Wqt j jk rR|r|jdd | j fqqqXqWdS( Ncs |fS(N((R>(Ru(s!/usr/lib/yum-plugins/langpacks.pyR?sR"ics |fS(N((R>(R(s!/usr/lib/yum-plugins/langpacks.pyR?sRs yum-langpacksRisFailed to remove package %s(RRRSRRER*RRRRRyR R RRR( RRuRGRHRRNRRRRR((RuRs!/usr/lib/yum-plugins/langpacks.pytremove_matches_from_tss,     cCst|jj|j}g}g}xb|jjD]N}|jttfkrxa|j D]V}||kr{qcn|j j |}|j rct ||j |j|jqcqcW|j}|jtkrt||qn|jttfkr>xa|j D]V}||krqn|j j |}|j rt||j |j|jqqW|j}|jtkrt||qq>q>WdS(N(R!Rt listEnabledRt getTsInfot getMemberst output_statet TS_INSTALLtTS_TRUEINSTALLtgroupstcompst return_grouptlangonlyRR*tgroupidRR RRtTS_ERASEt TS_OBSOLETEDRR(RRHt groups_addedtgroups_removedtmembertgtgroupR((s!/usr/lib/yum-plugins/langpacks.pytpostresolve_hooks6       cCstrttndS(N(RRv(R((s!/usr/lib/yum-plugins/langpacks.pytposttrans_hooksRcBs5eZdZdZdZdZdZRS(cCsdgS(Nt langinstall((R((s!/usr/lib/yum-plugins/langpacks.pytgetNamesscCsdS(Ns[langinstall lang1|lang2|...]((R((s!/usr/lib/yum-plugins/langpacks.pytgetUsagescCsdS(Ns1Install appropriate language packs for a language((R((s!/usr/lib/yum-plugins/langpacks.pyt getSummaryscCsdS(N((RRGtbasecmdtextcmds((s!/usr/lib/yum-plugins/langpacks.pytdoCheckscCsh|jjdkrddgfS|jjt|jjx^|D]V}t|dkr|jddkrtdt ||qFtd||qFW|j \}}|dkr||fSt|j dkrdddj |gfS|j}t|td kr1t|d kr1|S|dkrJdd gfS|d dj tgfSdS( Niis,You need to be root to perform this command.iR"isNo langpacks to install for: %st is#Language pack installation aborted!s Language packs installed for: %s(i(RtuidR tdoSetupR!RR'RxRRR[tbuildTransactionRtjoint doTransactionttypeR(RRGRRRutcodetmsgstrc((s!/usr/lib/yum-plugins/langpacks.pyt doCommands&   '   *  (R R RRRRR(((s!/usr/lib/yum-plugins/langpacks.pyRs     RcBs5eZdZdZdZdZdZRS(cCsdgS(Nt langremove((R((s!/usr/lib/yum-plugins/langpacks.pyRscCsdS(Ns[langremove lang1|lang2|...]((R((s!/usr/lib/yum-plugins/langpacks.pyRscCsdS(Ns.Remove installed language packs for a language((R((s!/usr/lib/yum-plugins/langpacks.pyRscCsdS(N((RRGRR((s!/usr/lib/yum-plugins/langpacks.pyRscCs||jjdkrddgfS|jjt|jjx^|D]V}t|dkr|jddkrtdt ||qFtd||qFW|j \}}|dkr||fSt|j dkrt |dddj|gfS|j}t|td kr;t|d kr;|S|dkrTdd gfSt ||d dj|gfSdS( Niis,You need to be root to perform this command.iR"isNo langpacks to remove for: %sRisLanguage pack removal aborted!sLanguage packs removed for: %s(i(RRR RR!RR'RxRRR[RRR{RRR(RRGRRRuRRR((s!/usr/lib/yum-plugins/langpacks.pyR s*   '    *   (R R RRRRR(((s!/usr/lib/yum-plugins/langpacks.pyRs     RcBs5eZdZdZdZdZdZRS(cCsdgS(NRK((R((s!/usr/lib/yum-plugins/langpacks.pyR:scCsdS(Ns [langlist]((R((s!/usr/lib/yum-plugins/langpacks.pyR=scCsdS(NsList installed languages((R((s!/usr/lib/yum-plugins/langpacks.pyR@scCsdS(N((RRGRR((s!/usr/lib/yum-plugins/langpacks.pyRCscCsMt}dGHx/|D]'}|jdsdt|GHqqWddgfS(NsInstalled languages:Rs iRw(RgRCRY(RRGRRRfR0((s!/usr/lib/yum-plugins/langpacks.pyRFs   (R R RRRRR(((s!/usr/lib/yum-plugins/langpacks.pyR9s     RcBs5eZdZdZdZdZdZRS(cCsdgS(Ntlanginfo((R((s!/usr/lib/yum-plugins/langpacks.pyROscCsdS(Ns[langinfo lang1|lang2|...]((R((s!/usr/lib/yum-plugins/langpacks.pyRRscCsdS(NsList languages information((R((s!/usr/lib/yum-plugins/langpacks.pyRUscCsdS(N((RRGRR((s!/usr/lib/yum-plugins/langpacks.pyRXsc Csp|jjt|jjt|\}}x.|D]&}dj|GHt|dkrqdGHddgfS|tkrt|dkr|jddkrt ||}nlt|dkr|jddkrt |t |}n-|jddkrt ||}ng}x|D]}d |GHq)Wt|dkr9d j|GHq9q9WddgfS( NsLanguage-Id={0}isNot a valid inputiRwiR"is s'No langpacks to show for languages: {0}( R RR!RRWtformatR'twhitelisted_localesRxRR[( RRGRRRtra_listRut list_pkgsRR((s!/usr/lib/yum-plugins/langpacks.pyR[s(   3'  (R R RRRRR(((s!/usr/lib/yum-plugins/langpacks.pyRNs     RcBs5eZdZdZdZdZdZRS(cCsdgS(Nt langavailable((R((s!/usr/lib/yum-plugins/langpacks.pyRyscCsdS(Ns[langavailable lang1|lang2|...]((R((s!/usr/lib/yum-plugins/langpacks.pyR|scCsdS(NsCheck available languages((R((s!/usr/lib/yum-plugins/langpacks.pyRscCsdS(N((RRGRR((s!/usr/lib/yum-plugins/langpacks.pyRsc CsZ|jjt|jjt|\}}t|}|sdGHx|D]M}t|}|dkrwd}n|dkrd}ndj||GHqPWnx|D]} t| dkr| j dd kr| j t t j |krd j| GHqId j| GHqt | |kr;d j| GHqd j| GHqWd d gfS(Ns#Displaying all available language:-t zh_Hans_CNRt zh_Hant_TWRs {0} [{1}]iR"is{0} is availables{0} is not availableiRw(R RR!RRWR2R[RR'RxtlowerRRRY( RRGRRtlanguage_packsRRKtlitemtlcnameRu((s!/usr/lib/yum-plugins/langpacks.pyRs,         '(R R RRRRR(((s!/usr/lib/yum-plugins/langpacks.pyRxs     (((((((2t yum.pluginsRt yum.constantstfnmatchtglobRRhtrpmt yum.ErrorsR tyum.miscRRRRtrequires_api_versiont plugin_typeRsRRRR!RR]R2RWRYR[RgRrRvR{RRRRRRRRRRRRRRRRRR(((s!/usr/lib/yum-plugins/langpacks.pytsZ            '      #         '   $&*