+
    i{> c                   s   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t^ RI
t^ RIt^ RIt^ RIHt  ^ RIt. R6Ot]P$                  P'                  R4      t ! R R4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R	]P8                  P:                  4      t ! R  R
]4      t ! R! R"]4      t ! R# R]4      t  ! R$ R]4      t! ! R% R]4      t" ! R& R]4      t# ! R' R(4      t$ ! R) R*]$4      t%R7R+ lt&R, t'R- t(R. t)R/ t*R0 t+ ! R1 R],4      t- ! R2 R]-4      t. ! R3 R]-4      t/ ! R4 R]-4      t0 ! R5 R]-4      t1R#   ] d    Rt ELEi ; i)8zDRead/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.N)GenericAliasMailboxMaildirmboxMHBabylMMDFMessageMaildirMessagemboxMessage	MHMessageBabylMessageMMDFMessageErrorNoSuchMailboxErrorNotEmptyErrorExternalClashErrorFormatErrorasciic                   s  a  ] tR t^"t o RtR$R ltR tR tR tR t	R t
R%R	 ltR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR%R ltR tR%R ltR tR tR t R t!R  t"R!t#R&R" lt$]%! ]&4      t'R#t(V t)R# )'r   z*A group of messages in a particular place.Nc                s    \         P                  P                  \         P                  P                  V4      4      V n        W n        R# )zInitialize a Mailbox instance.N)ospathZabspathZ
expanduser_path_factoryselfr   factorycreate   &&&& /usr/lib64/python3.14/mailbox.py__init__ZMailbox.__init__%   s*    WW__RWW%7%7%=>
    c                    \        R4      h)$Add message and return assigned key.&Method must be implemented by subclassZNotImplementedErrorr   message   &&r   addZMailbox.add*       !"JKKr   c                r   )=Remove the keyed message; raise KeyError if it doesn't exist.r!   r"   r   keyr%   r   removeZMailbox.remove.   r'   r   c                s(    V P                  V4       R # N)r+   r)   r%   r   __delitem__ZMailbox.__delitem__2   s    Cr   c                sN     V P                  V4       R#   \         d     R# i ; iz'If the keyed message exists, remove it.N)r+   KeyErrorr)   r%   r   discardZMailbox.discard5   s%    	KK 		s    $$c                r   )>Replace the keyed message; raise KeyError if it doesn't exist.r!   r"   r   r*   r$      &&&r   __setitem__ZMailbox.__setitem__<   r'   r   c                sL     V P                  V4      #   \         d    Tu # i ; i)z9Return the keyed message, or default if it doesn't exist.)__getitem__r/   )r   r*   defaultr3   r   getZMailbox.get@   s,    	##C(( 	N	s    ##c                s   V P                   '       g   V P                  V4      # \        P                  ! V P	                  V4      4      ;_uu_ 4       pV P                  V4      uuRRR4       #   + '       g   i     R# ; i)z=Return the keyed message; raise KeyError if it doesn't exist.N)r   get_message
contextlibZclosingget_file)r   r*   Zfile   && r   r5   ZMailbox.__getitem__G   sS    }}}##C((##DMM#$6774}}T* 8777s   A--A>	c                r   )4Return a Message representation or raise a KeyError.r!   r"   r)   r%   r   r8   ZMailbox.get_messageO   r'   r   c                sh    \         P                  ! V P                  V4      4      P                  4       # )zReturn a string representation or raise a KeyError.

Uses email.message.Message to create a 7bit clean string
representation of the message.emailmessage_from_bytes	get_bytesZ	as_stringr)   r%   r   
get_stringZMailbox.get_stringS   s'    
 ''s(;<FFHHr   c                r   )z8Return a byte string representation or raise a KeyError.r!   r"   r)   r%   r   r@   ZMailbox.get_bytesZ   r'   r   c                r   )6Return a file-like representation or raise a KeyError.r!   r"   r)   r%   r   r:   ZMailbox.get_file^   r'   r   c                r   )Return an iterator over keys.r!   r"   r      &r   iterkeysZMailbox.iterkeysb   r'   r   c                4    \        V P                  4       4      # )zReturn a list of keys.)listrF   rD   rE   r   keysZMailbox.keysf   s    DMMO$$r   c              #  sz   "   V P                  4        F  p W,          pTx  K  	  R#   \         d     K$  i ; i5i)z%Return an iterator over all messages.NrF   r/   r   r*   Zvalue   &  r   
itervaluesZMailbox.itervaluesj   s;     ==?C	 K #  s   ;)
;8;8;c                s"    V P                  4       # r,   )rM   rD   rE   r   __iter__ZMailbox.__iter__s   s      r   c                rG   )z,Return a list of messages. Memory intensive.)rH   rM   rD   rE   r   valuesZMailbox.valuesv   s    DOO%&&r   c              #  s|   "   V P                  4        F  p W,          pY3x  K  	  R#   \         d     K%  i ; i5i)z.Return an iterator over (key, message) tuples.NrJ   rK   rL   r   	iteritemsZMailbox.iteritemsz   s>     ==?C	 , #  s   <*<9<9<c                rG   )z9Return a list of (key, message) tuples. Memory intensive.)rH   rP   rD   rE   r   itemsZMailbox.items   s    DNN$%%r   c                r   )9Return True if the keyed message exists, False otherwise.r!   r"   r)   r%   r   __contains__ZMailbox.__contains__   r'   r   c                r   )*Return a count of messages in the mailbox.r!   r"   rD   rE   r   __len__ZMailbox.__len__   r'   r   c                sV    V P                  4        F  pV P                  V4       K  	  R# )zDelete all messages.N)rI   r0   r)      & r   clearZMailbox.clear   s    99;CLL r   c                s`     W,          pT P                  T4       T#   \          d    Tu # i ; i)z3Delete the keyed message and return it, or default.)r/   r0   )r   r*   r6   result   &&& r   popZMailbox.pop   s7    	YF 	S  	N	s    --c                sj    V P                  4        F  pWP                  V4      3u # 	  \        R4      h)z6Delete an arbitrary (key, message) pair and return it.zNo messages in mailbox)rF   rZ   r/   r)   rV   r   popitemZMailbox.popitem   s1    ==?C#'' # 344r   c                s   \        VR4      '       d   VP                  4       pM%\        VR4      '       d   VP                  4       pMTpRpV F
  w  rE WPV&   K  	  V'       d   \        R4      hR#   \         d    Rp K3  i ; i)z4Change the messages that correspond to certain keys.rP   rQ   FTzNo message with key(s)N)hasattrrP   rQ   r/   )r   ZargZsourceZbad_keyr*   r$   s   &&    r   updateZMailbox.update   s    3$$]]_FS'""YY[FF"LC#S	 #
 344   s   A00B Bc                r   )&Write any pending changes to the disk.r!   r"   rD   rE   r   flushZMailbox.flush   r'   r   c                r   )Lock the mailbox.r!   r"   rD   rE   r   lockZMailbox.lock   r'   r   c                r   )#Unlock the mailbox if it is locked.r!   r"   rD   rE   r   unlockZMailbox.unlock   r'   r   c                r   )Flush and close the mailbox.r!   r"   rD   rE   r   closeZMailbox.close   r'   r   c                sZ     VP                  R 4      #   \         d    \        R4      hi ; i)r   z?String input must be ASCII-only; use bytes or a Message instead)encodeZUnicodeError
ValueErrorr#   r%   r   _string_to_bytesZMailbox._string_to_bytes   s7    	2>>'** 	2 1 2 2	2s    *Fc                s>   \        V\        P                  P                  4      '       d   \        P
                  ! 4       p\        P                  P                  WC^ 4      pVP                  V4       VP                  ^ 4       VP                  4       pVP                  R\        4      pVP                  V4       V P                  '       d5   VP                  \        4      '       g   VP                  \        4       R# R# R# \        V\         \"        \        P$                  34      '       d   \        V\        P$                  4      '       d-   \&        P(                  ! R\*        ^4       VP-                  4       p\        V\         4      '       d   V P/                  V4      pV'       d   VP                  RR4      pVP                  R\        4      pVP                  V4       V P                  '       d5   VP                  \        4      '       g   VP                  \        4       R# R# R# \1        VR4      '       EdJ   \1        VR4      '       d)   \&        P(                  ! R\*        ^4       VP2                  pRp VP5                  4       pVP                  R	4      '       d   VRR R,           pM#VP                  R
4      '       d   VRR R,           pV'       g   MZV'       d(   VP7                  R4      '       d   RVR,          ,           pVP                  R\        4      pVP                  V4       TpK  V P                  '       d?   V'       d5   VP                  \        4      '       g   VP                  \        4       R# R# R# R# \9        R\;        V4      ,          4      h)z%Dump message contents to target file.   
8Use of StringIO input is deprecated, use BytesIO insteads   
From s   
>From readbufferDUse of text mode files is deprecated, use a binary mode file insteadN   
      From s   >From i   NNInvalid message type: %s)
isinstancer>   r$   r   ioBytesIO	generatorBytesGeneratorflattenseekrk   replacelinesepwrite_append_newlineendswithstrbytesStringIOwarningswarnDeprecationWarninggetvaluerh   r\   rl   readline
startswith	TypeErrortype)	r   r$   ZtargetZmangle_from_rl   ZgendataZlastlinelines	   &&&&     r   _dump_messageZMailbox._dump_message   s    gu}}4455ZZ\F//00qICKK KKN;;=D<<w/DLL###DMM',B,BW% -C# #ubkk!:;;'2;;// *+=qB!**,'3''//8!//*kBooeW5GLL!###G,<,<W,E,EW% -F# Wf%%w)) 56H!M!..H'')==))9u,D]]5))9u,DDOOH$=$=$tBx/D||E73T"###9J9J79S9SW% :T# 6gFGGr   )r   r   NTr,   F)*__name__
__module____qualname____firstlineno____doc__r   r&   r+   r-   r0   r4   r7   r5   r8   rA   r@   r:   rF   rI   rM   rN   rO   rP   rQ   rS   rU   rW   rZ   r[   r]   r_   ra   rc   re   rh   r   r   classmethodr    __class_getitem____static_attributes____classdictcell____classdict__   @r   r   r   "   s     4 
LLL+LILLL%!'&LL
55"LLLL2 O4Hl $L1r   c                   s  a  ] tR tRt o RtRtR(R ltR tR tR t	R	 t
R
 tR tR tR tV 3R lR ltR tV 3R lR ltV 3R lR ltV 3R lR ltR tR tR tR tR tR tR tR tR tR  tR! tR" t^t R# t!R$ t"R% t#R& t$R't%V t&R# ))r   i  zA qmail-style Maildir mailbox.:Nc           	     s   \         P                  WW#4       R\        P                  P	                  V P
                  R4      R\        P                  P	                  V P
                  R4      R\        P                  P	                  V P
                  R4      /V n        \        P                  P                  V P
                  4      '       gx   V'       d[   \        P                  ! V P
                  R4       V P                  P                  4        F  p\        P                  ! VR4       K  	  M\        V P
                  4      h/ V n        R^ R^ /V n        ^ V n        RV n        R# )zInitialize a Maildir instance.tmpnewcur  g?N)r   r   r   r   joinr   _pathsexistsmkdirrO   r   _toc_toc_mtimes
_last_read_skewfactor)r   dirnamer   r   r   s   &&&& r   r   ZMaildir.__init__  s    8277<<

E2277<<

E2277<<

E2
 ww~~djj))U+ KK..0DHHT5) 1 )44	!1eQ/r   c                s.   V P                  4       p V P                  W4       \        T4       \        T\        4      '       dE   TP                  4       pT P                  TP                  4       ,           pY@P                  8X  d   RpMRpRp\        P                  P                  TP                  4      P                  T P                  4      ^ ,          p\        P                  P!                  T P"                  Y5T,           4      p\        T\        4      '       dY   \        P$                  ! TP                  \        P                  P'                  TP                  4      TP)                  4       34         \        P*                  ! TP                  T4       \        P
                  ! TP                  4       T#   \         d3    TP                  4        \        P
                  ! TP                  4       h i ; i  \,        \.        3 d&    \        P0                  ! TP                  T4        T# i ; i  \2         dX   p\        P
                  ! TP                  4       TP4                  \4        P6                  8X  d   \9        RT,          4      hh Rp?ii ; i)r     r   z$Name clash with existing message: %sN)_create_tmpr   BaseExceptionre   r   r+   name_sync_closeru   r   
get_subdircolonget_infor   Zbasenamesplitr   r   utimegetatimeget_datelinkAttributeErrorPermissionErrorrenameOSErrorerrnoZEEXISTr   )r   r$   Ztmp_filesubdirsuffixuniqZdeste   &&      r   r&   ZMaildir.add$  s   ##%	w1
 	Hg~..'')FZZ'"2"2"44F#FFww.44TZZ@Cww||DJJv>g~..HHX]]gg&&x}}5w7G7G7IJL
	)t, 		(--( G  	NNIIhmm$	0 #O4 /		(--. /  	IIhmm$ww%,,&()O+/*0 1 1 	sB   F9 6!G9  H2 9=G692H/+H2 .H//H2 2J=AJJc                s    \         P                  ! \         P                  P                  V P                  V P                  V4      4      4       R# r(   N)r   r+   r   r   r   _lookupr)   r%   r   r+   ZMaildir.removeN  s*    
		"'',,tzz4<<+<=>r   c                sZ     V P                  V4       R#   \        \        3 d     R# i ; ir.   )r+   r/   FileNotFoundErrorr)   r%   r   r0   ZMaildir.discardR  s+    	KK+, 		s    **c                s&   V P                  V4      pV P                  V4      pV P                  V4      p\        V\        4      '       d   TpMTp\        P
                  P                  V4      pV P                  V9   d5   V P                  VP                  V P                  4      R,          ,           pMRpV P                  V4       \        P
                  P                  V P                  V4      p	\        P
                  P                  V P                  WqV,           4      p
\        V\        4      '       dE   \        P                  ! V	\        P
                  P                  V	4      VP                  4       34       \        P                  ! W4       R# )r1   r   Nrt   )r   r&   ru   r   r   r   r   r   r   r0   r   r   r   r   r   r   )r   r*   r$   old_subpathZtemp_keyZtemp_subpathZdominant_subpathr   r   Ztmp_pathnew_paths   &&&        r   r4   ZMaildir.__setitem__Z  s   ll3'88G$||H-g~..+  +!12::))ZZ"2"8"8"DR"HHFFS77<<

L977<<

F&LAg~..HHXgg&&x0'2B2B2DEG
 			(%r   c                s   V P                  V4      p\        \        P                  P	                  V P
                  V4      R4      ;_uu_ 4       pV P                  '       d   V P                  V4      pM\        V4      pRRR4       \        P                  P                  V4      w  rVXP                  V4       V P                  V9   d2   VP                  VP                  V P                  4      R,          4       VP                  \        P                  P                  \        P                  P	                  V P
                  V4      4      4       V#   + '       g   i     L; i)r<   rbNrt   )r   openr   r   r   r   r   r   r   
set_subdirr   set_infoset_dategetmtime)r   r*   subpathfmsgr   r      &&     r   r8   ZMaildir.get_messageu  s    ,,s#"'',,tzz73T::a}}}mmA&$Q'	 ;
 ww}}W-v::LLDJJ/34RWW%%bggll4::w&GHI
 ;:s   0EE"	c                s   \        \        P                  P                  V P                  V P                  V4      4      R4      ;_uu_ 4       pVP                  4       P                  \        R4      uuRRR4       #   + '       g   i     R# ; i)2Return a bytes representation or raise a KeyError.r   ri   N)	r   r   r   r   r   r   rk   r|   r}   r   r*   r   r;   r   r@   ZMaildir.get_bytes  sS    "'',,tzz4<<+<=tDD668##GU3 EDDDs   $A;;B	c                s    \        \        P                  P                  V P                  V P                  V4      4      R4      p\        V4      # )rB   r   )r   r   r   r   r   r   
_ProxyFiler   r;   r   r:   ZMaildir.get_file  s4    djj$,,s*;<dC!}r   c                s    V P                  V4      pV P                  V9   d#   VP                  V P                  4      R,          # R# )z+Get the keyed message's "info" as a string.r   rt   )r   r   r   )r   r*   r   r;   r   r   ZMaildir.get_info  s7    ,,s#:: ==,R00r   c                    < V ^8  d   QhRS[ /# )   infor   Zformatr      "r   __annotate__Maildir.__annotate__  s     % %# %r   c                s   \        V\        4      '       g   \        R\        V4       24      hV P	                  V4      pVP                  V P                  4      ^ ,          pV'       d   W@P                  V,           ,          pWC8X  d   R# \        P                  P                  V P                  V4      p\        P                  P                  V P                  V4      p\        P                  ! WV4       W@P                  V&   R# )z&Set the keyed message's "info" string.zinfo must be a string: N)ru   r   r   r   r   r   r   r   r   r   r   r   r   )r   r*   r   r   Znew_subpathZold_pathr   s   &&&    r   r   ZMaildir.set_info  s    $$$5d4j\BCCll3'!''

3A6::,,K%77<<

K877<<

K8
		(%$		#r   c                sh    V P                  V4      pVP                  R4      '       d
   VR,          # R# )zHReturn as a string the standard flags that are set on the keyed message.2,r   NNr   )r   r   )r   r*   r   r;   r   	get_flagsZMaildir.get_flags  s+    }}S!??4  8Or   c                r   )r   flagsr   r   r   r   r   r     s     ? ?C ?r   c                s    \        V\        4      '       g   \        R\        V4       24      hV P	                  VRRP                  \        \        V4      4      4      ,           4       R# )z>Set the given flags and unset all others on the keyed message.zflags must be a string: r   r   N)ru   r   r   r   r   r   sortedset)r   r*   r   r3   r   	set_flagsZMaildir.set_flags  sK    %%%6tE{mDEEc4"''&U*<"==>r   c                r   r   flagr   r   r   r   r   r     s     K K# Kr   c           
     s    \        V\        4      '       g   \        R\        V4       24      hV P	                  VRP                  \        V P                  V4      4      \        V4      ,          4      4       R# )zCSet the given flag(s) without changing others on the keyed message.flag must be a string: r   N)ru   r   r   r   r   r   r   r   r   r*   r   r3   r   add_flagZMaildir.add_flag  sT    $$$5d4j\BCCsBGGCs(;$<s4y$HIJr   c                r   r   r   r   r   r   r   r     s     O OS Or   c           
     s$   \        V\        4      '       g   \        R\        V4       24      hV P	                  V4      '       dL   V P                  VRP                  \        V P	                  V4      4      \        V4      ,
          4      4       R# R# )zLUnset the given string flag(s) without changing others on the keyed message.r   r   N)ru   r   r   r   r   r   r   r   r   r3   r   remove_flagZMaildir.remove_flag  sh    $$$5d4j\BCC>>#NN3DNN3,?(@3t9(L MN r   c              #  s   "   V P                  4        V P                   F  p V P                  V4       Tx  K  	  R#   \         d     K-  i ; i5irC   N)_refreshr   r   r/   r)   rV   r   rF   ZMaildir.iterkeys  sG     99CS! I   s%    A>
AA	AAAc                >    V P                  4        WP                  9   # rR   )r   r   r)   r%   r   rS   ZMaildir.__contains__  s    iir   c                L    V P                  4        \        V P                  4      # rT   )r   lenr   rD   rE   r   rU   ZMaildir.__len__  s    499~r   c                    R# )"Write any pending changes to disk.N rD   rE   r   r_   ZMaildir.flush  s     	r   c                r   )r`   Nr   rD   rE   r   ra   ZMaildir.lock      r   c                r   )rb   Nr   rD   rE   r   rc   ZMaildir.unlock  r   r   c                r   rd   Nr   rD   rE   r   re   ZMaildir.close  r   r   c                sj   . p\         P                  ! V P                  4       F  p\        V4      ^8  g   K  V^ ,          R8X  g   K%  \         P                  P                  \         P                  P                  V P                  V4      4      '       g   Kt  VP                  VR,          4       K  	  V# )Return a list of folder names..i   NN)r   listdirr   r   r   isdirr   appendr   rX   entryrL   r   list_foldersZMaildir.list_folders  sp    ZZ

+E5zA~%(c/ww}}RWW\\$**e<==eBi( , r   c                s    \        \        P                  P                  V P                  RV,           4      V P
                  RR7      # )z/Return a Maildir instance for the named folder.r   Fr   r   )r   r   r   r   r   r   r   folderr%   r   
get_folderZMaildir.get_folder  s2    rww||DJJf=#}}#% 	%r   c                s   \         P                  P                  V P                  RV,           4      p\	        W P
                  R7      p\         P                  P                  VR4      p\         P                  P                  V4      '       gP   \         P                  ! \         P                  ! V\         P                  \         P                  ,          R4      4       V# )z>Create a folder and return a Maildir instance representing it.r   r   Zmaildirfolderi  )r   r   r   r   r   r   r   re   r   O_CREATO_WRONLY)r   r   r   rX   Zmaildirfolder_path   &&   r   
add_folderZMaildir.add_folder  s    ww||DJJf5}}5WW\\$@ww~~011HHRWW/bkk1I r   c                s*   \         P                  P                  V P                  RV,           4      p\         P                  ! \         P                  P                  VR4      4      \         P                  ! \         P                  P                  VR4      4      ,            F3  p\        V4      ^8  g   V^ ,          R8w  g   K#  \        RV,          4      h	  \         P                  ! V4       Fs  pVR8w  g   K  VR8w  g   K  VR8w  g   K  \         P                  P                  \         P                  P                  W#4      4      '       g   Kb  \        RV: RV: 24      h	  \         P                  ! VRR	7       F~  w  rEpV F6  p\         P                  ! \         P                  P                  WC4      4       K8  	  V F6  p\         P                  ! \         P                  P                  WC4      4       K8  	  K  	  \         P                  ! V4       R
# )-Delete the named folder, which must be empty.r   r   r   zFolder contains message(s): %sr   zFolder contains subdirectory 'z': F)ZtopdownN)r   r   r   r   r   r   r   r   Zwalkr+   rmdir)r   r   r   r   ZrootZdirsZfilesr   r   remove_folderZMaildir.remove_folder  sY   ww||DJJf5ZZT5 9:ZZT5 9:; ;E5zA~qS#$Dv$MNN; ZZ%E~%5.Ue^ww}}RWW\\$677#%+U%4 5 5 &
 "$u!=D		"'',,t34 d23  ">
 	r   c                s   \         P                   ! 4       p\        P                  ! \        P                  P	                  V P
                  R4      4       Fq  p\        P                  P	                  V P
                  RV4      pV\        P                  P                  V4      ,
          R8  g   K[  \        P                  ! V4       Ks  	  R# )zDelete old files in "tmp".r   i@ N)timer   r   r   r   r   r   r+   )r   nowr   r   s   &   r   cleanZMaildir.clean  su    iikZZTZZ ?@E77<<

E59DRWW%%d++f4		$ Ar   c           	     s   \         P                   ! 4       p\        P                  ! 4       pRV9   d   VP                  RR4      pRV9   d   VP                  RR4      p\	        V4      : R\	        V^,          R,          4      : R\
        P                  ! 4       : R\        P                  : R	V: 2	p\
        P                  P                  V P                  R
V4      p \
        P                  ! V4       \!        RT,          4      h  \         d?    \        ;P                  ^,          un         \        T4      u #   \         d      LVi ; ii ; i)z=Create a file in the tmp subdirectory and open and return it.Z/z\057r   z\072z.Mg    .APZQr   r   z&Name clash prevented file creation: %s)r
  socketgethostnamer|   intr   getpidr   _countr   r   r   statr   _create_carefullyFileExistsErrorr   )r   r  Zhostnamer   r   s   &    r   r   ZMaildir._create_tmp  s    iik%%'(?''W5H(?''W5H$'Hc#'C-.@"))+$+NNH>ww||DJJt4	GGDM !!I!%"& ' 	' ! 	NNaN(.." 		s0   D (E0
D=:E=EEEEc                s   \         P                   ! 4       V P                  ,
          ^V P                  ,           8  dw   RpV P                   FZ  p\        P
                  P                  V P                  V,          4      pW0P                  V,          8  d   RpW0P                  V&   K\  	  V'       g   R# / V n        V P                   F  pV P                  V,          p\        P                  ! V4       F  pVP                  R4      '       d   K  \        P
                  P                  WE4      p\        P
                  P                  V4      '       d   Kb  VP                  V P                  4      ^ ,          p\        P
                  P                  W%4      V P                  V&   K  	  K  	  \         P                   ! 4       V n        R# )z!Update table of contents mapping.FTNr   )r
  r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r   Zrefreshr   Zmtimer   r   Zpr   s   &       r   r   ZMaildir._refresh4  s8    99;(1t/?/?+??G**((V)<=++F33"G+0  (	 +
 	&&F;;v&DD)##C((GGLL-77==##{{4::.q1"$'',,v"=		$ * ' ))+r   c                s    \         P                  P                  \         P                  P                  V P                  V P
                  V,          4      4      '       d   V P
                  V,          #  V P                  4         V P
                  V,          #   \         d     L1i ; i  \         d    \        RT,          4      Rhi ; i)z=Use TOC to return subpath for given key, or raise a KeyError.No message with key: %sN)r   r   r   r   r   r   r/   r   r)   r%   r   r   ZMaildir._lookupZ  s    	ww~~bggll4::tyy~FGGyy~% H 		F99S>!	  		
  	F4s:;E	Fs$   AB  B B) B&%B&)Cc                s    \        V R4      '       g   V P                  4       V n          V \        V P                  4      ,          #   \         d     R# \
         d     K9  i ; i)z0Return the next message in a one-time iteration._onetime_keysN)r\   rF   r  nextZStopIterationr/   rD   rE   r   r  ZMaildir.nexth  sX    t_--!%DD!3!3455   s   A A"A"A"!A")r   r  r   r   r   r   r   )'r   r   r   r   r   r   r   r&   r+   r0   r4   r8   r@   r:   r   r   r   r   r   r   rF   rS   rU   r_   ra   rc   re   r   r  r  r	  r  r  r   r   r   r  r   r   r   r   r   r   r     s     (E((T?&64

% %? ?K KO O 

%&  F'0$&LF
 
r   c                   s   a  ] tR tRt o RtRR ltR tR tR tR t	R	 t
R
 tR tR tR tR tR tR tR tRR ltR tRtV tR# )_singlefileMailboxiu  zA single-file mailbox.Nc                s*   \         P                  WW#4        \        V P                  R4      pY@n
        RT n        ^ T n        RT n        RT n        RT n        RT n        R#   \         d   pTP
                  \
        P                  8X  d9   T'       d   \        T P                  R4      p Rp?L\        T P                  4      hTP
                  \
        P                  \
        P                  39   d   \        T P                  R4      p Rp?Lh Rp?ii ; i)z!Initialize a single-file mailbox.rb+zwb+r   NF)r   r   r   r   r   r   ENOENTr   EACCESEROFS_filer   	_next_key_pending_pending_sync_locked_file_length)r   r   r   r   r   r   s   &&&&  r   r   Z_singlefileMailbox.__init__x  s    W5	TZZ'A 
	" !  		ww%,,&TZZ/A,TZZ88U\\5;;77T*		s*   A   D+&DD-ADDDc                s    V P                  4        V P                  V4      V P                  V P                  &   V ;P                  ^,          un        RV n        V P                  ^,
          # )r    T)r   _append_messager   r  r!  r#   r%   r   r&   Z_singlefileMailbox.add  sO    $($8$8$A		$..!! "~~!!r   c                sP    V P                  V4       V P                  V RV n        R# )r(   TN)r   r   r   r)   r%   r   r+   Z_singlefileMailbox.remove  s     SIIcNr   c                sr    V P                  V4       V P                  V4      V P                  V&   RV n        R# )r1   TN)r   r$  r   r   r2   r3   r   r4   Z_singlefileMailbox.__setitem__  s-    S--g6		#r   c              #  sv   "   V P                  4        V P                  P                  4        Rj  xL
  R#  L5ir   )r   r   rI   rD   rE   r   rF   Z_singlefileMailbox.iterkeys  s"     99>>###s   .979c                r   r   )r   r   r)   r%   r   rS   Z_singlefileMailbox.__contains__  s    iir   c                r   r   )r   r   r   rD   rE   r   rU   Z_singlefileMailbox.__len__  s    499~r   c                sf    V P                   '       g   \        V P                  4       RV n         R# R# )r`   TN)r"  
_lock_filer  rD   rE   r   ra   Z_singlefileMailbox.lock  s#    |||tzz"DL r   c                sf    V P                   '       d   \        V P                  4       RV n         R# R# rb   FN)r"  _unlock_filer  rD   rE   r   rc   Z_singlefileMailbox.unlock  s#    <<<$ DL r   c           	     sz   V P                   '       g1   V P                  '       d   \        V P                  4       RV n        R# V P                  P	                  ^ ^4       V P                  P                  4       pWP                  8w  d   \        RV P                  V3,          4      h\        V P                  4      p / pV P                  V4       \        V P                  P                  4       4       F  pV P                  V,          w  rVV P                  P	                  V4       V P                  V4       VP                  4       p V P                  P                  \!        RW`P                  P                  4       ,
          4      4      pV'       g   MVP#                  V4       K`  WrP                  4       3W4&   V P%                  V4       K  	  VP                  4       V n        \/        T4       T P                  P'                  4        \(        P0                  ! T P                  4      p	\(        P2                  ! TP,                  T	P4                  4        \(        P6                  ! TP,                  T	P8                  T	P:                  4        \(        P@                  ! TP,                  T P                  4       \E        T P                  R4      T n        Y0n        RT n         RT n        T PF                  '       d   \I        T P                  RR7       R# R#    TP'                  4        \(        P*                  ! TP,                  4       h ; i  \<        \>        3 d     Li ; i  \B         dP    \(        P*                  ! T P                  4       \(        P@                  ! TP,                  T P                  4        ELi ; i)r   FNz4Size of mailbox file changed (expected %i, found %i)   r  )dotlock)%r   r!  _sync_flushr  r{   tellr#  r   _create_temporaryr   _pre_mailbox_hookr   r   rI   _pre_message_hookrk   Zminr~   _post_message_hookre   r   r+   r   r   r  ZchmodZst_modeZchownZst_uidZst_gidr   r   r   r  r   r"  r%  )
r   Zcur_lenZnew_fileZnew_tocr*   startstopZ	new_startrl   r   s
   &         r   r_   Z_singlefileMailbox.flush  s   }}}!!! DJJ'%*" 	

1**//#'''$ &?&*&7&7%A&B C C %TZZ0	G""8,diinn./"iin

&&&x0$MMO	!ZZ__S15

8I1I.K LF!NN6* )==?;''1 0 !)D
 	H

wwtzz"
-	HHX]]DKK=	1IIhmmTZZ0 $**e,
	"<<<tzz51 /	NNIIhmm$ ( 		  	1IIdjj!IIhmmTZZ0	1s2   =D'L 6M	 +M  3M	MM AN:9N:c                r   ),Called before writing the mailbox to file f.Nr   r   r   r%   r   r-  Z$_singlefileMailbox._pre_mailbox_hook  r   r   c                r   )-Called before writing each message to file f.Nr   r3  r%   r   r.  Z$_singlefileMailbox._pre_message_hook  r   r   c                r   ,Called after writing each message to file f.Nr   r3  r%   r   r/  Z%_singlefileMailbox._post_message_hook  r   r   c                s    V P                  4         V P                  '       d   V P                  4        V P                  P	                  4        R#   T P                  P	                  4        i ; i   T P                  '       d   T P                  4        T P                  P	                  4        i   T P                  P	                  4        i ; i; ir   )r_   r"  rc   r  re   rD   rE   r   re   Z_singlefileMailbox.close  s    	#JJL#<<<KKM

  "

  "	#<<<KKM

  "

  "s.   A0 "A A-0C2"B/C/CCc                s    V P                   f   V P                  4        Ve    V P                   V,          # R#   \         d    \        RT,          4      Rhi ; i)z'Return (start, stop) or raise KeyError.Nr  )r   _generate_tocr/   r)   r%   r   r   Z_singlefileMailbox._lookup  s\    99 ?Jyy~%   J83>?TIJs	   9 Ac                sX   V P                   P                  ^ ^4       V P                   P                  4       p\        V P                  4      ^ 8X  d.   V P
                  '       g   V P                  V P                   4        V P                  V P                   4       V P                  V4      pV P                  V P                   4       T P                   P                  4        T P                   P                  4       T n        T#   \         d    T P                   P                  T4       h i ; i)z;Append message to mailbox and return (start, stop) offsets.)r  r{   r+  r   r   r   r-  r.  _install_messager/  r   Ztruncater_   r#  )r   r$   ZbeforeZoffsets   &&  r   r$  Z"_singlefileMailbox._append_message%  s    

1"tyy>Qt}}}
 ""4::.	""4::.++G4G##DJJ/ 	

 JJOO-  	JJ'	s   ?AD (D))r  r#  r"  r  r   r!  r   r   r,   )r   r   r   r   r   r   r&   r+   r4   rF   rS   rU   ra   rc   r_   r-  r.  r/  re   r   r$  r   r   r   r   r   r  r  u  s`      !."$
 

 !B2H	#J r   r  c                   sR   a  ] tR tRt o RtRtR tRR ltRR ltRR lt	R t
R	tV tR
# )	_mboxMMDFi<  zAn mbox or MMDF mailbox.Tc                s   V P                  V4      w  r#V P                  P                  V4       V P                  P                  4       P	                  \
        R4      P                  R4      pV P                  P                  W0P                  P                  4       ,
          4      pV P                  VP	                  \
        R4      4      pVP                  V4       VP                  VR,          4       V# )r<   r   r   ri   rq   )r   r  r{   r   r|   r}   Zdecoderk   r+  _message_factoryZset_unixfromset_from)r   r*   r0  r1  	from_linestringr   r   r   r8   Z_mboxMMDF.get_messageA  s    ll3'

JJ'')11'3?FFwO	

(9!9:##FNN7E$BC#Yr]#
r   c                sl    \         P                  ! V P                  W4      4      P                  VR7      # )3Return a string representation or raise a KeyError.)unixfromr=   )r   r*   from_r3   r   rA   Z_mboxMMDF.get_stringL  s.    ''NN3&((1	5	(A	Br   c                s@   V P                  V4      w  r4V P                  P                  V4       V'       g   V P                  P                  4        V P                  P	                  W@P                  P                  4       ,
          4      pVP                  \        R4      # )r?  ri   )r   r  r{   r   rk   r+  r|   r}   )r   r*   rA  r0  r1  r>     &&&   r   r@   Z_mboxMMDF.get_bytesQ  sf    ll3'

JJ!

(9!9:~~gu--r   c                s    V P                  V4      w  r4V P                  P                  V4       V'       g   V P                  P                  4        \	        V P                  V P                  P                  4       V4      # )rB   )r   r  r{   r   _PartialFiler+  )r   r*   rA  r0  r1  s   &&&  r   r:   Z_mboxMMDF.get_fileZ  sS    ll3'

JJ!DJJ

(94@@r   c                s   Rp\        V\        4      '       d   V P                  V4      p\        V\        4      '       dF   VP	                  R4      '       d/   VP                  R4      pVR8w  d   VRV pW^,           R pMTpRpM\        V\        4      '       d*   VP                  4       P                  R4      pRV,           pMO\        V\        P                  P                  4      '       d&   VP                  4       pVe   VP                  R4      pVf?   R\        P                  ! \        P                  ! 4       4      P                  4       ,           pV P                   P#                  4       pV P                   P%                  V\&        ,           4       V P)                  WP                   V P*                  4       V P                   P#                  4       pWV3# )z1Format a message and blindly write to self._file.Nrp   ri   r   r   s   From MAILER-DAEMON rt   )ru   r   rh   r   r   find_mboxMMDFMessageget_fromrf   r>   r$   r   get_unixfromr
  asctimegmtimer  r+  r~   r}   r   _mangle_from_)r   r$   r=  ZnewlineZauthorr0  r1  r   r   r8  Z_mboxMMDF._install_messageb  sg   	gs##++G4Ggu%%'*<*<X*F*Fll5)G"}#HW-	!A+,/#	!122%%'..w7F 6)I!6!677,,.I$%,,W5	.dkkm1L1S1S1UUI

!

W,-7JJ0B0BCzz }r   r   Nr   )r   r   r   r   r   rJ  r8   rA   r@   r:   r8  r   r   r   r   r   r:  r:  <  s-     "M	B
.A r   r:  c                   sB   a  ] tR tRt o RtRtRtR	R ltR tR t	Rt
V tR# )
r   i  zA classic mbox mailbox.TNc                H    \         V n        \        P                  WW#4       R# )zInitialize an mbox mailbox.N)r	   r;  r:  r   r   r   r   r   Zmbox.__init__       +4w7r   c                s0    VP                  \        4       R# r5  r~   r}   r3  r%   r   r/  Zmbox._post_message_hook  s    	r   c                s(   . . r!RpV P                   P                  ^ 4        V P                   P                  4       pV P                   P                  4       pVP	                  R4      '       dn   \        V4      \        V4      8  d@   V'       d'   VP                  V\        \        4      ,
          4       MVP                  V4       VP                  V4       RpK  V'       gA   V'       d'   VP                  V\        \        4      ,
          4       MVP                  V4       MV\        8X  d   RpEK  RpEK  \        \        \        W4      4      4      V n        \        V P                  4      V n        V P                   P                  4       V n        R# )0Generate key-to-(start, stop) table of contents.FTrp   N)r  r{   r+  r   r   r   r   r}   dict	enumeratezipr   r  r#  )r   startsstopsZlast_was_emptyline_posr      &     r   r7  Zmbox._generate_toc  s   B

zz(H::&&(Dx((u:F+%XG%<=
 X.h'!&!LLCL!89LL*!%!&3v#567	TYY JJOO-r   r#  r;  r  r   r   )r   r   r   r   r   rJ  r   r   r/  r7  r   r   r   r   r   r   r     s(     !M O8
. .r   c                   s@   a  ] tR tRt o RtR	R ltR tR tR tRt	V t
R# )
r   i  zAn MMDF mailbox.Nc                rK  )zInitialize an MMDF mailbox.N)r   r;  r:  r   r   r   r   r   ZMMDF.__init__  rL  r   c                >    VP                  R\        ,           4       R# )r4     NrM  r3  r%   r   r.  ZMMDF._pre_message_hook  s    	#g-.r   c                sT    VP                  \        R,           \        ,           4       R# )r6  rX  NrM  r3  r%   r   r/  ZMMDF._post_message_hook  s    	--78r   c                s:   . . r!V P                   P                  ^ 4       ^ p TpV P                   P                  4       pV P                   P                  4       pVP	                  R\
        ,           4      '       d   VP                  V4        TpV P                   P                  4       pV P                   P                  4       pVR\
        ,           8X  d(   VP                  V\        \
        4      ,
          4       K  V'       d   Kz  VP                  V4       K  V'       d   EK   \        \        \        Y4      4      4      T n        \        T P                  4      T n        T P                   P                  ^ ^4       T P                   P                  4       T n        R# )rN  rX  N)r  r{   r   r+  r   r}   r   r   rO  rP  rQ  r   r  r#  )r   rR  rS  next_posrT  r   rU  r   r7  ZMMDF._generate_toc  s   B

H::&&(Dzz(H2W<==h''H::..0D#zz0H2W<<XG%<=!TX.T3v#567	TYY

1 JJOO-r   rV  r   )r   r   r   r   r   r   r.  r/  r7  r   r   r   r   r   r   r     s!     8
/9. .r   c                   s   a  ] tR tRt o RtRR ltR tR tR tR t	R	 t
R
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )r   i  zAn MH mailbox.Nc                s4   \         P                  WW#4       \        P                  P	                  V P
                  4      '       g   V'       d   \        P                  ! V P
                  R4       \        P                  ! \        P                  ! \        P                  P                  V P
                  R4      \        P                  \        P                  ,          \        P                  ,          R4      4       M\        V P
                  4      hRV n        R# )zInitialize an MH instance.r   .mh_sequencesi  FN)r   r   r   r   r   r   r   re   r   r   r  ZO_EXCLr  r   r"  r   r   r   r   ZMH.__init__  s    W5ww~~djj))U+djj/!J!#bii!7"++!EuN O )44r   c                s   V P                  4       p\        V4      ^ 8X  d   ^pM\        V4      ^,           p\        P                  P                  V P                  \        V4      4      p\        V4      pRp V P                  '       d   \        V4         V P                  W4       \!        T\"        4      '       d   T P%                  Y4       T P                  '       d   \        T4       T'       g   \        T4       T#   \         dC    T P                  '       d   \        T4       \        T4       Rp\        P                  ! T4       h i ; i  T P                  '       d   \        T4       i i ; i  T'       g   \        T4       i i ; i)r    FT)rI   r   Zmaxr   r   r   r   r   r  r"  r%  r   r   r'  r   r+   ru   r
   _dump_sequences)r   r$   rI   Znew_keyr   r   closedr   r   r&   ZMH.add  s$   yy{t9>G$i!mG77<<

CL9h'	|||1$	&&w2 gy11((:<<< OA! % |||$QN!FIIh' <<< O   A s<   7E3 D  ''E E3  E0EE  E00E3 3F	c                s\   \         P                  P                  V P                  \	        V4      4      p \        VR4      pVP                  4        \         P                  ! V4       R#   \         d8   pTP                  \        P                  8X  d   \        RT,          4      hh Rp?ii ; i)r(   r  r  N)r   r   r   r   r   r   re   r+   r   r   r  r/   )r   r*   r   r   r   r  r   r+   Z	MH.remove  s{    ww||DJJC1		T5!A GGIIIdO  	ww%,,&83>??		s   A) )B+42B&&B+c                s   \         P                  P                  V P                  \	        V4      4      p \        VR4      p T P                  '       d   \        T4        \         P                  ! \         P
                  ! T\         P                  \         P                  ,          4      4       T P                  Y$4       \!        T\"        4      '       d   T P%                  Y!4       T P                  '       d   \'        T4       \)        T4       R#   \         d8   pTP                  \        P                  8X  d   \        RT,          4      hh Rp?ii ; i  T P                  '       d   \'        T4       i i ; i  \)        T4       i ; i)r1   r  r  N)r   r   r   r   r   r   r   r   r  r/   r"  r%  re   r  O_TRUNCr   ru   r
   r[  r'  r   )r   r*   r$   r   r   r   rB  r   r4   ZMH.__setitem__  s   ww||DJJC1	T5!A	|||1$r{{RZZ'?@A""7.gy11((6<<< ON#  	ww%,,&83>??		 <<< O   NsB   D E8 E8  BE &E8 E2EE E55E8 8Fc                sL    V P                   '       d?   \        \        P                  P	                  V P
                  \        V4      4      R4      pM>\        \        P                  P	                  V P
                  \        V4      4      R4      p T;_uu_ 4        V P                   '       d   \        V4        \        V4      pV P                   '       d   \        V4       RRR4       T P                  4       P                  4        F  w  rVY9   g   K  XP!                  T4       K   	  X#   \         d8   pTP                  \        P                  8X  d   \        RT,          4      hh Rp?ii ; i  T P                   '       d   \        T4       i i ; i  + '       g   i     L; i)r<   r  r   r  N)r"  r   r   r   r   r   r   r   r   r  r/   r%  r
   r'  get_sequencesrQ   add_sequence)r   r*   r   r   r   r   key_listr   r   r8   ZMH.get_message7  s    		|||djj#c(;UCdjj#c(;TB Q|||1$l<<< O  #00288:ND  & ; 
!  	ww%,,&83>??		 <<< O   QsF   D+ =D+ =D+ F9E0F+E-62E((E-0 FFF#	c                s     V P                   '       d?   \        \        P                  P	                  V P
                  \        V4      4      R4      pM>\        \        P                  P	                  V P
                  \        V4      4      R4      p T;_uu_ 4        V P                   '       d   \        V4        VP                  4       P                  \        R4      V P                   '       d   \        V4       uuRRR4       #   \         d8   pTP                  \        P                  8X  d   \        RT,          4      hh Rp?ii ; i  T P                   '       d   \        T4       i i ; i  + '       g   i     R# ; i)r   r  r   r  Nri   )r"  r   r   r   r   r   r   r   r   r  r/   r%  rk   r|   r}   r'  r   r*   r   r   r9  r   r@   ZMH.get_bytesP  s    		|||djj#c(;UCdjj#c(;TB Q|||1$vvx''7<<< O Q  	ww%,,&83>??		 <<< O   QQsF   D =D =D E,9#E	E,E2EE	 E))E,,E=	c                s    \        \        P                  P                  V P                  \        V4      4      R4      p\        T4      #   \         d8   pTP                  \        P                  8X  d   \        RT,          4      hh Rp?ii ; i)rB   r   r  N)r   r   r   r   r   r   r   r   r  r/   r   ra  r9  r   r:   ZMH.get_filee  sl    	RWW\\$**c#h7>A !}  	ww%,,&83>??		s   =A
 
B2BBc                st    \        \        R \        P                  ! V P                  4       4       4      4      # )rC   c              3   sh   "   T F(  pVP                  4       '       g   K  \        V4      x  K*  	  R # 5ir,   )isdigitr  ).0r   rV   r   	<genexpr>ZMH.iterkeys.<locals>.<genexpr>r  s(      :3I%). &3u::3Is   22)Ziterr   r   r   r   rD   rE   r   rF   ZMH.iterkeysp  s/    F :2::djj3I : : ; 	;r   c                s    \         P                  P                  \         P                  P                  V P                  \        V4      4      4      # r   )r   r   r   r   r   r   r)   r%   r   rS   ZMH.__contains__u  s,    ww~~bggll4::s3x@AAr   c                sF    \        \        V P                  4       4      4      # r   )r   rH   rF   rD   rE   r   rU   Z
MH.__len__y  s    4())r   c                s&   V'       d   R MRpV'       d   RR/M/ p\         P                  P                  V P                  R4      p  \	        VRV,           3/ VB #   \
         d     Mi ; i \	        TRT,           3/ TB #   \         d     KJ  i ; i)r   ZbencodingASCIIrZ  zr+zx+)r   r   r   r   r   r   r  )r   textZmodeZkwargsr   r  r   _open_mh_sequences_fileZMH._open_mh_sequences_file}  s    rs*.*g&Bww||DJJ8D$+888$ D$+888" s$   A A)(A)-B BBc                s    V P                   '       g6   V P                  RR7      V n        \        V P                  4       RV n         R# R# )r`   Frg  TN)r"  rh  r  r%  rD   rE   r   ra   ZMH.lock  s8    |||5555ADJtzz"DL r   c                s    V P                   '       d6   \        V P                  4       \        V P                  4       V =RV n         R# R# r&  )r"  r'  r  r   rD   rE   r   rc   Z	MH.unlock  s4    <<<$

#
 DL	 r   c                r   )r^   Nr   rD   rE   r   r_   ZMH.flush  r   r   c                sN    V P                   '       d   V P                  4        R# R# r   )r"  rc   rD   rE   r   re   ZMH.close  s    <<<KKM r   c                s   . p\         P                  ! V P                  4       Fc  p\         P                  P	                  \         P                  P                  V P                  V4      4      '       g   KR  VP                  V4       Ke  	  V# )r   )r   r   r   r   r   r   r   r   rL   r   r   ZMH.list_folders  sW    ZZ

+Eww}}RWW\\$**e<==e$ , r   c                s    \        \        P                  P                  V P                  V4      V P
                  RR7      # )z+Return an MH instance for the named folder.Fr   r   r   r   r   r   r   r   r%   r   r  ZMH.get_folder  s-    "'',,tzz62--7 	7r   c                s    \        \        P                  P                  V P                  V4      V P
                  R7      # )z:Create a folder and return an MH instance representing it.r  rj  r   r%   r   r  ZMH.add_folder  s+    "'',,tzz62--) 	)r   c                st   \         P                  P                  V P                  V4      p\         P                  ! V4      pVR.8X  d6   \         P
                  ! \         P                  P                  VR4      4       M$V. 8X  d   M\        RV P                  ,          4      h\         P                  ! V4       R# )r  rZ  zFolder not empty: %sN)r   r   r   r   r   r+   r   r  )r   r   r   Zentriesr9  r   r	  ZMH.remove_folder  sx    ww||DJJ/**T"''IIbggll49:] 6 CDD
r   c                sZ   / p \        \        P                  P                  V P                  R4      RRR7      pT;_uu_ 4        \        T P                  4       4      pT F  p TP                  R4      w  rV\        4       pTP                  4        Fp  pTP                  4       '       d   TP                  \        T4      4       K5  R TP                  R4       4       w  rTP                  \        Y^,           4      4       Kr  	  \        T4       Uu. uF  pY9   g   K  TNK  	  upY&   \        Y,          4      ^ 8X  d   Y K  K  	  R	R	R	4       T#   \
         d    Tu # i ; iu upi   \          d"    \#        RTP%                  4       ,          4      hi ; i  + '       g   i     T# ; i)
z=Return a name-to-key-list dictionary to define each sequence.rZ  Zrrf  )re  r   c              3   s8   "   T F  p\        V4      x  K  	  R # 5ir,   )r  )rc  ZxrV   r   rd  Z#MH.get_sequences.<locals>.<genexpr>  s     *K?a3q66?s   -z"Invalid sequence specification: %sN)r   r   r   r   r   r   r   rI   r   rb  r&   r  r]   Zranger   r   rg   r   Zrstrip)r   Zresultsr   Zall_keysr   r   ZcontentsrI   Zspecr0  r1  r*   s   &           r   r^  ZMH.get_sequences  se   	RWW\\$**o>gVA Q499;'H5%)ZZ_ND5D ( 0<<>> HHSY/*K4::c?*KKE KKeAX(>? !1 5;4L %=LS,/O &)SL %=GM7=)Q.#M /  & + ! 	N	%= " 5%&J&*kkm'4 5 55! Q& sN   6E F$B.E*E%
E%
%E*FE"!E"%E**,F	FF*	c                s   V P                  RR7      p \        P                  ! \        P                  ! VP                  \        P
                  \        P                  ,          4      4       VP                  4        F  w  r4\        V4      ^ 8X  d   K  VP                  VR,           4       RpRp\        \        V4      4       Fj  pV^,
          V8X  d   V'       g   RpVP                  R4       M;V'       d   RpVP                  V: RV: 24       MVP                  RV,          4       TpKl  	  V'       d$   VP                  \        V4      R	,           4       K  VP                  R	4       K  	  \        V4       R#   \        T4       i ; i)
z:Set sequences using the given name-to-key-list dictionary.Tri  r   NFrk   z %sZ
)rh  r   re   r   r   r  r]  rQ   r   r~   r   r   r   r   )r   	sequencesr   r   rI   prevZ
completingr*   r   r   set_sequencesZMH.set_sequences  s   ((d(3	HHRWWQVVR[[2::%=>?'oo/
t9>s
#"
!#d),CQw$))-JGGCL#%*
4 56,D - GGCI,-GGDM) 0, NKNs   CE> E> 8A E> 98E> >Fc                s\   V P                  4       p^ p. pV P                  4        F  pV^,
          V8w  d   VP                  WB^,           34        \        P                  ! \        P
                  P                  V P                  \        V4      4      \        P
                  P                  V P                  \        V^,           4      4      4       \        P                  ! \        P
                  P                  V P                  \        V4      4      4       V^,          pK  	  V^,           V n        \        V4      ^ 8X  d   R# VP                  4        F+  w  rVV F   w  rxWv9   g   K  WVP!                  V4      &   K"  	  K-  	  V P#                  V4       R#   \        \        3 d    \        P                  ! \        P
                  P                  T P                  \        T4      4      \        P
                  P                  T P                  \        T^,           4      4      4        ELi ; i)z?Re-name messages to eliminate numbering gaps. Invalidates keys.N)r^  rF   r   r   r   r   r   r   r   unlinkr   r   r   r  r   rQ   indexro  )	r   rm  rn  Zchangesr*   r   r`  Zoldr   	   &        r   packZMH.pack  s|   &&(	==?CQw$AX/BGGBGGLLSX>GGLLS]CE IIbggll4::s3x@AAID # w<1'oo/ND#?47X^^C01 $ 0 	9% '8 GIIbggll4::s3x@ ggll4::s4!8}EGGs   B FBH+*H+c                s*   VP                  4       pV P                  4       pVP                  4        F7  w  rVWS9   d   VP                  V4       K  W&9   g   K&  WfP                  V4       K9  	  V F  pWt9  g   K  V.WG&   K  	  V P	                  V4       R# )z;Inspect a new MHMessage and update sequences appropriately.N)r^  rQ   r   rq  ro  )r   r$   r*   Zpending_sequencesZall_sequencesr   r`  sequences   &&&     r   r[  ZMH._dump_sequences  s    #113**,+113ND($^^C01	 4
 *H,+.%' * 	=)r   )r  r"  r  r   )r   r   r   r   r   r   r&   r+   r4   r8   r@   r:   rF   rS   rU   rh  ra   rc   r_   re   r   r  r  r	  r^  ro  rs  r[  r   r   r   r   r   r   r     s     
 D02$*	;
B* !
7
)

8:&4* *r   c                   s   a  ] tR tRt o Rt]! 0 Rm4      tRR ltR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tRtV tR# )r   i#  zAn Rmail-style Babyl mailbox.Nc                s@    \         P                  WW#4       / V n        R# )zInitialize a Babyl mailbox.N)r  r   _labelsr   r   r   r   ZBabyl.__init__)  s    ##D@r   c                s    \         P                  W4      p\        V\        4      '       d   VP	                  4       V P
                  V&   V# )r    )r  r&   ru   r   
get_labelsru  )r   r$   r*   r;   r   r&   Z	Babyl.add.  s;     $$T3g|,, ' 2 2 4DLL
r   c                sn    \         P                  W4       WP                  9   d   V P                  V R# R# r   )r  r+   ru  r)   r%   r   r+   ZBabyl.remove5  s+    !!$,,,S! r   c                s    \         P                  WV4       \        V\        4      '       d    VP	                  4       V P
                  V&   R# R# )r1   N)r  r4   ru   r   rv  ru  r2   r3   r   r4   ZBabyl.__setitem__;  s;    &&t':g|,, ' 2 2 4DLL -r   c                s   V P                  V4      w  r#V P                  P                  V4       V P                  P                  4        \        P
                  ! 4       p V P                  P                  4       pVR\        ,           8X  g	   V'       g   M'VP                  VP                  \        R4      4       K]  \        P
                  ! 4       p V P                  P                  4       pV\        8X  g	   V'       g   M'VP                  VP                  \        R4      4       KV  W0P                  P                  4       ,
          pV P                  P                  V4      pVP                  \        R4      p\        VP                  4       V,           4      p	V	P                  VP                  4       4       WP                  9   d#   V	P                  V P                  V,          4       V	# )r<      *** EOOH ***ri   )r   r  r{   r   rv   rw   r}   r~   r|   r+  rk   r   r   set_visibleru  
set_labels)
r   r*   r0  r1  original_headersr   Zvisible_headersnZbodyr   s
   &&        r   r8   ZBabyl.get_messageA  sJ   ll3'



::<::&&(D00""4<<#?@**,::&&(Dwd!!$,,w">?::??$$zzq!||GU++446=>0023,,NN4<<,-
r   c                s   V P                  V4      w  r#V P                  P                  V4       V P                  P                  4        \        P
                  ! 4       p V P                  P                  4       pVR\        ,           8X  g	   V'       g   M'VP                  VP                  \        R4      4       K]   V P                  P                  4       pV\        8X  g   V'       d   K0   TP                  4       pY0P                  P                  4       ,
          pT P                  P                  T4      pTP                  \        R4      pYh,           # )r?  rw  ri   )r   r  r{   r   rv   rw   r}   r~   r|   r   r+  rk   )	r   r*   r0  r1  rz  r   Zheadersr{  r   s	   &&       r   r@   ZBabyl.get_bytes]  s    ll3'



::<::&&(D00""4<<#?@::&&(Dwdd"++-::??$$zzq!||GU+~r   c                st    \         P                  ! V P                  V4      P                  R\        4      4      # )rB   ri   )rv   rw   r@   r|   r}   r)   r%   r   r:   ZBabyl.get_files  s'    zz$..-55eWEFFr   c                s    V P                  4        \        4       pV P                  P                  4        F  pVP	                  V4       K  	  VP                  V P                  4       \        V4      # )z4Return a list of user-defined labels in the mailbox.)r   r   ru  rO   r]   Zdifference_update_special_labelsrH   )r   labelsZ
label_listrL   r   rv  ZBabyl.get_labelsw  sS    ,,--/JMM*% 0  !5!56F|r   c                s   . . r!V P                   P                  ^ 4       ^ p. p TpV P                   P                  4       pV P                   P                  4       pVR\        ,           8X  d   \        V4      \        V4      8  d&   VP                  V\        \        4      ,
          4       VP                  V4       V P                   P                  4       R,          P                  R4       Uu. uF+  pVP                  4       '       g   K  VP                  4       NK-  	  ppVP                  V4       EK  VR8X  g   VR\        ,           8X  dE   \        V4      \        V4      8  d)   VP                  V\        \        4      ,
          4       EKk  EKn  V'       d   EKy  VP                  V\        \        4      ,
          4        \        \        \        Y4      4      4      T n        \        \        T4      4      T n        \        T P                  4      T n        T P                   P                  ^ ^4       T P                   P                  4       T n        R# u upi )rN  s   r      ,   N)r  r{   r   r+  r}   r   r   r   ZstriprO  rP  rQ  r   ru  r  r#  )	r   rR  rS  rY  Zlabel_listsrT  r   labelr}  rr  r   r7  ZBabyl._generate_toc  s   B

H::&&(Dzz(H{W,,u:F+LLCL!89h'+/::+>+>+@+D+J+J4+P:+P -2+0;;= (%++-+P  : ""6*DGg,=$=u:F+LLCL!89 ,TXG453v#567	Ik23TYY

1 JJOO-:s   -I
Ic                s   R\         ,           pVR\         ,           ,          pV P                  4       pR V 4       pVRRP                  V4      ,           \         ,           ,          pVR,          pVP                  V4       R# )r2  s   BABYL OPTIONS:s
   Version: 5c              3   s@   "   T F  qP                  4       x  K  	  R # 5ir,   )rf   )rc  r  rV   r   rd  Z*Babyl._pre_mailbox_hook.<locals>.<genexpr>  s     5fU,,..fs   s   Labels:r~  r  N)r}   rv  r   r~   )r   r   Zbabylr}  r9  r   r-  ZBabyl._pre_mailbox_hook  sc    !G+(("5f5dii//'99	r   c                rW  )r4  s   NrM  r3  r%   r   r.  ZBabyl._pre_message_hook  s    	'!"r   c                s>    VP                  \        R,           4       R# )r6  r  NrM  r3  r%   r   r/  ZBabyl._post_message_hook  s    	'!"r   c                s   V P                   P                  4       p\        V\        4      '       Ed   . p. pVP	                  4        F7  pWPP
                  9   d   VP                  V4       K&  VP                  V4       K9  	  V P                   P                  R4       V F3  pV P                   P                  RVP                  4       ,           4       K5  	  V P                   P                  R4       V F:  pV P                   P                  RVP                  4       ,           R,           4       K<  	  V P                   P                  \        4       M&V P                   P                  R\        ,           4       \        V\        P                  P                  4      '       Ed>   \        P                  ! 4       p\        P                  P!                  VR^ 4      pVP#                  V4       VP%                  ^ 4        VP'                  4       pV P                   P                  VP)                  R	\        4      4       VR	8X  g   V'       d   KQ   T P                   P                  R
\        ,           4       \        T\        4      '       d   \        P                  ! 4       p	\        P                  P!                  T	R^ 4      p
T
P#                  TP+                  4       4        T	P'                  4       pT P                   P                  TP)                  R	\        4      4       TR	8X  g   T'       d   KQ  McTP%                  ^ 4        TP'                  4       pT P                   P                  TP)                  R	\        4      4       TR	8X  g   T'       d   KQ    TP-                  R4      pT'       g   EMT P                   P                  TP)                  R	\        4      4       KM  \        V\.        \0        \        P2                  34      '       Ed   \        V\        P2                  4      '       d-   \4        P6                  ! R\8        ^4       VP;                  4       p\        V\0        4      '       d   V P=                  V4      pVP?                  R4      ^,           pV^,
          R8w  d   V P                   P                  VRV P)                  R	\        4      4       V P                   P                  R
\        ,           4       V P                   P                  VRV P)                  R	\        4      4       V P                   P                  WR P)                  R	\        4      4       EMfV P                   P                  R
\        ,           \        ,           4       V P                   P                  VP)                  R	\        4      4       EM\A        VR4      '       Ed   \A        VR4      '       d)   \4        P6                  ! R\8        ^4       VPB                  pVP                  4       pRp VP'                  4       pVPE                  R4      '       d   VRR R	,           pM#VPE                  R4      '       d   VRR R	,           pV P                   P                  VP)                  R	\        4      4       VR	8X  g   V'       d   K  V'       d<   RpV P                   P                  R
\        ,           4       VP%                  V4       K    TP'                  4       pT'       g   MTPE                  R4      '       d   TRR \        ,           pMOTPE                  R4      '       d   TRR \        ,           pM'TPE                  R	4      '       d   TRR \        ,           pT P                   P                  T4       K  \G        R\I        V4      ,          4      hV P                   P                  4       pW/3# )z0Write message contents and return (start, stop).s   1s   , s   ,,s    r~  s   1,,FTri   rw  r(  rj   s   

Nr   rl   rm   rn   ro   rr   rt   rs   )%r  r+  ru   r   rv  r|  r   r~   rf   r}   r>   r$   r   rv   rw   rx   ry   rz   r{   r   r|   get_visiblerk   r   r   r   r   r   r   r   rh   rD  r\   rl   r   r   r   )r   r$   r0  Zspecial_labelsr}  r  Zorig_bufferZorig_generatorr   Z
vis_bufferZvis_generatorrl   Z
body_startZoriginal_posZ
first_passr1  s   &&              r   r8  ZBabyl._install_message  s   

!g|,,NF ++-000"))%0MM%(	 .
 JJT"'

  !78 (JJU#

  !6!=>  JJW%JJVg-.gu}}4455**,K"__;;KPQRN""7+Q"++-

  eW!=>5=JJ_w67'<00ZZ\
 % > >z5RS T%%g&9&9&;<%..0DJJ$$T\\%%ABu}DD  #&//1DJJ$$T\\%%ABu}DD$))$/

  w!?@%bkk!:;;'2;;// *+=qB!**,'3''//8 g.2JA~#

  *!5!=!=eW!MN

  7!:;

  *!5!=!=eW!MN

  !5!=!=eW!MN

  7!:W!DE

  !@AWj))w)) 56H!M!.."<<>LJ'')==))9u,D]]5))9u,D

  eW!=>5=!%*


((7)BC\2'')==))9w.D]]5))9w.D]]5))9w.D

  &6gFGGzz }r   )r#  ru  r  r   >   ZfiledZeditedresentunseendeletedanswered	forwardedr   )r   r   r   r   r   Z	frozensetr|  r   r&   r+   r4   r8   r@   r:   rv  r7  r-  r.  r/  r8  r   r   r   r   r   r   r   #  sb     ' !B CO
"58,G.<##i ir   c                   s:   a  ] tR tRt o RtRR ltR tR tRtV t	R# )	r   i  z0Message with mailbox-format-specific properties.Nc                s~   \        V\        P                  P                  4      '       dQ   V P	                  \
        P                  ! V4      4       \        V\        4      '       d   VP                  V 4       R# R# \        V\        4      '       d(   V P	                  \        P                  ! V4      4       R# \        V\        4      '       d(   V P	                  \        P                  ! V4      4       R# \        V\        P                  4      '       d(   V P	                  \        P                  ! V4      4       R# \        VR4      '       d(   V P	                  \        P                   ! V4      4       R# Vf,   \        P                  P                  P#                  V 4       R# \%        R\'        V4      ,          4      h)zInitialize a Message instance.rk   Nrr   )ru   r>   r$   r   _become_messagecopyZdeepcopy_explain_tor   r?   r   Zmessage_from_stringrv   ZTextIOWrapperZmessage_from_filer\   Zmessage_from_binary_filer   r   r   r#   r%   r   r   ZMessage.__init__  s    gu}}4455  w!78'7++##D) ,''  !9!9'!BC%%  !:!:7!CD!1!122  !8!8!ABWf%%  !?!?!HI_MM!!**406gFGGr   c                s    \        VR. 4      pVP                   F+  pW29  g   K  VP                  V,          V P                  V&   K-  	  R# )z0Assume the non-format-specific state of message._type_specific_attributesN)ZgetattrZ__dict__)r   r$   Ztype_specificr   r9  r   r  ZMessage._become_message2  s@    )DbI$$D(&-&6&6t&<d# %r   c                sH    \        V\        4      '       d   R# \        R4      h)z:Copy format-specific state to message insofar as possible.Nz Cannot convert to specified type)ru   r   r   r#   r%   r   r  ZMessage._explain_to9  s    gw''>??r   r   r,   )
r   r   r   r   r   r   r  r  r   r   r   r   r   r   r     s     :H&=@ @r   c                   sx   a  ] tR tRt o Rt. ROtRR ltR tR tR t	R t
R	 tR
 tR tR tR tR tR tRtV tR# )r   iA  z)Message with Maildir-specific properties.Nc                s    RV n         RV n        \        P                  ! 4       V n        \        P                  W4       R# )z%Initialize a MaildirMessage instance.r   r   N)_subdir_infor
  _dater   r   r#   r%   r   r   ZMaildirMessage.__init__F  s+    
YY[
'r   c                    V P                   # )zReturn 'new' or 'cur'.)r  rD   rE   r   r   ZMaildirMessage.get_subdirM  s    ||r   c                sR    VR8X  g   VR8X  d	   Wn         R# \        RV,          4      h)zSet subdir to 'new' or 'cur'.r   r   z!subdir must be 'new' or 'cur': %sN)r  rg   )r   r   r%   r   r   ZMaildirMessage.set_subdirQ  s%    U?fo!L@6IJJr   c                sn    V P                   P                  R4      '       d   V P                   R,          # R# )*Return as a string the flags that are set.r   r   r   )r  r   rD   rE   r   r   ZMaildirMessage.get_flagsX  s(    ::  &&::b>!r   c                sR    RRP                  \        V4      4      ,           V n        R# ))Set the given flags and unset all others.r   r   N)r   r   r  )r   r   r%   r   r   ZMaildirMessage.set_flags_  s    BGGF5M22
r   c                    V P                  RP                  \        V P                  4       4      \        V4      ,          4      4       R# z.Set the given flag(s) without changing others.r   Nr   r   r   r   r   r   r%   r   r   ZMaildirMessage.add_flagc  ,    rwws4>>#34s4y@ABr   c                s    V P                  4       '       dJ   V P                  RP                  \        V P                  4       4      \        V4      ,
          4      4       R# R# )7Unset the given string flag(s) without changing others.r   N)r   r   r   r   r  r%   r   r   ZMaildirMessage.remove_flagg  s>    >>NN2773t~~'7#83t9#DEF r   c                r  )z<Return delivery date of message, in seconds since the epoch.)r  rD   rE   r   r   ZMaildirMessage.get_datel      zzr   c                sl     \        V4      V n        R#   \         d    \        RT,          4      Rhi ; i)z9Set delivery date of message, in seconds since the epoch.zcan't convert to float: %sN)Zfloatr  rg   r   )r   Zdater%   r   r   ZMaildirMessage.set_datep  s7    	KtDJ 	K84?@dJ	Ks    3c                r  )z%Get the message's "info" as a string.)r  rD   rE   r   r   ZMaildirMessage.get_infow  r  r   c                st    \        V\        4      '       d	   Wn        R# \        R\	        V4      ,          4      h)z Set the message's "info" string.zinfo must be a string: %sN)ru   r   r  r   r   )r   r   r%   r   r   ZMaildirMessage.set_info{  s)    dC  J7$t*DEEr   c                sD   \        V\        4      '       d`   VP                  V P                  4       4       VP	                  V P                  4       4       VP                  V P                  4       4       R# \        V\        4      '       d   \        V P                  4       4      pRV9   d   VP                  R4       V P                  4       R8X  d   VP                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       VP                  R	\        P                  ! V P                  4       4      4       R# \        V\        4      '       df   \        V P                  4       4      pRV9  d   VP                  R
4       RV9   d   VP                  R4       RV9   d   VP                  R4       R# R# \        V\         4      '       d~   \        V P                  4       4      pRV9  d   VP#                  R
4       RV9   d   VP#                  R4       RV9   d   VP#                  R4       RV9   d   VP#                  R4       R# R# \        V\$        4      '       d   R# \'        R\)        V4      ,          4      h)z;Copy Maildir-specific state to message insofar as possible.SRr   OTDFAMAILER-DAEMONr  repliedflaggedr  r  r  r  $Cannot convert to specified type: %sN)ru   r   r   r   r   r   r   r   rE  r   r   r<  r
  rI  r
   r_  r   	add_labelr   r   r   )r   r$   r   r;   r   r  ZMaildirMessage._explain_to  s   g~..dnn./t01T]]_-!122()Ee|  % E)  %e|  %e|  %e|  %_dkk$--/.JK++()E%$$X.e|$$Y/e|$$Y/ ..()E%!!(+e|!!),e|!!*-e|!!+. ))B M* + +r   )r  r  r  )r  r  r  r,   )r   r   r   r   r   r  r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r   r   r   r   A  sT     3 =(K3CG
KF)+ )+r   c                   sb   a  ] tR tRt o RtR.tRR ltR tRR ltR t	R	 t
R
 tR tR tRtV tR# )rE  i  z/Message with mbox- or MMDF-specific properties._fromNc                s.   V P                  RR4       \        V\        P                  P                  4      '       dD   VP                  4       pVe0   VP                  R4      '       d   V P                  VR,          4       \        P                  W4       R# )z'Initialize an mboxMMDFMessage instance.r  TNzFrom rq   )r<  ru   r>   r$   r   rG  r   r   )r   r$   r@  r;   r   r   Z_mboxMMDFMessage.__init__  si    ot,gu}}4455++-H#(;(;G(D(Dhrl+'r   c                r  )z Return contents of "From " line.r  rD   rE   r   rF  Z_mboxMMDFMessage.get_from  r  r   c                s    Ve@   VRJ d   \         P                  ! 4       pVR\         P                  ! V4      ,           ,          pWn        R# )z>Set "From " line, formatting and appending time_ if specified.NTrl  )r
  rI  rH  r  )r   rA  Ztime_r3   r   r<  Z_mboxMMDFMessage.set_from  s7    }S4<<...E
r   c                sT    V P                  RR4      V P                  RR4      ,           # )r  Statusr   X-Status)r7   rD   rE   r   r   Z_mboxMMDFMessage.get_flags  s#    xx"%R(@@@r   c                s   \        V4      pRRr2R F$  pWA9   g   K  W$,          pVP                  V4       K&  	  R F$  pWA9   g   K  W4,          pVP                  V4       K&  	  VRP                  \        V4      4      ,          p V P	                  RV4        V P	                  RV4       R#   \
         d    T P                  RT4        L4i ; i  \
         d    T P                  RT4        R# i ; i)r  r   r  r  N)r  r  )r  r  r  )r   r+   r   r   replace_headerr/   Z
add_header)r   r   Zstatus_flagsZxstatus_flagsr   r  r   r   Z_mboxMMDFMessage.set_flags  s    E
&("mD}$T"  $D}%T" $ 	//	4,7	7
M:  	4OOHl3	4  	7OOJ6	7s$   B, C ,CCC0/C0c                r  r  r  r  r%   r   r   Z_mboxMMDFMessage.add_flag  r  r   c                s    RV 9   g   RV 9   dJ   V P                  RP                  \        V P                  4       4      \        V4      ,
          4      4       R# R# )r  r  r  r   Nr  r  r%   r   r   Z_mboxMMDFMessage.remove_flag  s@    tzT1NN2773t~~'7#83t9#DEF  2r   c                sv   \        V\        4      '       Ed   \        V P                  4       4      pRV9   d   VP	                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       VR	 VR
 RP                  V P                  4       P                  4       RR 4      p VP                  \        P                  ! \        P                  ! VR4      4      4       R# \        V\         4      '       dA   VP#                  V P                  4       4       VP%                  V P                  4       4       R# \        V\&        4      '       dj   \        V P                  4       4      pRV9  d   VP)                  R4       RV9   d   VP)                  R4       RV9   d   VP)                  R4       VR	 VR
 R# \        V\*        4      '       dj   \        V P                  4       4      pRV9  d   VP-                  R4       RV9   d   VP-                  R4       RV9   d   VP-                  R4       VR	 VR
 R# \        V\.        4      '       d   R# \1        R\3        V4      ,          4      h  \        \        3 d     R# i ; i)zACopy mbox- or MMDF-specific state to message insofar as possible.r  r   r  r  r  r  r  r  Zstatuszx-statusrl  Nz%a %b %d %H:%M:%S %Yr  r  r  r  r  r  i)ru   r   r   r   r   r   r   rF  r   r   calendarZtimegmr
  Zstrptimerg   ZOverflowErrorrE  r   r<  r
   r_  r   r  r   r   r   )r   r$   r   Z
maybe_dater9  r   r  Z_mboxMMDFMessage._explain_to  sH   g~..()Ee|""5)e|  %e|  %e|  %e|  %!
#$--/"7"7"9"#">?J  z6L2N "O P !122dnn./T]]_-++()E%$$X.e|$$Y/e|$$Y/!
#..()E%!!(+e|!!),e|!!*-!
#))B M* + +9 . s    :J# #J87J8r  r,   )r   r   r   r   r   r  r   rF  r<  r   r   r   r   r  r   r   r   r   r   rE  rE    s@     9!(	(A7,CG
1+ 1+r   rE  c                       ] tR tRtRtRtR# )r	   i  z&Message with mbox-specific properties.r   Nr   r   r   r   r   r   r   r   r   r	   r	         0r   c                   sR   a  ] tR tRt o RtR.tRR ltR tR tR t	R	 t
R
 tRtV tR# )r
   i#  z$Message with MH-specific properties.
_sequencesNc                s>    . V n         \        P                  W4       R# )z!Initialize an MHMessage instance.N)r  r   r   r#   r%   r   r   ZMHMessage.__init__(  s    'r   c                (    V P                   R,          # )z4Return a list of sequences that include the message.NNNr  rD   rE   r   r^  ZMHMessage.get_sequences-  s    q!!r   c                &    \        V4      V n        R# )z3Set the list of sequences that include the message.N)rH   r  )r   rm  r%   r   ro  ZMHMessage.set_sequences1  s    y/r   c                s    \        V\        4      '       d0   WP                  9   g   V P                  P                  V4       R# R# \	        R\        V4      ,          4      h)z8Add sequence to list of sequences including the message.zsequence type must be str: %sN)ru   r   r  r   r   r   r   rt  r%   r   r_  ZMHMessage.add_sequence5  sG    h$$.&&x0 / ;d8nLMMr   c                b     V P                   P                  V4       R#   \         d     R# i ; i)zARemove sequence from the list of sequences including the message.N)r  r+   rg   r  r%   r   remove_sequenceZMHMessage.remove_sequence=  s+    	OO""8, 		    ..c                s   \        V\        4      '       d   \        V P                  4       4      pRV9   d   VP	                  R4       M"VP	                  R4       VP                  R4       RV9   d   VP                  R4       RV9   d   VP                  R4       R# R# \        V\        4      '       dx   \        V P                  4       4      pRV9  d   VP                  R4       MVP                  R	4       RV9   d   VP                  R4       RV9   d   VP                  R
4       R# R# \        V\        4      '       d+   V P                  4        F  pVP                  V4       K  	  R# \        V\        4      '       dN   \        V P                  4       4      pRV9   d   VP                  R4       RV9   d   VP                  R4       R# R# \        V\        4      '       d   R# \        R\        V4      ,          4      h)z6Copy MH-specific state to message insofar as possible.r  r   r  r  r  r  r  ROr  r  r  r  N)ru   r   r   r^  r   r   rE  r
   r_  r   r  r   r   r   )r   r$   rm  rt  r9  r   r  ZMHMessage._explain_toD  s   g~..D..01I9$""5)""5)  %I%  %I%  % &!122D..01Iy(  &  %I%  %I%  % &++ ..0$$X. 1..D..01I9$!!(+I%!!*- &))B M* + +r   r  r,   )r   r   r   r   r   r  r   r^  ro  r_  r  r  r   r   r   r   r   r
   r
   #  s4     .!-(
"*N$+ $+r   c                   sf   a  ] tR tRt o RtRR.tRR ltR tR tR	 t	R
 t
R tR tR tR tRtV tR# )r   ik  z'Message with Babyl-specific properties.ru  _visibleNc                s\    . V n         \        4       V n        \        P                  W4       R# )z#Initialize a BabylMessage instance.N)ru  r   r  r   r#   r%   r   r   ZBabylMessage.__init__p  s     	'r   c                r  )z'Return a list of labels on the message.r  )ru  rD   rE   r   rv  ZBabylMessage.get_labelsv  s    ||Ar   c                r  )z&Set the list of labels on the message.N)rH   ru  )r   r}  r%   r   ry  ZBabylMessage.set_labelsz  s    F|r   c                s    \        V\        4      '       d0   WP                  9  d   V P                  P                  V4       R# R# \	        R\        V4      ,          4      h)z+Add label to list of labels on the message.zlabel must be a string: %sN)ru   r   ru  r   r   r   r   r  r%   r   r  ZBabylMessage.add_label~  sG    eS!!LL(##E* ) 84;FGGr   c                r  )z4Remove label from the list of labels on the message.N)ru  r+   rg   r  r%   r   remove_labelZBabylMessage.remove_label  s+    	LL& 		r  c                s,    \        V P                  4      # )z3Return a Message representation of visible headers.r   r  rD   rE   r   r  ZBabylMessage.get_visible  s    t}}%%r   c                r  )z2Set the Message representation of visible headers.Nr  )r   Zvisibler%   r   rx  ZBabylMessage.set_visible  s    (r   c                s&   V P                   P                  4        F:  pW9   d%   V P                   P                  WV,          4       K-  V P                   V K<  	  R F2  pW9   g   K  WP                   9  g   K  W,          V P                   V&   K4  	  R# )z9Update and/or sensibly generate a set of visible headers.N)ZDateZFromzReply-ToZToZCCZSubject)r  rI   r  )r   ZheaderrV   r   update_visibleZBabylMessage.update_visible  sl    mm((*F~,,V&\BMM&)	 +
 JF~&"=(,f% Jr   c                s   \        V\        4      '       d   \        V P                  4       4      pRV9   d   VP	                  R4       M"VP	                  R4       VP                  R4       RV9   g   RV9   d   VP                  R4       RV9   d   VP                  R4       R	V9   d   VP                  R
4       R# R# \        V\        4      '       dx   \        V P                  4       4      pRV9  d   VP                  R4       MVP                  R4       R	V9   d   VP                  R4       RV9   d   VP                  R4       R# R# \        V\        4      '       dN   \        V P                  4       4      pRV9   d   VP                  R4       RV9   d   VP                  R4       R# R# \        V\        4      '       dJ   VP                  V P                  4       4       V P                  4        F  pVP                  V4       K  	  R# \        V\        4      '       d   R# \        R\        V4      ,          4      h)z9Copy Babyl-specific state to message insofar as possible.r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  N)ru   r   r   rv  r   r   rE  r
   r_  r   rx  r  r  r   r   r   )r   r$   r}  r  r9  r   r  ZBabylMessage._explain_to  s   g~..*+F6!""5)""5)  %f$F(:  %V#  %F"  % #!122*+Fv%  &  %F"  %V#  % $++*+F6!$$X.V#$$Y/ $.. 0 0 23*!!%( +))B M* + +r   )ru  r  r,   )r   r   r   r   r   r  r   rv  ry  r  r  r  rx  r  r  r   r   r   r   r   r   r   k  sF     1!*J 7($H&)	5'+ '+r   c                   r  )r   i  z&Message with MMDF-specific properties.r   Nr  r   r   r   r   r     r  r   c                   s   a  ] tR tRt o RtRR ltRR ltRR ltRR ltRR lt	R	 t
R
 tRR ltR tR tR tR tR tR tR tR t]R 4       t]! ]4      tRtV tR# )r   i  zA read-only wrapper of a file.Nc                sT    Wn         Vf   VP                  4       V n        R# W n        R# )zInitialize a _ProxyFile.N)r  r+  _pos)r   r   Zposr3   r   r   Z_ProxyFile.__init__  s    
;DIIr   c                L    V P                  WP                  P                  4      # zRead bytes.)_readr  rk   r   sizer%   r   rk   Z_ProxyFile.read  s    zz$

00r   c                r  r  )r  r  read1r  r%   r   r  Z_ProxyFile.read1  s    zz$

 0 011r   c                r  )zRead a line.)r  r  r   r  r%   r   r   Z_ProxyFile.readline  s    zz$

 3 344r   c                s    . pV  F6  pVP                  V4       Vf   K  V\        V4      ,          pV^ 8:  g   K5   V# 	  V# )zRead multiple lines.)r   r   )r   ZsizehintrX   r   r9  r   	readlinesZ_ProxyFile.readlines  sG    DMM$#CI%q=  r   c              #  sJ   "   V P                  4       ;p'       d   Vx  K  R# 5i)zIterate over lines.N)r   )r   r   rV   r   rN   Z_ProxyFile.__iter__  s      mmo%d%J &s   ##c                r  )zReturn the position.)r  rD   rE   r   r+  Z_ProxyFile.tell  s    yyr   c                s    V^8X  d&   V P                   P                  V P                  4       V P                   P                  W4       V P                   P                  4       V n        R# )zChange position.Nr  r{   r  r+  r   ZoffsetZwhencer3   r   r{   Z_ProxyFile.seek  s?    Q;JJOODII&

'JJOO%	r   c                s    \        V R4      '       d<    \        V P                  R4      '       d   V P                  P                  4        V =R# R#   T =i ; i)zClose the file.r  re   N)r\   r  re   rD   rE   r   re   Z_ProxyFile.close   sH    4!!4::w//JJ$$&J "
 Js   6A Ac                s    Vf   RpV P                   P                  V P                  4       V! V4      pV P                   P                  4       V n        V# )z"Read size bytes using read_method.rt   r  )r   r  read_methodrX   rY   r   r  Z_ProxyFile._read	  sA    <D

		"T"JJOO%	r   c                s    V # )z$Context management protocol support.r   rD   rE   r   	__enter__Z_ProxyFile.__enter__  s    r   c                s&    V P                  4        R # r,   )re   )r   Zexcs   &*r   __exit__Z_ProxyFile.__exit__  s    

r   c                6    V P                   P                  4       # r,   )r  readablerD   rE   r   r  Z_ProxyFile.readable      zz""$$r   c                r  r,   )r  writablerD   rE   r   r  Z_ProxyFile.writable  r  r   c                r  r,   )r  seekablerD   rE   r   r  Z_ProxyFile.seekable  r  r   c                r  r,   )r  r_   rD   rE   r   r_   Z_ProxyFile.flush"  s    zz!!r   c                s    \        V R 4      '       g   R# \        V P                  R4      '       g   R# V P                  P                  # )r  Tr\  F)r\   r  r\  rD   rE   r   r\  Z_ProxyFile.closed%  s6    tW%%tzz8,,zz   r   )r  r  r,   i    )r   r   r   r   r   r   rk   r  r   r  rN   r+  r{   re   r  r  r  r  r  r  r_   Zpropertyr\  r   r    r   r   r   r   r   r   r   r     sy     (125	
&%%%" ! ! $L1r   r   c                   sJ   a  ] tR tRt o RtR
R ltR tRR ltR tR t	R	t
V tR# )rC  i0  z&A read-only wrapper of part of a file.Nc                sJ    \         P                  WV4       W n        W0n        R# )zInitialize a _PartialFile.N)r   r   _start_stop)r   r   r0  r1  r   r   r   Z_PartialFile.__init__3  s    DU+
r   c                sN    \         P                  V 4      V P                  ,
          # )z*Return the position with respect to start.)r   r+  r  rD   rE   r   r+  Z_PartialFile.tell9  s    t$t{{22r   c                s    V^ 8X  d   V P                   V n        ^pMV^8X  d   V P                  V n        ^p\        P	                  WV4       R# )z8Change position, possibly with respect to start or stop.N)r  r  r  r   r{   r  r3   r   r{   Z_PartialFile.seek=  s>    Q;DIFq[

DIFf-r   c                s    V P                   V P                  ,
          pV^ 8:  d   R# Ve   V^ 8  g   W8  d   Tp\        P                  WV4      # )z;Read size bytes using read_method, honoring start and stop.r   )r  r  r   r  )r   r  r  Z	remainingrY   r   r  Z_PartialFile._readG  sF    JJ*	><4!8t'7DK88r   c                s2    \        V R 4      '       d   V =R# R# )r  N)r\   r  rD   rE   r   re   Z_PartialFile.closeP  s     4!!
 "r   )r  r  r  )NNr  )r   r   r   r   r   r   r+  r{   r  re   r   r   r   r   r   rC  rC  0  s&     03.9 r   rC  c                s   Rp \         '       d<    \         P                  ! V \         P                  \         P                  ,          4       V'       d    \        V P                  R,           4      pVP                  4          \        P                  ! TP                  T P                  R,           4       Rp\        P                  ! TP                  4       R# R#   \         da   pTP
                  \
        P                  \
        P                  \
        P                  39   d   \        RT P                  ,          4      hh Rp?ii ; i  \         d<   pTP
                  \
        P                  \
        P                  39   d    Rp?R# h Rp?ii ; i  \         \"        3 d9    \        P$                  ! TP                  T P                  R,           4       Rp R# i ; i  \&         d>    \        P(                  ! TP                  4       \        RT P                  ,          4      hi ; i   \         '       d&   \         P                  ! T \         P*                  4       T'       d(   \        P(                  ! T P                  R,           4       h ; i)z(Lock file f using lockf and dot locking.Fzlockf: lock unavailable: %sN.lockTzdot lock unavailable: %s)fcntllockfZLOCK_EXZLOCK_NBr   r   ZEAGAINr  r  r   r   r,  re   r   r   rp  r   r   r   r  r+   LOCK_UN)r   r)  Zdotlock_doner   Zpre_lockr  r   r%  r%  W  s   L%5Au}}u}}<= ,QVVg-=> 1-GGHMM166G+;<#'L
 IIhmm,#   77u||U\\5;;GG,-J-.VV.4 5 5   77u||U[[99	 '8 (IIhmmQVVg-=>#'L(
 # 1		(--(()C)**0 1 115KK5==)IIaffw&'s   H( :C H( ,E 4F 6 G E%AE  EH( F/F	H( F		FH( AGG GG AH%%H( (:J#(Jc                s&   \         '       d&   \         P                  ! V \         P                  4       \        P                  P                  V P                  R,           4      '       d*   \        P                  ! V P                  R,           4       R# R# )z*Unlock file f using lockf and dot locking.r  N)r  r  r  r   r   r   r   r+   r   rE   r   r'  r'    sO    uAu}}%	ww~~affw&''
		!&&7"# (r   c                s    \        V R4      # )zCCreate a file if it doesn't exist and open for reading and writing.zxb+)r   r   rE   r   r  r    s    er   c           
     s    \        V : R\        \        P                  ! 4       4      : R\        P                  ! 4       : R\
        P                  ! 4       : 24      # )zBCreate a temp file based on path and open for reading and writing.r   )r  r  r
  r  r  r   r  r  rE   r   r,  r,    s8    dC		4D.4.@.@.B.0iik; < <r   c                s    V P                  4        \        \        R4      '       d'   \        P                  ! V P	                  4       4       R# R# )z0Ensure changes to file f are physically on disk.fsyncN)r_   r\   r   r  Zfilenor  rE   r   r*  r*    s/    GGIr7
 r   c                s<    \        V 4       V P                  4        R# )z:Close file f, ensuring all changes are physically on disk.N)r*  re   r  rE   r   r   r     s    NGGIr   c                   r  )r   i  z"Raised for module-specific errors.r   Nr  r   r   r   r   r     s    ,r   c                   r  )r   i  z:The specified mailbox does not exist and won't be created.r   Nr  r   r   r   r   r     s    Dr   c                   r  )r   i  z>The specified mailbox is not empty and deletion was requested.r   Nr  r   r   r   r   r     s    Hr   c                   r  )r   i  z)Another process caused an action to fail.r   Nr  r   r   r   r   r         3r   c                   r  )r   i  z)A file appears to have an invalid format.r   Nr  r   r   r   r   r     r  r   )r   r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   )T)2r   r   r
  r  r  r   r  r   r>   Zemail.messageZemail.generatorrv   r9   Ztypesr    r  ZImportErrorZ__all__r}   rf   r   r   r  r:  r   r   r   r   r$   r   r   rE  r	   r
   r   r   r   rC  r%  r'  r  r,  r*  r   Z	Exceptionr   r   r   r   r   r   r   r   <module>r     s   J 
          	  A
 **

G
$f2 f2Rgg gTC CN@" @F1.9 1.h*.9 *.Z@* @*F
v vr"@emm## "@Jj+W j+Zn+w n+b1" 1E+ E+P\+7 \+~1" 1_2 _2D$: $N(T$<-I -E EIE I4 44% 4eD  Es   E7 7	FF