Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/aptsources/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/aptsources/distro.pyc


WRc@sddlZddlZddlZddlZddlmZddlmZdefdYZ	de
fdYZdefd	YZd
efdYZ
dZeeeed
ZdS(iN(tElementTree(tgettexttNoDistroTemplateExceptioncBseZRS((t__name__t
__module__(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR"stDistributioncBs}eZdZdZddZdZdZddddddZdZ	dZ
d	Zd
ZdZ
RS(
cCs:||_||_||_||_d|_d|_dS(s2 Container for distribution specific informations tdebsdeb-srcN(tidtcodenametdescriptiontreleasetbinary_typetsource_type(tselfRRR	R
((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt__init__(s					cCs||_d|_g|_g|_g|_g|_g|_g|_g|_	g|_
t|_g|_
d|_d|_d|_g|_xH|jjjD]7}|j|jr|j|jkr||_PqqW|jdkrtdng}g}g}g}xo|jjD]a}|jtkr|j|jr|jr|jjtkr|j|jjr|jj dr|j!tkr|jj"||j#|j$q|jj dr|j!tkr|jj"|q|j%|j&krA|j!tkrA|jj"||j#|j$|j"|jq|j%|j&kru|j!tkru|jj"|q|j%|j'kr|j!tkr|j
j"|q|j%|j'kr|j!tkr|jj"|qn|jtkr|j|jj(kr|j!tkr8|j%|j&kr8|jj"|q|j!tkrl|j%|j'krl|j
j"|q|jj"|qqWt)||_t)||_	|j#||j#|t)||_t)||_
|j*dS(sf
        Find the corresponding template, main and child sources
        for the distribution
        ts-Error: could not find a distribution templatescdrom:N(+tsourceslisttNonetsource_templatet
child_sourcestmain_sourcestdisabled_sourcest
cdrom_sourcestdownload_compst
enabled_compstcdrom_compst
used_mediatFalsetget_source_codetsource_code_sourcestdefault_servertmain_servertnearest_servertused_serverstmatchert	templatestis_codenametnametdistributionRRtlisttinvalidtdistttemplatetofficialtTrueturit
startswithtdisabledtappendtextendtcompsttypeRRtchildrentsettget_mirrors(R
RR*tmediaR2RRtsource((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytget_sources3s																		

c
Cs|jj|_x3|jD](}|jds|jj|qqWt|jdkri|j|_	n|jdj
|_	i|_d}tj
j|rRtd|}|jd}x|D]}y|jd}Wntk
r|jd}nXy|jd}Wntk
r+|jd	}nXtjd
||j|j<qWnd|_d|_tjddd
}	|	jd}
|	jd}|dkrt|	}n|	|
d|!j}|r|||_n||jkr
|j||_||_ndS(sR
        Provide a set of mirrors where you can get the distribution from
        scdrom:is%/usr/share/xml/iso-codes/iso_3166.xmltfiletiso_3166_entrytcommon_nameR%talpha_2_codetalpha_3_codetiso_3166tLANGtdefaultten_UKt_t.iiN(Rtbase_uriRRR.R!R0tlenRRR-t	countriestostpathtexistsRtgetiteratortattribtKeyErrorRtdgettexttlowerRtcountrytcountry_codetgetenvtfindR (
R
tmirror_templatetmediumtfnametettittelmtdescrtcodetlocaletatzRQ((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR6sH	


			cCsd}|jd}|jd}|dkrV|dkrV||td|!}n||jkrztd|j|Sd|jdSdS(su Try to get a human readable name for the main mirror of a country
            Customize for different distributions s://s.archive.ubuntu.comis
Server for %ss%ss/ N(RRSRFRGRCtrstrip(R
tserverRPtitl((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt_get_mirror_namescCskd}g}t|jdksRt|jdkr||jd|jr|jtd|jtg|jrg|j|j|j|jtgqgnt|jdkrq||jd|jrq|jtd|jtg|jd}|jrF|||jsF|j|j|j|jtgqFn|rg|j|j||tgqgnt|jdkrg|jtd|jtg|jr|j|j|j|jtgn|jtddtgxr|jD]d}|j||tg}|||js|||jrDqq||kr|j|qqWn|S(s- Return a list of used and suggested servers cSs"tj|jd|jdS(sl Helper function that handles comaprision of mirror urls
                that could contain trailing slashess/ (tretmatchtstripR_(tmir1tmir2((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytcompare_mirrorssiisMain serversCustom serversN(
RFR!RR0RCR,R RcRR(R
RitmirrorsR`tmirror_entry((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytget_server_listsB		
	%	RcCs|dkr|j}n|dkr0|j}n|dkrNt|j}n|dkrf|j}n|jj|||||}|jt	kr||jkr|jj|j
||||d|jd|jjj|dndS(s3
        Add distribution specific sources
        R:tposiN(
RRRR'RRRtaddRR,RR:tindex(R
R3R-R)R2tcommentt
new_source((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt
add_sources	cCst|g}xS|jD]H}x?|jjD]1}|j|kr,|jr,|j|jq,q,WqWx|D]}|j|qlWdS(s
        Enable a component in all main, child and source code sources
        (excluding cdrom based sources)

        comp:         the component that should be enabled
        N(R5RR*t
componentsR%tparent_componentRnt_enable_component(R
tcompR2R8tc((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytenable_components
csfd}g}|j|j|j|ji}i}x_|D]W}|j|jkrH|j|krt||j<nt||jj|j	qHqHWxb|j
D]W}|j|jkr|j|krt||j<nt||jj|j	qqWt|jdkr7|j
ddgn?x|D]}|||q>Wx|j
D]}|||q_W|jtkrt|j
dkr|j
d|jddgqx!|j
D]}|||qWndS(NcsR|j|krdS||jkr*dS|jj||jjdS(s
            Check if we already added the component to the repository, since
            a repository could be splitted into different apt lines. If not
            add the component
            N(R)R2R0Rn(R8tcomps_per_dist(Rv(s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytadd_component_only_once-siR2s%sR3(R1RRR3RR)R5tmapRnR2RRRFRrRR,(R
RvRztsourcesRytcomps_per_sdisttsR8((Rvs5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRu+s6
!!
#cCsg}|j|j|j|j|j|j||jkr^g}|j|jnxX|D]P}||jkre|jj|t|jdkr|jj|qqeqeWdS(sx
        Disable a component in all main, child and source code sources
        (excluding cdrom based sources)
        iN(	R1RRRRR2tremoveRFR(R
RvR|R8((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytdisable_componentgs
csfd}g}g}|_x!jD]}||||q.WxKjD]@}|jjdks|jj|jkrR||||qRqRWx!jD]}||||qWdS(sN Change the server of all distro specific sources to
            a given host cs||_x[|jD]P}|j|j|g|krG|jj|q|j|j|j|gqWt|jdkrjj|ndS(Ni(R-R2R)RR0RFR(R8R-tseenRv(R
(s5/usr/lib/python2.7/dist-packages/aptsources/distro.pytchange_server_of_source}s	 N(RRRR*RERR-R(R
R-Rtseen_binarytseen_sourceR8((R
s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt
change_serverys	cCs||jkrtStSdS(s1 Compare a given name with the release codename. N(RR,R(R
R%((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR$sN(RRRR9RR6RcRlRrRxRuRRR$(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR&s		\5		3		<		tDebianDistributioncBs)eZdZdZdZdZRS(s+ Class to support specific Debian features cCs*||jks|jdkr"tStSdS(s Compare a given name with the release codename and check if
            if it can be used as a synonym for a development releases ttestingtunstableN(RR(RR
R,R(R
R%((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR$scCsd}|jd}|jd}|dkrV|dkrV||td|!}n||jkrtdtjd|j|jjSd|jdSdS(	s_ Try to get a human readable name for the main mirror of a country
            Debian specific s://ftp.s.debian.orgis
Server for %sR?s%ss/ N(RRSRFRGRCRRNR_(R
R`RPRaRb((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRcscCstj|dddS(NRTs http://ftp.%s.debian.org/debian/(RR6(R
((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR6s(RRt__doc__R$RcR6(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRs		tUbuntuDistributioncBseZdZdZRS(s+ Class to support specific Ubuntu features cCstj|dddS(NRTs$http://%s.archive.ubuntu.com/ubuntu/(RR6(R
((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR6s(RRRR6(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRscCsddlm}m}ddl}idd6dd6dd	6d
d6}yU|dd
gd|jd}|jd}|jd|jdDWn9tk
r}|j|j	krt
jd|qnX|S(s-Call lsb_release --idrc and return a mapping.i(tPopentPIPENtsidtCodenametDebiansDistributor IDsDebian GNU/Linux unstable (sid)tDescriptionRtReleasetlsb_releases-idrctstdoutisutf-8css*|] }d|kr|jdVqdS(s:	N(tsplit(t.0Rb((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pys	<genexpr>ss
s#lsb_release failed, using defaults:(t
subprocessRRterrnotcommunicatetdecodetupdateRtOSErrortENOENTtloggingtwarn(RRRtresulttouttexc((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt_lsb_releases
"$cCs|o|o|o|sLt}|d}|d}|d}|d}n|dkrkt||||S|dkrt||||St||||SdS(s
    Check the currently used distribution and return the corresponding
    distriubtion class that supports distro specific features.

    If no paramter are given the distro will be auto detected via
    a call to lsb-release
    sDistributor IDRRRtUbuntuRN(RRRR(RRR	R
R((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt
get_distros		



(RRRdRHtxml.etree.ElementTreeRtapt_pkgRCt	ExceptionRtobjectRRRRRR(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt<module>sx