KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/task/21573/root/proc/21572/root/usr/lib64/python2.4/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/task/21573/root/proc/21572/root/usr/lib64/python2.4/mhlib.pyo
m
=5Dc@sFdZdZdZdZdZdkZdkZdkZdkZdk	Z	dk
Z
dklZddd	d
gZde
fdYZdfdYZeid
ZdZd	fdYZd
eifdYZdefdYZdfdYZddZddZdZedjoendS(s	MH interface -- purely object-oriented (well, almost)

Executive summary:

import mhlib

mh = mhlib.MH()         # use default mailbox directory and profile
mh = mhlib.MH(mailbox)  # override mailbox location (default from profile)
mh = mhlib.MH(mailbox, profile) # override mailbox and profile

mh.error(format, ...)   # print error message -- can be overridden
s = mh.getprofile(key)  # profile entry (None if not set)
path = mh.getpath()     # mailbox pathname
name = mh.getcontext()  # name of current folder
mh.setcontext(name)     # set name of current folder

list = mh.listfolders() # names of top-level folders
list = mh.listallfolders() # names of all folders, including subfolders
list = mh.listsubfolders(name) # direct subfolders of given folder
list = mh.listallsubfolders(name) # all subfolders of given folder

mh.makefolder(name)     # create new folder
mh.deletefolder(name)   # delete folder -- must have no subfolders

f = mh.openfolder(name) # new open folder object

f.error(format, ...)    # same as mh.error(format, ...)
path = f.getfullname()  # folder's full pathname
path = f.getsequencesfilename() # full pathname of folder's sequences file
path = f.getmessagefilename(n)  # full pathname of message n in folder

list = f.listmessages() # list of messages in folder (as numbers)
n = f.getcurrent()      # get current message
f.setcurrent(n)         # set current message
list = f.parsesequence(seq)     # parse msgs syntax into list of messages
n = f.getlast()         # get last message (0 if no messagse)
f.setlast(n)            # set last message (internal use only)

dict = f.getsequences() # dictionary of sequences in folder {name: list}
f.putsequences(dict)    # write sequences back to folder

f.createmessage(n, fp)  # add message from file f as number n
f.removemessages(list)  # remove messages in list from folder
f.refilemessages(list, tofolder) # move messages in list to other folder
f.movemessage(n, tofolder, ton)  # move one message to a given destination
f.copymessage(n, tofolder, ton)  # copy one message to a given destination

m = f.openmessage(n)    # new open message object (costs a file descriptor)
m is a derived class of mimetools.Message(rfc822.Message), with:
s = m.getheadertext()   # text of message's headers
s = m.getheadertext(pred) # text of message's headers, filtered by pred
s = m.getbodytext()     # text of message's body, decoded
s = m.getbodytext(0)    # text of message's body, not decoded
s
~/.mh_profiles~/Mails
.mh_sequencesiN(sbisecttMHtErrortFoldertMessagecBstZRS(N(t__name__t
__module__(((t/usr/lib64/python2.4/mhlib.pyRWscBstZdZeedZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZRS(s<Class representing a particular collection of folders.
    Optional constructor arguments are the pathname for the directory
    containing the collection, and the MH profile to use.
    If either is omitted or empty a default is used; the default
    directory is taken from the MH profile if it is specified there.cCs|djo
t}ntii||_|djo|id}n|p
t}ntii	|o*|ddjotii
d|}ntii|}tii|p
tdn||_dS(sConstructor.tPathit~sMH() path not foundN(
tprofiletNonet
MH_PROFILEtostpatht
expandusertselft
getprofiletPATHtisabstjointisdirR(RR
R	((Rt__init__bs



%
cCsd|i|ifS(sString representation.s
MH(%r, %r)N(RR
R	(R((Rt__repr__nscGstiid||dS(sARoutine to print an error.  May be overridden by a derived class.s
MH error: %s
N(tsyststderrtwritetmsgtargs(RRR((RterrorrscCst|i|S(s*Return a profile entry, None if not found.N(tpicklineRR	tkey(RR((RRvscCs|iS(s9Return the path (the name of the collection's directory).N(RR
(R((RtgetpathzscCs9ttii|idd}|p
d}n|S(s&Return the name of the current folder.tcontextsCurrent-FoldertinboxN(RRR
RRRR (RR ((Rt
getcontext~s	
cCsItii|id}t|d}|id||i
dS(s#Set the name of the current folder.R twsCurrent-Folder: %s
N(RR
RRRtfntopentfRR tclose(RR R&R$((Rt
setcontexts
cCssg}|i}xPti|D]?}tii||}tii	|o|i
|q"q"W|i|S(s*Return the names of the top-level folders.N(tfoldersRRR
RtlistdirtnameRtfullnameRtappendtsort(RR)R+R
R,((Rtlistfolderss
c	Cstii|i|}ti|i}|djogSng}ti
|}xx|D]p}tii||}tii|oBtii||}|i||d}|djoPqq[q[W|i|S(scReturn the names of the subfolders in a given folder
        (prefixed with the given folder name).iiN(RR
RRR+R,tstattst_nlinktnlinkst
subfoldersR*tsubnamestsubnametfullsubnameRtname_subnameR-R.(	RR+R4R6R3R5R2R,R7((Rtlistsubfolderss$





cCs
|idS(s<Return the names of all folders and subfolders, recursively.tN(Rtlistallsubfolders(R((Rtlistallfolderssc
Cs2tii|i|}ti|i}|djogSng}ti
|}x|D]}|ddjp
t
|oq[ntii||}tii|ortii||}|i|tii|p|i|}	||	}n|d}|djoPq q[q[W|i|S(s>Return the names of subfolders in a given folder, recursively.iit,iN(RR
RRR+R,R0R1R2R3R*R4R5t	isnumericR6RR7R-tislinkR:t
subsubfoldersR.(
RR+R4R6R3R5R2R,R7R?((RR:s.





cCs
t||S(s0Return a new Folder object for the named folder.N(RRR+(RR+((Rt
openfolderscCsht|id}|o t|ot|d}nt}ti	ti
i|i||dS(s@Create a new folder (or raise os.error if it cannot be created).sFolder-ProtectiN(RRR	tprotectR=tinttmodetFOLDER_PROTECTRtmkdirR
RRR+(RR+RARC((Rt
makefolderscCstii|i|}xgti|D]V}tii||}yti
|Wq+tij
o|id|q+Xq+Wti|dS(sDelete a folder.  This removes files in the folder but not
        subdirectories.  Raise os.error if deleting the folder itself fails.s%s not deleted, continuing...N(
RR
RRRR+R,R*R5R6tunlinkRtrmdir(RR+R6R5R,((Rtdeletefolders(RRt__doc__R
RRRRRR"R(R/R8R;R:R@RFRI(((RR[s													s
^[1-9][0-9]*$cCsti|dj	S(N(tnumericprogtmatchtstrR
(RM((RR=scBstZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZddZdZdZdZdZdZdZdZRS(s'Class representing a particular folder.cCs@||_||_tii|iptd|ndS(sConstructor.sno folder %sN(tmhRR+RR
RtgetfullnameR(RRNR+((RRs
		cCsd|i|ifS(sString representation.sFolder(%r, %r)N(RRNR+(R((RRscGs|ii|dS(sError message handler.N(RRNRR(RR((RRscCstii|ii|iS(s'Return the full pathname of the folder.N(RR
RRRNR+(R((RROscCstii|itS(s8Return the full pathname of the folder's sequences file.N(RR
RRROtMH_SEQUENCES(R((RtgetsequencesfilenamescCstii|it|S(s4Return the full pathname of a message in the folder.N(RR
RRRORMtn(RRR((RtgetmessagefilenamescCs|ii|iS(s!Return list of direct subfolders.N(RRNR8R+(R((RR8scCs|ii|iS(sReturn list of all subfolders.N(RRNR:R+(R((RR:scCsg}ti}|i}x8ti|iD]!}||o||q.q.Wt	t
|}|i|o|d|_n
d|_|S(sReturn the list of messages currently present in the folder.
        As a side effect, set self.last to the last message (or 0).iiN(
tmessagesRKRLR-RR*RROR+tmapRBR.tlast(RR+RTRLR-((Rtlistmessagess		

	cCsh}|i}yt|d}Wntj
o|SnXx|i}|pPn|i	d}t|djo!|id||i
fn|di
}t|di
di}|||<qBW|S(	s+Return the set of sequences for the folder.trit:isbad sequence in %s: %sit N(t	sequencesRRQR,R%R&tIOErrortreadlinetlinetsplittfieldstlenRtstripRtIntSetttolisttvalue(RR&R`ReRR[R,R^((Rtgetsequences%s&	!cCs|i}d}xm|iD]_\}}t	dd}|i||pt|d}n|i
d||ifqW|p.yti|Wqtij
oqXn|idS(s.Write the set of sequences back to the folder.R9RZR#s%s: %s
N(RRQR,R
R&R[t	iteritemsRtseqRctstfromlistR%RttostringRRGRR'(RR[RhR&RiRR,((Rtputsequences9s 

!	cCsG|i}yt|dSWn"ttfj
otdnXdS(s<Return the current message.  Raise Error when there is none.tcursno cur messageN(RRftseqstmaxt
ValueErrortKeyErrorR(RRn((Rt
getcurrentJscCs#t|idt|ddS(sSet the current message.RmiN(t
updatelineRRQRMRR(RRR((Rt
setcurrentRscCs|i}|ptd|in|djo|Sn|id}|djo|| d||d}}}|d djo|d |d}}nt|ptd|nyt|}Wn%ttfj
ot|}nXy|i||}Wntj
o}
|i}	||	jo/|
pd|}
nt|
tid	n|	|}|ptd
|n|djo
||Sq.|| Sq2X|p|djo
d}qn|djo+t||}|td|||!Sq2t||d}||||!Sn|id}|djo|i|| |}|i||d|}t||d}t||}
|||
!}|ptd|n|Sny|i||}WnXtj
oL}
|i}	||	jo"|
pd|}
nt|
n|	|SnEX||jo/t|otd|qtd|n|gSdS(sParse an MH sequence specification into a message list.
        Attempt to mimic mh-sequence(5) as close as possible.
        Also attempt to mimic observed behavior regarding which
        conditions cause which error messages.sno messages in %stallRYiR9is-+sbad message list %sissequence %s emptyt-tprevRVsmessage %d doesn't exists
no %s messageN(Rwslast( RRWRuRR+RhtfindtitheadtdirttailR=RBtcountRpt
OverflowErrorRat_parseindextanchorRRfRnRtexc_infotmsgstbisectRotbegintendtjRXRR(RRhRuRRRRRR|RzRnRR}RyRRXRR{((Rt
parsesequenceVs~

 














cCslt|o5yt|SWqBttfj
otiSqBXn|d
jo|iSn|djo|dSn|djo|dSn|djoJ|i}t||}y||SWqt
j
otdqXn|d	jol|i}t||d
}|djo
tdny||d
SWq_t
j
otdq_XntddS(s7Internal: parse a message number (or cur, first, etc.).Rmt.tfirstiRVitnextsno next messageRwisno prev messageN(scurR(R=RhRBR~RpRtmaxintRRrRuRRRRyt
IndexErrorRR
(RRhRuRyRR((RRs:







cCs
t||S(s+Open a message -- returns a Message object.N(RRRR(RRR((RtopenmessagescCsg}g}x|D]}|i|}|idt|}yt	i
|Wnt	ij
onXyt	i||Wn%t	ij
o}|i|qX|i|qW|o|i|n|o=t|djot	i|dqt	id|fndS(s2Remove one or more messages -- may raise os.error.R<iismultiple errors:N(terrorstdeletedtlistRRRRSR
RMt	commapathRRGRtrenameRR-tremovefromallsequencesRa(RRRRRRRRR
((Rtremovemessagess,icCsg}h}
x|D]}|id}|i|}	|i|}yti|	|Wnti
j
oy!ti|	|ti|	Wqtti
fj
oC}|i|yti|Wqti
j
oqXqqXnX|i|||
|<qW|
o8|o|i||
in|i|
in|o=t|djoti
|dqti
d|fndS(s_Refile one or more messages -- may raise os.error.
        'tofolder' is an open folder object.iismultiple errors:N(RtrefiledRRRttofoldertgetlastttonRRSR
ttopathRRRtshutiltcopy2RGR\RR-tsetlastt
keepsequencest_copysequencestitemsRtkeysRa(RRRRRRRRRRR
R((Rtrefilemessagess>


cCs|i}|i}
d}x|iD]\}}y|
|}	d}Wntj
og}	d}nXx8|D]0\}}||jo|	i|d}qtqtW|o|	o|	|
|<q+q+W|o|i|
ndS(s.Helper for refilemessages() to copy sequences.iiN(t
fromfolderRft
fromsequencesRttosequencestchangedRR+RhttoseqtnewRqtrefileditemstfromnRR-Rl(RRRRRhRRRRRRR+((RR	s*




c	Cs+|i|}t|}|i~|i|}|id|}yti||Wnti
j
onXyti||Wnti
j
ozd}z'|idti||d}Wd|p.yti|Wqti
j
oqXnXti|nX|i|gdS(saMove one message over a specific destination message,
        which may or may not already exist.s,%diiN(RRSRRR
R%R&R'RRRtbackuptopathRRRtokRR
RRRGR(	RRRRRRRR&RR
((Rtmovemessages6



c	Cs|i|}t|}|i~|i|}|id|}yti||Wnti
j
onXd}z'|idti||d}Wd|p.yti|Wqti
j
oqXnXdS(saCopy one message over a specific destination message,
        which may or may not already exist.s,%diiN(RRSRRR
R%R&R'RRRRRRRRRR
RRRG(	RRRRRRRR&RR
((Rtcopymessage>s,


c	Cs|i|}|id|}yti||Wntij
onXd}dd}zSt
|d}x-|i
|}|pPn|i|qtW|id}Wd|p.yti|Wqtij
oqXnXdS(s3Create a message, with text from the open file txt.s,%diiiR#iN(RRSRRR
t
backuppathRRRRtBUFSIZER%R&ttxttreadtbufRR'RG(	RRRRRRR&RRR
((Rt
createmessageXs2


cCst|do|i|jo
|`n|i}d}xu|iD]g\}}|djoqInxD|D]<}||jo)|i|d}|p||=qqpqpWqIW|o|i|ndS(s`Remove one or more messages from all sequences (including last)
        -- but not from 'cur'!!!RViRmiN(
thasattrRRVRRfR[RRR+RhRRtremoveRl(RRR+RhRRRR[((RRrs$ 




cCs%t|dp|in|iS(sReturn the last message number.RVN(RRRWRV(R((RRscCs8|djot|do
|`q4n
||_dS(sSet the last message number.RVN(RVR
RR(RRV((RRs

(RRRJRRRRORQRSR8R:RWRfRlRrRtRRRRRRRRRRRR(((RRs4														T			#		 				cBsGtZddZdZddZddZdZdZRS(NcCsX||_||_|djo"|i|}t	|d}nt
ii||dS(sConstructor.RXN(
R&RtfolderRRtnumbertfpR
RSR
R%t	mimetoolsRR(RR&RRRR
((RRs		
cCsdt|i|ifS(sString representation.sMessage(%s, %s)N(treprRRR(R((RRscCs|djodi|iSng}d}xt|iD]i}|dip:|id}|djo||| i
}qn|o|i|q7q7Wdi|S(sReturn the message's header text as a string.  If an
        argument is specified, it is used as a filter predicate to
        decide which headers to return (its argument is the header
        name converted to lower case).R9iRYN(tpredR
RRtheadersthitR^tisspaceRxRytlowerR-(RRRRyRR^((Rt
getheadertexts


icCs{|ii|i|i}|p
|djo|iiSndkl}|}t
i|i|||iS(sReturn the message's body text as string.  This undoes a
        Content-Transfer-Encoding, but does not interpret other MIME
        features (e.g. multipart messages).  To suppress decoding,
        pass 0 as an argument.R9t7bitt8bittbinary(sStringION(R9RRR(RRtseektstartofbodytgetencodingtencodingtdecodeRtStringIOtoutputRtgetvalue(RRRRR((Rtgetbodytexts
	cCs|idjo
tdn|id}|p
tdn|ii|iti	|i}|i|g}xQ|i
oCd|idt|f}t|i||}|i|q~W|i|S(sOnly for multipart messages: return the message's body as a
        list of SubMessage objects.  Each submessage object behaves
        (almost) as a Message object.t	multipartsContent-Type is not multipart/*tboundarys"multipart/* without boundary params%s.%riN(RtgetmaintypeRtgetparamtbdryRRRt	multifilet	MultiFiletmftpushtpartsRRRaRRt
SubMessageRtpartR-tpop(RRRRRRR((Rtgetbodypartss"




cCs/|idjo|iSn|iSdS(s3Return body, either a string or a list of messages.RN(RRRR(R((Rtgetbodys(	RRR
RRRRRR(((RRs			RcBs8tZdZdZddZdZdZRS(NcCsmti|||||idjoti||_nti	||_ti	|dd|_
dS(sConstructor.RRiN(RRRR&RRRRRtbodyRtbodyencoded(RR&RRR((RRscCs.|i|i|i}}}d|||fS(sString representation.sSubMessage(%s, %s, %s)N(RRRRR&RR(RRRRR&((RRsicCs=|p|iSnt|itdjo|iSndS(NR9(RRRttypeR(RR((RRscCs+t|itgjo|iSndS(N(RRR(R((RRscCs|iS(N(RR(R((RRs(RRRRRRR(((RRs
	
		RccBstZdZedddZdZdZdZdZdZ	d	Z
d
ZdZdZ
d
ZdZdZdZdZdZRS(sClass implementing sets of integers.

    This is an efficient representation for sets consisting of several
    continuous ranges, e.g. 1-100,200-400,402-1000 is represented
    internally as a list of three pairs: [(1,100), (200,400),
    (402,1000)].  The internal representation is always kept normalized.

    The constructor has up to three arguments:
    - the string used to initialize the set (default ''),
    - the separator between ranges (default ',')
    - the separator between begin and end of a range (default '-')
    The separators must be strings (not regexprs) and should be different.

    The tostring() function yields a string that can be passed to another
    IntSet constructor; __repr__() is a valid IntSet constructor itself.
    R<RvcCs7g|_||_||_|o|i|ndS(N(Rtpairstseptrngtdatat
fromstring(RRRR((RRs
			cCs
g|_dS(N(RR(R((RtresetscCst|i|iS(N(tcmpRRtother(RR((Rt__cmp__scCs
t|iS(N(thashRR(R((Rt__hash__scCsd|i|i|ifS(NsIntSet(%r, %r, %r)(RRkRR(R((RR"scCs|iid}x|t|ijow|i|d\}}|i|\}}||djo.|t	||fg|i|d|d+q|d}qWdS(Ni(
RRR.RyRatalotahitblotbhiRo(RRRRyRR((Rt	normalize%s
.cCsd}xs|iD]h\}}||jot|}nt||it|}|o||i|}q|}qW|S(NR9(	RiRRtlothiRttRR(RRRiRR((RRk0s


cCsAg}x4|iD])\}}t||d}||}qW|S(Ni(tlRRRRtrangetm(RRRRR((RRd9s
cCs"x|D]}|i|qWdS(N(RRyRR-(RRRy((RRj@scCst}|i|_|S(N(RcRRR(RR((RtcloneDs	
cCs|iddS(Ni(RR(R((RtminIscCs|iddS(Ni(RR(R((RRoLscCsDx=|iD]2\}}||jo
|jnotSq
q
WtS(N(RRRRtxtTruetFalse(RRRR((RtcontainsOs

cCsxtt|iD]}|i|\}}||jo|d|jo||f|i|<n|ii|||f|djo_|d|i|ddjo?|i|dd|i|dfg|i|d|d+ndSn||jodSqqWt|id}|djoC|i|\}}|d|jo||f|i|<dSqmn|ii	||fdS(Nii(
RRaRRRyRRRtinsertR-(RRRyRR((RR-Ts&
-?

cCs9||jodSn|ii||f|idS(N(txlotxhiRRR-R(RRR((Rtaddpairms
cCsg}x|i|iD]}g}x9|i|iD]%}|i	}|it|q8Wt
|djo|i|d|dfqt
|djo4|d|djo|i|d|dfqtdqW|i||_|idS(Niiisbad data passed to IntSet(RRR_RRRRRtsubpRbRiR-RBRaRpRR(RRRRRiRR((RRrs(
(RRRJR
RRRRRRRkRdRjRRRoRR-RR(((RRcs"															icCsyt|d}Wntj
odSnXti|d}ti	||oti}x|i
}|pPn|i|o_|t|d}x:|i
}|p|dioPn||}qW|iSq_q_WdS(NRXRYii(R%tfileR&R\R
tretescapeRtpattcompiletcasefoldt
IGNORECASEtprogR]R^RLRattextRRb(RRRRR&RRR^((RRs*	cCsly)t|d}|i}|iWntj
o
g}nXti|d}ti||oti
}
|djo
d}nd||f}xytt|D]G}||}|
i|o'|djo||=n|||<PqqW|dj	o|i|n|d}	t|	d}x|D]}|i|q7W|iti|	|dS(NRXs:(.*)
s%s: %s
RR#(R%RR&t	readlinestlinesR'R\RRRRRRRRReR
tnewlineRRaRyR^RLR-ttempfileRRR(RRReRRR&RyRR
RRR^((RRss8




	


c	Cstidtad}|d|dddddd	d
g}x|D]}|d|fqRW|d|d
tida|d|d|dti	}tddi|d<|GHti
||dx%t|D]}|d|fqW|dti}ti|a|dxdddddddddd d!d"d#d$d%d&d'd(d)gD]v}y|d*|fWntj
o}d+G|GHnXtid,|fi}tt|i}|Gd-GHqW|d.dS(/Nsrm -rf $HOME/Mail/@testcCs|GHt|GHdS(N(Riteval(Ri((Rtdossmh.listfolders()smh.listallfolders()s@tests@test/test1s@test/test2s@test/test1/test11s@test/test1/test12s@test/test1/test11/test111smh.makefolder(%r)smh.listsubfolders('@test')smh.listallsubfolders('@test')sf.listsubfolders()sf.listallsubfolders()sf.getsequences()s
1-10 12-20RZtfoosmh.deletefolder(%r)smh.getcontext()sf.getcurrent()RRVRmRRwRsfirst:3slast:3scur:3scur:-3sprev:3snext:3s1:3s1:-3s100:3s100:-3s10000:3s10000:-3Rusf.parsesequence(%r)sError:spick %r 2>/dev/nulls<-- picksf.listmessages()(RtsystemRRNRttestfoldersRR@R&RfRnRcRdRltreversedR"R RhRRtpopenRtstuffRURBR_R(	RRhRRRRRR Rn((RttestsL
		











@
t__main__(RJRRRPRDRRRRRRRt__all__t	ExceptionRRRRKR=RRRRcRRsRR(RRcRRRRRR=RRDRRRRKRRPRsRRRRRR((Rt?6s4
						
	J"	*


Anon7 - 2021