ó »ÉD[c@@s“ddlmZmZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddddd gZ d „Zd „Zdefd „ƒYZdefd „ƒYZdefd„ƒYZd efd„ƒYZedkre jƒeƒZx%eD]ZejdejƒƒqWeddƒZejdeƒejeddƒƒejeddƒƒndS(i(tabsolute_importtprint_functionNi(tDistInfot is_mirrort SourceEntryt NullMatchert SourcesListtSourceEntryMatchercC@sž|jdƒ}|jdƒ}||kr.tSy*|jdƒd}|jdƒd}Wntk rltSXd|krš||jdƒd|krštStS(sµ check if the given add_url is idential or a mirror of orig_uri e.g. master_uri = archive.ubuntu.com compare_uri = de.archive.ubuntu.com -> True s/ s//it.(trstriptTruetsplitt IndexErrortFalsetindex(t master_urit compare_urit compare_srvt master_srv((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR.s   cC@stt|ƒƒS(s. simple and efficient way to return uniq collection This is not intended for use with a SourceList. It is provided for internal use only. It does not have a leading underscore to not break any old code that uses it; but it should not be used in new code (and is not listed in __all__).(tlisttset(ts((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytuniqLscB@sPeZdZdd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( s single sources.list entry cC@s·t|_t|_d|_g|_d|_d|_d|_g|_ d|_ ||_ |dkr‹t j jdƒt j jdƒ}n||_|j|ƒd|_g|_dS(NtsDir::EtcsDir::Etc::sourcelist(R tinvalidtdisabledttypet architecturestNonettrustedturitdisttcompstcommenttlinetapt_pkgtconfigtfind_dirtfindtfiletparsettemplatetchildren(tselfR"R'((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__init__Ys"               cC@sX|j|jkoW|j|jkoW|j|jkoW|j|jkoW|j|jkS(s- equal operator for two sources.list entries (RRRRR (R+tother((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__eq__ms cC@sF|jƒ}g}d}t}t}xùtt|ƒƒD]å}||dkr|ryt}t}|j|ƒ||}qt}|||7}q7||dkr·t}|||7}q7|rî||jƒ rît}|j|ƒ||}q7||jƒr| rt}q7|||7}q7Wt|ƒdkrB|j|ƒn|S(s‚ a split() implementation that understands the sources.list format better and takes [] into account (for e.g. cdroms) Rt[t]i(tstripR trangetlenR tappendtisspace(R+R"tpiecesttmptp_foundt space_foundti((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytmysplitus6      cC@si|jjƒ}|dks'|dkr4t|_dS|ddkrt|_|djƒjƒ}|ddkr€t|_dS|d}n|jdƒ}|dkrÆ||d|_|| }n|j|ƒ}t |ƒd krôt|_dS|djƒ|_ |j dkr#t|_dS|djƒdd kró|j dƒjd ƒjƒ}x•|D]Š}y|jd dƒ\}}Wnt k r t|_qbX|dkrÂ|jdƒ|_ qb|dkrãtj|ƒ|_qbt|_qbWn|djƒ|_t |jƒdkr't|_n|djƒ|_t |ƒd kr\|d |_n g|_dS(s^ parse a given sources.list (textual) line and break it up into the field we have Rt#Niitrpmsrpm-srctdebsdeb-srciR/s[]t=tarcht,Ri(R=srpm-srcR>sdeb-src(R>sdeb-srcR=srpm-src(R"R1R RRR R&R!R;R3Rtpopt ExceptionRR#tstring_to_boolRRRR (R+R"R6R:toptionstoptiontkeytvalue((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR(šsT              cC@s^| |_|r.|jjƒjdƒ|_n,|jjƒddkrZd|j|_ndS(s# set a line to enabled or disabled R<iN(RR"tlstripR1(R+t new_value((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt set_enabledÚs  cC@s|jƒjƒS(s debug helper (tstrR1(R+((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__str__åscC@sQ|jr|jSd}|jr(d}n||j7}|jr|jdk r|ddj|jƒ|jrqdndf7}nU|jdk r®|d|jr£dnd7}n&|jrÔ|ddj|jƒ7}n|d |j|j f7}t |j ƒd kr |d d j|j ƒ7}n|j dkrC|d |j 7}n|d 7}|S(s# return the current line as string Rs# s [arch=%s trusted=%s]RAtyestnos [trusted=%s]s [arch=%s]s %s %sit s #s N( RR"RRRRRtjoinRRR3R R!(R+R"((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRLés(    ,   N( t__name__t __module__t__doc__RR,R.R;R(RKRMRL(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRVs   % @ cB@seZdZd„ZRS(s a Matcher that does nothing cC@stS(N(R (R+R((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytmatchs(RRRSRTRU(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRscB@s†eZdZedd„Zd„Zd„Zd„Zdddgd„Z d „Z d „Z dd „Z d „Z d „Zd„ZRS(s8 represents the full sources.list + sources.list.d file s /usr/share/python-apt/templates/cC@s;g|_|r!t|ƒ|_n tƒ|_|jƒdS(N(RRtmatcherRtrefresh(R+t withMatchert matcherPath((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR, s   cC@s™g|_tjjdƒ}|j|ƒtjjdƒ}x(tjd|ƒD]}|j|ƒqNWx-|jD]"}|jso|jj |ƒqoqoWdS(s" update the list of known entries sDir::Etc::sourcelistsDir::Etc::sourcepartss %s/*.listN( RR#R$t find_filetloadR%tglobRRVRU(R+R'tpartsdirtsource((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRWs   cc@s#x|jD] }|Vq Wt‚dS(sM simple iterator to go over self.list, returns SourceEntry types N(Rt StopIteration(R+tentry((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__iter__&s c/@s[xT|jD]I‰t‡‡fd†ˆDƒƒr t‡fd†|Dƒƒr ˆVq q WdS(Nc3@s(|]}tˆ|ƒˆ|kVqdS(N(tgetattr(t.0RG(tattrsR^(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pys /sc3@s|]}|ˆƒVqdS(N((Rct predicate(R^(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pys 0s(Rtall(R+t predicatesRd((RdR^s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__find-sRiÿÿÿÿc  @stˆƒ‰|} |j‡fd†dtdtd|d|d|ƒ} xW| D]O} xF| D]>} | | jkr]| | j| ƒ=t| ƒdkr›| Sq]q]WqPW|j‡fd†dtd|d|d|ƒ} xb| D]Z} | jrt| jƒt| ƒkrt| _| S| jsÚt| j| ƒ| _| SqÚW|} ˆr^| d d jˆƒ7} n| d ||f7} x| D]}| d |} qyW|d kr°d| |f} n| d} t | ƒ}|dk rÞ||_ n|j j |ƒ|jj||ƒ|S(s¨ Add a new source to the sources.list. The method will search for existing matching repos and will try to reuse them as far as possible c@st|jƒˆkS(N(RR(R(R(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt?sRRRRRic@st|jƒˆkS(N(RR(R(R(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRiLss [arch=%s]RAs %s %sRPRs%s #%s s N(Rt_SourcesList__findR R RR3RRRQRRR'RVRURtinsert(R+RRRt orig_compsR!tposR'RR tsourcesR^tnew_compR"tct new_entry((Rs:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytadd3sF    $        cC@s|jj|ƒdS(s2 remove the specified entry from the sources.list N(Rtremove(R+t source_entry((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRshscC@s²tjjdƒ}tjj||ƒrQtjj|ƒrQtj|||ƒntjjdƒ}xHt j d|ƒD]3}tjj||ƒrwtj|||ƒqwqwWdS(s: restore sources.list files based on the backup extension sDir::Etc::sourcelistsDir::Etc::sourcepartss %s/*.listN( R#R$RZtostpathtexiststshutiltcopyR%R\(R+t backup_extR'R]((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytrestore_backupls(cC@s†tƒ}|dkr'tjdƒ}nxX|jD]M}|j|kr1tjj|jƒr1t j |jd|j|fƒq1q1W|S(s† make a backup of the current source files, if no backup extension is given, the current date/time is used (and returned) s %y%m%d.%H%Ms%s%sN( RRttimetstrftimeRR'RuRvRwRxRy(R+Rztalready_backupedR^((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytbackupws  'cC@skyLt|dƒ7}x-|D]%}t||ƒ}|jj|ƒqWWdQXWntjd|ƒnXdS(s (re)load the current sources trNscould not open file '%s' (topenRRR4tloggingtwarning(R+R'tfR"R^((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR[ƒs cC@sài}t|jƒdkr\tjjdƒ}d}t|dƒ}|j|ƒWdQXdSz]xV|jD]K}|j|kršt|jdƒ||j( R R’tretsearchR”RRUt match_nameRRR R)R(R+R^tfoundR)((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRUÑs!  (RRRSRTR,RU(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR¾s t__main__sentry %ss!http://archive.ubuntu.com/ubuntu/s$http://de.archive.ubuntu.com/ubuntu/sis_mirror(): %ss http://archive.ubuntu.com/ubuntus#http://de.archive.ubuntu.com/ubuntu(t __future__RRR\R‚tos.pathRuR–RxR|R#tdistinfoRt__all__RRtobjectRRRRRRt init_configRnR`tinfoRLtmirror(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyts8           ­´(