�`^c@sedZddlmZededd�[ddgZdefd��YZddd ��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/sys/lib/python2.7/multifile.pyR$scBs�eZdZdd�Zd�Zdd�Zd�Zd�Zd�Zd�Z d �Z
d
�Zd�Zd�Z
d
�ZRS(iicCsU||_g|_d|_d|_|rQd|_|jj�|_g|_ndS(Nii(tfptstacktleveltlasttseekablettelltstarttposstack(tselfRR
((s/sys/lib/python2.7/multifile.pyt__init__+s cCs*|jdkr|jS|jj�|jS(Ni(RtlastposRRR(R((s/sys/lib/python2.7/multifile.pyR5scCs�|j�}|re|dkr+||}qe|dkre|jdkrV||j}qbtd�qend|ko||kns�|jdkr�||jkr�td�n|jj||j�d|_d|_dS(Niiiscan't use whence=2 yetsbad MultiFile.seek() call(RRRRRtseekRR (Rtpostwhencethere((s/sys/lib/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
RR(Rtlinetmarkertitsep((s/sys/lib/python2.7/multifile.pyRKs6 "
cCs3g}x&|j�}|sPn|j|�q |S(N(Rtappend(RtlistR((s/sys/lib/python2.7/multifile.pyt readlinespscCsdj|j��S(NR(tjoinR%(R((s/sys/lib/python2.7/multifile.pytreadxscCscx|j�rqW|jdks+|jr/dSd|_d|_|jr_|jj�|_ndS(Nii(RRR R
RRR(R((s/sys/lib/python2.7/multifile.pytnext{s cCs`|jdkrtd�n|jj|�|jr\|jj|j�|jj�|_ndS(Nisbad MultiFile.push() call( RRRR#R
R
RRR(RR"((s/sys/lib/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 RRtmaxtpopR
R
(Rt
abslastpos((s/sys/lib/python2.7/multifile.pyR+�s
cCs|d dkS(Nis--((RR((s/sys/lib/python2.7/multifile.pyR�scCsd|S(Ns--((Rtstr((s/sys/lib/python2.7/multifile.pyR�scCsd|dS(Ns--((RR-((s/sys/lib/python2.7/multifile.pyR�s(RRR
RRRRR%R'R(R)R+RRR(((s/sys/lib/python2.7/multifile.pyR's
%
N((t__doc__twarningsRtDeprecationWarningt__all__t ExceptionRR(((s/sys/lib/python2.7/multifile.pyt<module>s
|