ó DÑÕfc@sedZddlmZededdƒ[ddgZdefd„ƒYZdd d „ƒYZd S( s­A readline()-style interface to the parts of a multipart message. The MultiFile class makes each part of a multipart message "feel" like an ordinary file, as long as you use fp.readline(). Allows recursive use, for nested multipart messages. Probably best used together with module mimetools. Suggested use: real_fp = open(...) fp = MultiFile(real_fp) "read some lines from fp" fp.push(separator) while 1: "read lines from fp until it returns an empty string" (A) if not fp.next(): break fp.pop() "read remaining lines from fp until it returns an empty string" The latter sequence may be used recursively at (A). It is also allowed to use multiple push()...pop() sequences. If seekable is given as 0, the class code will not do the bookkeeping it normally attempts in order to make seeks relative to the beginning of the current file part. This may be useful when using MultiFile with a non- seekable stream object. iÿÿÿÿ(twarns9the multifile module has been deprecated since Python 2.5t stacklevelit MultiFiletErrorcBseZRS((t__name__t __module__(((s!/usr/lib64/python2.7/multifile.pyR$scBs€eZdZdd„Zd„Zdd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z d „Z d „ZRS(iicCsU||_g|_d|_d|_|rQd|_|jjƒ|_g|_ndS(Nii(tfptstacktleveltlasttseekablettelltstarttposstack(tselfRR ((s!/usr/lib64/python2.7/multifile.pyt__init__+s     cCs*|jdkr|jS|jjƒ|jS(Ni(RtlastposRR R (R((s!/usr/lib64/python2.7/multifile.pyR 5scCsÙ|jƒ}|re|dkr+||}qe|dkre|jdkrV||j}qbtd‚qend|ko||kn s |jdkr¬||jkr¬td‚n|jj||jƒd|_d|_dS(Niiiscan't use whence=2 yetsbad MultiFile.seek() call(R RRRRtseekR R (Rtpostwhencethere((s!/usr/lib64/python2.7/multifile.pyR:s      cCsX|jdkrdS|jjƒ}|set|jƒ|_|jdk|_|jratd‚ndS|jdkszt‚|j|ƒr|S|j ƒ}xkt t |jƒƒD]P\}}||j |ƒkrÝd|_Pq¯||j |ƒkr¯d|_Pq¯q¯W|S|jr,|jƒt|ƒ|_n|d|_|jdkrTtd‚ndS(Nits"sudden EOF in MultiFile.readline()is)Missing endmarker in MultiFile.readline()(RRtreadlinetlenRR RtAssertionErrortis_datatrstript enumeratetreversedtsection_dividert end_markerR R R(Rtlinetmarkertitsep((s!/usr/lib64/python2.7/multifile.pyRKs6   "     cCs3g}x&|jƒ}|sPn|j|ƒq |S(N(Rtappend(RtlistR((s!/usr/lib64/python2.7/multifile.pyt readlinesps cCsdj|jƒƒS(NR(tjoinR%(R((s!/usr/lib64/python2.7/multifile.pytreadxscCscx|jƒrqW|jdks+|jr/dSd|_d|_|jr_|jjƒ|_ndS(Nii(RRR R RR R (R((s!/usr/lib64/python2.7/multifile.pytnext{s   cCs`|jdkrtd‚n|jj|ƒ|jr\|jj|jƒ|jjƒ|_ndS(Nisbad MultiFile.push() call( RRRR#R R R RR (RR"((s!/usr/lib64/python2.7/multifile.pytpush…s   cCs°|jgkrtd‚n|jdkr6d|_n|j|j}td|jdƒ|_|jjƒ|jr¬|j jƒ|_|jdkr¬||j|_q¬ndS(Nsbad MultiFile.pop() callii( RRRR RR tmaxtpopR R (Rt abslastpos((s!/usr/lib64/python2.7/multifile.pyR+s    cCs|d dkS(Nis--((RR((s!/usr/lib64/python2.7/multifile.pyR›scCsd|S(Ns--((Rtstr((s!/usr/lib64/python2.7/multifile.pyRžscCs d|dS(Ns--((RR-((s!/usr/lib64/python2.7/multifile.pyR¡s(RRR RR RRR%R'R(R)R+RRR(((s!/usr/lib64/python2.7/multifile.pyR's   %      N((t__doc__twarningsRtDeprecationWarningt__all__t ExceptionRR(((s!/usr/lib64/python2.7/multifile.pyts