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/sourceslist.pyc


WRc@sxddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZdZdZ
defdYZdefd	YZd
efdYZdefd
YZedkrtejeZx%eD]ZejdejqWeddZejdeejeddejeddndS(iN(tDistInfo(tfunction_deprecated_bycCs|jd}|jd}||kr.tSy*|jdd}|jdd}Wntk
rltSXd|kr||jdd|krtStS(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_uritcompare_uritcompare_srvt
master_srv((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt	is_mirror*s
cCstt|S(s. simple and efficient way to return uniq list (tlisttset(ts((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytuniqHstSourceEntrycBsPeZdZddZdZdZdZdZdZ	dZ
RS(	s single sources.list entry cCst|_t|_d|_g|_d|_d|_g|_d|_||_	|dkrtjj
dtjjd}n||_|j|d|_g|_dS(NtsDir::EtcsDir::Etc::sourcelist(Rtinvalidtdisabledttypet
architecturesturitdisttcompstcommenttlinetNonetapt_pkgtconfigtfind_dirtfindtfiletparsettemplatetchildren(tselfRR"((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__init__Ps 											
	cCsX|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__cs
cCs!|j}g}d}t}t}xtt|D]}||dkrk|rkt}|||7}q7||dkrt}|||7}q7|r||jrt}|j|||}q7||jr|rt}q7|||7}q7Wt|dkr|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(tstripRtrangetlenRtisspacetappend(R&Rtpiecesttmptp_foundtspace_foundti((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytmysplitks,

	cCsK|jj}|dks'|dkr4t|_dS|ddkrt|_|djj}|ddkrt|_dS|d}n|jd}|dkr||d|_|| }n|j|}t	|d
krt|_dS|dj|_
|j
dkr#t|_dS|djddkr|jdjdjd
}xt|D]i}y|jdd\}}Wntk
rt|_qeX|dkr|jd|_
qet|_qeWn|dj|_t	|jdkr	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;t=tarcht,i(R8srpm-srcR9sdeb-src(R9sdeb-srcR8srpm-src(RR,RRRRR!RR6R.Rtpopt	ExceptionRRRR(R&RR1R5toptionstoptiontkeytvalue((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR#sP			

		!


cCs^||_|r.|jjjd|_n,|jjddkrZd|j|_ndS(s# set a line to enabled or disabled R7iN(RRtlstripR,(R&t	new_value((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytset_enableds

cCs|jjS(s debug helper (tstrR,(R&((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__str__scCs|jr|jSd}|jr(d}n||j7}|jr[|ddj|j7}n|d|j|jf7}t|j	dkr|ddj|j	7}n|j
dkr|d|j
7}n|d	7}|S(
s# return the current line as string Rs# s
 [arch=%s]R=s %s %sit s #s
(RRRRRtjoinRRR.RR(R&R((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRGs			
	
N(t__name__t
__module__t__doc__RR'R)R6R#RFRHRG(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRMs			>		tNullMatchercBseZdZdZRS(s a Matcher that does nothing cCstS(N(R(R&R((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytmatchs(RKRLRMRO(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRNstSourcesListcBseZdZeddZdZdZdZdddgdZ	d	Z
d
Zej
rueeZnddZdZd
ZdZRS(s8 represents the full sources.list + sources.list.d file s /usr/share/python-apt/templates/cCs;g|_|r!t||_nt|_|jdS(N(RtSourceEntryMatchertmatcherRNtrefresh(R&twithMatchertmatcherPath((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR's
	cCsg|_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(
RRRt	find_filetloadR tglobRRRRO(R&R"tpartsdirtsource((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRSs	
	ccs#x|jD]}|Vq
WtdS(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]ItfdDr
tfd|Dr
Vq
q
WdS(Nc3s(|]}t||kVqdS(N(tgetattr(t.0RB(RZtattrs(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pys	<genexpr>sc3s|]}|VqdS(N((R_t	predicate(RZ(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pys	<genexpr>s(Rtall(R&t
predicatesR`((RZR`s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt__findsRic	st|}	|jfddtdtd|d|d|}
xW|
D]O}xF|	D]>}||jkr]|	|	j|=t|	dkr|Sq]q]WqPW|jfddtd|d|d|}
x\|
D]T}|jrt|j|	krt|_|S|jst|j|	|_|SqW|}
rX|
d	d
j7}
n|
d||f7}
x|	D]}|
d|}
qsW|d
krd|
|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
        cst|jkS(N(RR(R(R(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt<lambda>'sRRRRRicst|jkS(N(RR(R(R(s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRe4ss
 [arch=%s]R=s %s %sRIRs%s #%s
s
N(Rt_SourcesList__findRRRR.RRRJRRR"RRRORtinsert(R&RRRt
orig_compsRtposR"RRtsourcesRZtnew_compRtct	new_entry((Rs:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytaddsF	


		

cCs|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.pyRoQscCstjjd}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(
RRRVtostpathtexiststshutiltcopyR RX(R&t
backup_extR"RY((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytrestore_backupUscCst}|dkr'tjd}nxX|jD]M}|j|kr1tjj|jr1t	j
|jd|j|fq1q1W|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"RqRrRsRtRu(R&Rvtalready_backupedRZ((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytbackupds	'cCskyLt|d7}x-|D]%}t||}|jj|qWWdQXWntjd|nXdS(s (re)load the current sources trNscould not open file '%s'
(topenRRR0tloggingtwarn(R&R"tfRRZ((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRWps
cCsi}t|jdkr\tjjd}d}t|d}|j|WdQXdSz]xV|jD]K}|j|krt|jd||j<n||jj|jqiWWdx|D]}||j	qWXdS(s save the current sources isDir::Etc::sourcelists## See sources.list(5) for more information, especialy
# Remember that you can only use http, ftp or file URIs
# CDROMs are managed through the apt-cdrom tool.
twN(
R.RRRRVR}twriteR"RGtclose(R&tfilesRrtheaderRRZ((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytsavezs"
cCsg}i}x|D]}|jdkr.qn|jjrv|j}||kr\g||<n||}|j|qt|jjdkr|j|qqW||fS(s5get all parent and child channels in the sources listiN(R$RtchildR0R.R%(R&tsources_listtparentstused_child_templatesRZRBttemp((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pytcheck_for_relationss
	

N(RKRLRMRR'RSR]RfRRnRoRwRt_COMPAT_0_7Rt
restoreBackupR{RWRR(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRPs			5				
	RQcBs eZdZdZdZRS(s} matcher class to make a source entry look nice
        lots of predefined matchers to make it i18n/gettext friendly
        cCsg|_tjd|}x|D]|}tjj|}|jd}|d|!}t|d|}x3|jD](}|jdk	rs|jj	|qsqsWq#WdS(Ns	%s/*.infos.infoitbase_dir(
t	templatesRXRqRrtbasenameR!Rt	match_uriRR0(R&RUt
spec_filesRR5RR$((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyR's	

cCst}x|jD]}tj|j|jrztj|j|jrz|j	|j	ksg|j	dkrzt
}||_Pq|j|jrtj|j|jrt
}||_PqqW|S(s%Add a matching template to the sourceR9(
RRtretsearchRRROt
match_nameRRRR$R
(R&RZtfoundR$((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyROs!		(RKRLRMR'RO(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyRQs	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(RXR~tos.pathRqRRtRxRtdistinfoRtapt.deprecationRR
RtobjectRRNRPRQRKtinit_configRjR\tinfoRGtmirror(((s:/usr/lib/python2.7/dist-packages/aptsources/sourceslist.pyt<module>s4		(