Viewing File: /usr/lib64/python2.7/Demo/scripts/newslist.pyo

ó
V
Qc@sâddlZddlZddlZddlZddlZejjdƒZdZdZ	dZ
eZdZdZ
dZd	Zd
ZxXejejdfD]@ZejjedƒZejjeƒr›eGHeeƒPq›q›Wdd
lmZddlTdZdjed„ejƒƒƒZiaejjee	ƒZ	ejjee
ƒZ
ejjeeƒZd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'd„Z(d„Z)e*dkrÞe)ƒndS(iÿÿÿÿNs
~/newspagesnews.example.comt	grouptreet
newsgroupsttrootis;... <img src="http://pelican.cl.cam.ac.uk/icons/page.xbm"> itHOMEs.newslistrc.py(tNNTP(t*s
$Revision$t cCs
d|kS(Nt$((ts((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt<lambda>mscCs6dGHx*|D]"}|jdƒ}t||ƒqWdS(NsUpdating tree...t.(tsplittmakeleaf(ttreetgroupstitparts((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt	addtotreexs
cCst|d}t|ƒ}||kr/i||<n|dkrLd||d<n|dkrpt|||dƒndS(NiiR(tlenR
(Rtpathtjtl((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyR
s

c	Cstjjt|dƒ}|tkr.d}n
d|}t|dƒ¸}|jdƒ|jd|ƒ|jdƒ|jd|ƒ|jd	ttfƒt||d
|ƒ|jdƒ|jdt	ƒ|jt
jt
j
ƒƒd
ƒ|jdƒWdQXdS(Ns.htmlRs under tws<html>
<head>
s&<title>Newsgroups available%s</title>
s</head>
<body>
s <h1>Newsgroups available%s</h1>
s-<a href="%s%s.html">Back to top level</a><p>
is
<p>s7<i>This page automatically created by 'newslist' v. %s.s</i>
s</body>
</html>
(tosRtjointpagedirtrootpagetopentwritethttppreft	printtreetrcsrevttimetctime(RRtptfilenametdetailtf((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt
createpages"	


	
	 cCs”t|ƒ}|tkr}|dkr}|jdt|dfƒ|j|ddƒ|jdtƒt|d||ƒdS|jƒ}|dkrÝ|jƒ|dkrÃ|jd|dƒn
|jdƒ|d}nx”|D]Œ}|dkrQ|jd	|d|dfƒ|dtkrA|jd
t|dƒqp|jdƒqät	|||||d|ƒqäW|dkr|jdƒndS(
Nis<li><b><a href="%s%s.html">is.*s</a></b>%s
s<li>%s
<ul>s<ul>Rs<li><a href="news:%s">%s</a> s     <i>%s</i>
s
s
</ul>(
RtsublistsizeRRtpagelinkiconR'tkeystsorttdescR(R&RtindentR#RtklR((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyR¨s.



#c
CsÊia|dkrdSy’t|dƒ}}dGHxn|D]f}|jƒ}y@|d}dj|dƒ}t|ƒdkrˆ|t|<nWq7tk
rœq7Xq7WWdQXWntk
rÅd|GHdSXdS(NRtrsReading descriptions...iRis Failed to open description file (R,RRRRt
IndexErrortIOError(tdescfiletdRtbitstgrptdsc((s-/usr/lib64/python2.7/Demo/scripts/newslist.pytreaddescÒs$



	cCs…tjj|ƒsd|GHdGHtjjƒddkrlytj|dƒWq~dGHtjdƒq~XqdGHtjdƒndS(	NsDirectory %s does not exist.s Shall I create it for you? (y/n)ityiÿsSorry - failed!isOK. Exiting.(RRtisdirtsyststdintreadlinetmkdirtexit(R((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt
checkopdirìs	cCsÊdGHi}y tjtj|ƒtƒ}Wn'd|GHdGHdGHtjdƒnXd|dd|d|d	f}y+t|d
ƒ}tj	|ƒ}WdQXWnt
k
r¿d|GHnX||fS(Ns#Reading current local group list...s&
*** Failed to open local group cache s5If this is the first time you have run newslist, thensuse the -a option to create it.is%02d%02d%02diiditrbsCannot open local group list (R!t	localtimeRtstattST_MTIMER:R>RtmarshaltloadR1(ttreefileRttreetimettreedatetdump((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt
readlocallistüs  	#

cCs`y7t|dƒ}tj||ƒ}WdQXd|GHWn"dG|GHdGHtjdƒnXdS(NtwbsSaved list to %s
s,Sorry - failed to write to local group caches8Does it (or its directory) have the correct permissions?i(RRDRIR:R>(RFRRIR((s-/usr/lib64/python2.7/Demo/scripts/newslist.pytwritelocallists
	cCs®dGHd}|jƒd}g}dGHtr4dGHnx`|D]X}|djƒd}tr†t|dƒt|dƒkr†|dGq;|j|ƒq;Wd	GHtrªd
GHn|S(NsGetting list of all groups...t010101is
Processing...s!
Ignoring following empty groups:iiRs
s(End of empty groups)(tlistt	skipemptyRtinttappend(tserverRHtinfoRRtgrpname((s-/usr/lib64/python2.7/Demo/scripts/newslist.pytgetallgroupss 
&cCsnd|G|j|dƒd}dt|ƒGHdGg}x+|D]#}|jƒd}|j|ƒq>WdGH|S(Ns/Getting list of new groups since start of %s...t000001isgot %d.s
Processing...itDone(t	newgroupsRRRQ(RRRHRSRRRT((s-/usr/lib64/python2.7/Demo/scripts/newslist.pytgetnewgroups/s
cCs<i}ttƒyDdtGHtjddkrAtjtƒ}nttƒ}t}Wn3tj	tj
fk
r‰}dG|GHdGHt}nX|rÇttj
ƒdkrÇtj
ddkrÇt|ƒ}n*ttƒ\}}|rñt||ƒ}n|rt||ƒtt|ƒnttƒdGHtt|d	ƒd
GHdS(NsConnecting to %s...it0sError connecting to host:s$I'll try to use just the local list.is-asCreating pages...RRW(R?RtnewshostR:tversionRtinittTruetnntplibt
error_tempt
error_permtFalseRtargvRURJRFRYRRLR7R2R'R(RR	t	connectedtxRRH((s-/usr/lib64/python2.7/Demo/scripts/newslist.pytmain=s0
	
	
.

t__main__(+R:R_RDR!RRt
expanduserttopdirR[RFR2RRRROR)R(tcurdirtenvirontdirRtrcfiletexiststexecfileRRBR tfilterRR,tpageRR
R'RR7R?RJRLRURYRft__name__(((s-/usr/lib64/python2.7/Demo/scripts/newslist.pyt<module>#sJ<	

!				*							)
Back to Directory File Manager