D[c@sddlZddlZddlZddlZddlmZddlmZdefdYZ de fdYZ de fd YZ d e fd YZ d Zeeeed ZdS(iN(t ElementTree(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 Z d Z d Z RS( cCs:||_||_||_||_d|_d|_dS(s2 Container for distribution specific informations tdebsdeb-srcN(tidtcodenamet descriptiontreleaset binary_typet source_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|jdkr td|j|jfng}g}g}g}x4|jjD]&}|j r|j|jr|jr|jjr|j|jjr|jj dr|j! r|jj"||j#|j$q|jj dr|j!r|jj"|q|j%|j&kr6|j! r6|jj"||j#|j$|j"|jq|j%|j&krd|j!rd|jj"|q|j%|j'kr|j! r|j j"|q|j%|j'kr|j!r|jj"|qn|j r.|j|jj(kr.|j! r|j%|j&kr|jj"|qT|j! rA|j%|j'krA|j j"|qT|jj"|q.q.Wt)||_t)||_ |j#||j#|t)||_t)||_ |j*dS(sf Find the corresponding template, main and child sources for the distribution ts7Error: could not find a distribution template for %s/%sscdrom:N(+t sourceslisttNonetsource_templatet child_sourcest main_sourcestdisabled_sourcest cdrom_sourcestdownload_compst enabled_compst cdrom_compst used_mediatFalsetget_source_codetsource_code_sourcestdefault_servert main_servertnearest_servert used_serverstmatchert templatest is_codenametnamet distributionRRRtlisttinvalidtdistttemplatetofficialturit startswithtdisabledtappendtextendtcompsttypeR R tchildrentsett get_mirrors(R RR*tmediaR1RRtsource((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyt get_sources3s                               c Cs5|jj|_x3|jD](}|jds|jj|qqWt|jdkri|j|_ n|jdj |_ i|_ d}t j j|rytd|}t|dddkr|j|_n|jd}x|D]}y|jd}Wntk r |jd}nXy|jd }Wntk rR|jd }nXtjd ||j |j  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 RkR(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(RRTRFRGRCRROR`(R RaRQRbRc((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRdscCstj|dddS(NRUs http://ftp.%s.debian.org/debian/(RR5(R ((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR5s(RRt__doc__R$RdR5(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRs  tUbuntuDistributioncBseZdZdZRS(s+ Class to support specific Ubuntu features cCstj|dddS(NRUs$http://%s.archive.ubuntu.com/ubuntu/(RR5(R ((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyR5s(RRRR5(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyRscCsddlm}m}ddl}idd6dd6dd 6d d 6}yU|d d gd|jd}|jd}|jd|jdDWn9tk r}|j|j krt j d|qnX|S(s-Call lsb_release --idrc and return a mapping.i(tPopentPIPENtsidtCodenametDebiansDistributor IDsDebian GNU/Linux unstable (sid)t DescriptionRtReleaset lsb_releases-idrctstdoutisutf-8css*|] }d|kr|jdVqdS(s: N(tsplit(t.0Rc((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pys ss s#lsb_release failed, using defaults:( t subprocessRRterrnot communicatetdecodetupdateRtOSErrortENOENTtloggingtwarning(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        (RRReRHtxml.etree.ElementTreeRtapt_pkgRCt ExceptionRtobjectRRRRRR(((s5/usr/lib/python2.7/dist-packages/aptsources/distro.pyts