
bc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z d d l
 Z d d l Z y( e j d k r e  n  d d l Z Wn e k
 r e Z n Xd d l Z e j   0 e j re j d d e  n  d d l Z Wd QXd d d d	 d
 d d d d d d d d d d d d g Z d f  d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d	 e f d     YZ d
 e f d      YZ d e j j  f d!     YZ  d e  f d"     YZ! d# e  f d$     YZ" d e" f d%     YZ# d e  f d&     YZ$ d e  f d'     YZ% d e" f d(     YZ& d) f  d*     YZ' d+ e' f d,     YZ( e) d-  Z* d.   Z+ d/   Z, d0   Z- d1   Z. d2   Z/ d3 f  d4     YZ0 d e0 f d5     YZ1 d e1 f d6     YZ2 d e0 f d7     YZ3 d f  d8     YZ4 d e0 f d9     YZ5 d: e6 f d;     YZ7 d< e7 f d=     YZ8 d> e7 f d?     YZ9 d@ e7 f dA     YZ: dB e7 f dC     YZ; d S(D   sD   Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.iNt   os2emxt   ignores   .*rfc822 has been removedt   Mailboxt   Maildirt   mboxt   MHt   Babylt   MMDFt   Messaget   MaildirMessaget   mboxMessaget	   MHMessaget   BabylMessaget   MMDFMessaget   UnixMailboxt   PortableUnixMailboxt   MmdfMailboxt	   MHMailboxt   BabylMailboxc           B   s4  e  Z d  Z d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 d d  Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d d  Z d   Z d   Z d   Z  d   Z! e" Z# e" d  Z$ RS(    s*   A group of messages in a particular place.c         C   s.   t  j j t  j j |   |  _ | |  _ d S(   s   Initialize a Mailbox instance.N(   t   ost   patht   abspatht
   expandusert   _patht   _factory(   t   selfR   t   factoryt   create(    (    s   /usr/lib/python2.7/mailbox.pyt   __init__+   s    !c         C   s   t  d   d S(   s$   Add message and return assigned key.s&   Method must be implemented by subclassN(   t   NotImplementedError(   R   t   message(    (    s   /usr/lib/python2.7/mailbox.pyt   add0   s    c         C   s   t  d   d S(   s=   Remove the keyed message; raise KeyError if it doesn't exist.s&   Method must be implemented by subclassN(   R   (   R   t   key(    (    s   /usr/lib/python2.7/mailbox.pyt   remove4   s    c         C   s   |  j  |  d  S(   N(   R!   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   __delitem__8   s    c         C   s)   y |  j  |  Wn t k
 r$ n Xd S(   s'   If the keyed message exists, remove it.N(   R!   t   KeyError(   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   discard;   s    c         C   s   t  d   d S(   s>   Replace the keyed message; raise KeyError if it doesn't exist.s&   Method must be implemented by subclassN(   R   (   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyt   __setitem__B   s    c         C   s*   y |  j  |  SWn t k
 r% | SXd S(   s9   Return the keyed message, or default if it doesn't exist.N(   t   __getitem__R#   (   R   R    t   default(    (    s   /usr/lib/python2.7/mailbox.pyt   getF   s    c         C   s0   |  j  s |  j |  S|  j  |  j |   Sd S(   s=   Return the keyed message; raise KeyError if it doesn't exist.N(   R   t   get_messaget   get_file(   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR&   M   s    	c         C   s   t  d   d S(   s4   Return a Message representation or raise a KeyError.s&   Method must be implemented by subclassN(   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR)   T   s    c         C   s   t  d   d S(   s3   Return a string representation or raise a KeyError.s&   Method must be implemented by subclassN(   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt
   get_stringX   s    c         C   s   t  d   d S(   s6   Return a file-like representation or raise a KeyError.s&   Method must be implemented by subclassN(   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR*   \   s    c         C   s   t  d   d S(   s   Return an iterator over keys.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   iterkeys`   s    c         C   s   t  |  j    S(   s   Return a list of keys.(   t   listR,   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   keysd   s    c         c   sE   x> |  j    D]0 } y |  | } Wn t k
 r7 q n X| Vq Wd S(   s%   Return an iterator over all messages.N(   R,   R#   (   R   R    t   value(    (    s   /usr/lib/python2.7/mailbox.pyt
   itervaluesh   s    c         C   s
   |  j    S(   N(   R0   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   __iter__q   s    c         C   s   t  |  j    S(   s,   Return a list of messages. Memory intensive.(   R-   R0   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   valuest   s    c         c   sK   xD |  j    D]6 } y |  | } Wn t k
 r7 q n X| | f Vq Wd S(   s.   Return an iterator over (key, message) tuples.N(   R,   R#   (   R   R    R/   (    (    s   /usr/lib/python2.7/mailbox.pyt	   iteritemsx   s    c         C   s   t  |  j    S(   s9   Return a list of (key, message) tuples. Memory intensive.(   R-   R3   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   items   s    c         C   s   t  d   d S(   s9   Return True if the keyed message exists, False otherwise.s&   Method must be implemented by subclassN(   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   has_key   s    c         C   s   |  j  |  S(   N(   R5   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   __contains__   s    c         C   s   t  d   d S(   s*   Return a count of messages in the mailbox.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   __len__   s    c         C   s(   x! |  j    D] } |  j |  q Wd S(   s   Delete all messages.N(   R,   R$   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   clear   s    c         C   s4   y |  | } Wn t  k
 r" | SX|  j |  | S(   s3   Delete the keyed message and return it, or default.(   R#   R$   (   R   R    R'   t   result(    (    s   /usr/lib/python2.7/mailbox.pyt   pop   s    c         C   s7   x0 |  j    D] } | |  j |  f SWt d   d S(   s6   Delete an arbitrary (key, message) pair and return it.s   No messages in mailboxN(   R,   R:   R#   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyt   popitem   s    c         C   s   t  | d  r | j   } n$ t  | d  r< | j   } n | } t } x< | D]4 \ } } y | |  | <WqO t k
 r t } qO XqO W| r t d   n  d S(   s4   Change the messages that correspond to certain keys.R3   R4   s   No message with key(s)N(   t   hasattrR3   R4   t   FalseR#   t   True(   R   t   argt   sourcet   bad_keyR    R   (    (    s   /usr/lib/python2.7/mailbox.pyt   update   s    c         C   s   t  d   d S(   s&   Write any pending changes to the disk.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   flush   s    c         C   s   t  d   d S(   s   Lock the mailbox.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   lock   s    c         C   s   t  d   d S(   s#   Unlock the mailbox if it is locked.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   unlock   s    c         C   s   t  d   d S(   s   Flush and close the mailbox.s&   Method must be implemented by subclassN(   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   close   s    c   	      C   s	  t  | t j j  r t j   } t j j | | d  } | j |  | j d  | j	   j
 d t j  } | j |  |  j r| j t j  r| j t j  qnXt  | t  r+| r | j
 d d  } n  | j
 d t j  } | j |  |  j r| j t j  r| j t j  qn t | d  rd } xt t r| j   } | d k rePn  | r| j d  rd | d	 } n  | j
 d t j  } | j |  | } qCW|  j r| r| j t j  r| j t j  qn t d
 t |    d S(   s%   Dump message contents to target file.i    s   
s   
From s   
>From t   readt    s   From s   >From i   s   Invalid message type: %sN(   t
   isinstancet   emailR   R   t   StringIOt	   generatort	   Generatort   flattent   seekRG   t   replaceR   t   linesept   writet   _append_newlinet   endswitht   strR<   t   NoneR>   t   readlinet
   startswitht	   TypeErrort   type(	   R   R   t   targett   mangle_from_t   buffert   gent   datat   lastlinet   line(    (    s   /usr/lib/python2.7/mailbox.pyt   _dump_message   s<    	
"N(%   t   __name__t
   __module__t   __doc__RV   R>   R   R   R!   R"   R$   R%   R(   R&   R)   R+   R*   R,   R.   R0   R1   R2   R3   R4   R5   R6   R7   R8   R:   R;   RB   RC   RD   RE   RF   R=   RS   Rb   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   (   s@   																												c           B   s   e  Z d  Z d Z e j e d  Z d   Z d   Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d Z d   Z d   Z d   Z d   Z RS(   s   A qmail-style Maildir mailbox.t   :c         C   s  t  j |  | | |  i t j j |  j d  d 6t j j |  j d  d 6t j j |  j d  d 6|  _ t j j |  j  s | r t j |  j d  x9 |  j j	   D] } t j | d  q Wq t
 |  j   n  i  |  _ i d d 6d d 6|  _ d |  _ d |  _ d S(   s   Initialize a Maildir instance.t   tmpt   newt   curi  i    g?N(   R   R   R   R   t   joinR   t   _pathst   existst   mkdirR2   t   NoSuchMailboxErrort   _toct   _toc_mtimest
   _last_readt   _skewfactor(   R   t   dirnameR   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR      s    		c         C   s  |  j    } y |  j | |  Wn. t k
 rP | j   t j | j    n Xt |  t | t	  r | j
   } |  j | j   } | |  j k r d } q n d } d } t j j | j  j |  j  d } t j j |  j | | |  } t | t	  r4t j | j t j j | j  | j   f  n  yL t t d  rlt j | j |  t j | j  n t j | j |  WnK t k
 r} t j | j  | j t j k rt d |   q  n X| S(   s$   Add message and return assigned key.RH   Rh   i    t   links$   Name clash with existing message: %s(   t   _create_tmpRb   t   BaseExceptionRF   R   R!   t   namet   _sync_closeRI   R	   t
   get_subdirt   colont   get_infoR   t   basenamet   splitRj   R   t   utimet   getatimet   get_dateR<   Rt   t   renamet   OSErrort   errnot   EEXISTt   ExternalClashError(   R   R   t   tmp_filet   subdirt   suffixt   uniqt   destt   e(    (    s   /usr/lib/python2.7/mailbox.pyR     s@    

%%c         C   s,   t  j t  j j |  j |  j |    d S(   s=   Remove the keyed message; raise KeyError if it doesn't exist.N(   R   R!   R   Rj   R   t   _lookup(   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR!   4  s    c         C   sS   y |  j  |  Wn; t k
 r$ n+ t k
 rN } | j t j k rO   qO n Xd S(   s'   If the keyed message exists, remove it.N(   R!   R#   R   R   t   ENOENT(   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyR$   8  s    c         C   s$  |  j  |  } |  j |  } |  j  |  } t | t  rE | } n | } t j j |  } |  j | k r |  j | j |  j  d } n d } |  j	 |  t j j
 |  j |  }	 t j j
 |  j | | |  }
 t | t  rt j |	 t j j |	  | j   f  n  t j |	 |
  d S(   s>   Replace the keyed message; raise KeyError if it doesn't exist.iRH   N(   R   R   RI   R	   R   R   Rs   Rz   R}   R$   Rj   R   R~   R   R   R   (   R   R    R   t   old_subpatht   temp_keyt   temp_subpatht   dominant_subpathR   R   t   tmp_patht   new_path(    (    s   /usr/lib/python2.7/mailbox.pyR%   C  s"    	 	"c         C   s   |  j  |  } t t j j |  j |  d  } z+ |  j rN |  j |  } n t |  } Wd | j   Xt j j	 |  \ } } | j
 |  |  j | k r | j | j	 |  j  d  n  | j t j j t j j |  j |    | S(   s4   Return a Message representation or raise a KeyError.t   rNi(   R   t   openR   R   Rj   R   R   R	   RF   R}   t
   set_subdirRz   t   set_infot   set_datet   getmtime(   R   R    t   subpatht   ft   msgR   Rw   (    (    s   /usr/lib/python2.7/mailbox.pyR)   ^  s    !	 +c         C   sJ   t  t j j |  j |  j |   d  } z | j   SWd | j   Xd S(   s3   Return a string representation or raise a KeyError.R   N(   R   R   R   Rj   R   R   RG   RF   (   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyR+   p  s    *c         C   s4   t  t j j |  j |  j |   d  } t |  S(   s6   Return a file-like representation or raise a KeyError.t   rb(   R   R   R   Rj   R   R   t
   _ProxyFile(   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyR*   x  s    *c         c   sO   |  j    x> |  j D]3 } y |  j |  Wn t k
 rA q n X| Vq Wd S(   s   Return an iterator over keys.N(   t   _refreshRo   R   R#   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR,   }  s    
c         C   s   |  j    | |  j k S(   s9   Return True if the keyed message exists, False otherwise.(   R   Ro   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR5     s    
c         C   s   |  j    t |  j  S(   s*   Return a count of messages in the mailbox.(   R   t   lenRo   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR7     s    
c         C   s   d S(   s"   Write any pending changes to disk.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRC     s    c         C   s   d S(   s   Lock the mailbox.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRD     s    c         C   s   d S(   s#   Unlock the mailbox if it is locked.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRE     s    c         C   s   d S(   s   Flush and close the mailbox.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRF     s    c         C   s   g  } xt t  j |  j  D]` } t |  d k r | d d k r t  j j t  j j |  j |   r | j | d  q q W| S(   s   Return a list of folder names.i   i    t   .(   R   t   listdirR   R   R   t   isdirRj   t   append(   R   R9   t   entry(    (    s   /usr/lib/python2.7/mailbox.pyt   list_folders  s    "$c         C   s/   t  t j j |  j d |  d |  j d t S(   s/   Return a Maildir instance for the named folder.R   R   R   (   R   R   R   Rj   R   R   R=   (   R   t   folder(    (    s   /usr/lib/python2.7/mailbox.pyt
   get_folder  s    	c         C   s   t  j j |  j d |  } t | d |  j } t  j j | d  } t  j j |  s t  j t  j | t  j	 t  j
 Bd   n  | S(   s>   Create a folder and return a Maildir instance representing it.R   R   t   maildirfolderi  (   R   R   Rj   R   R   R   Rl   RF   R   t   O_CREATt   O_WRONLY(   R   R   R   R9   t   maildirfolder_path(    (    s   /usr/lib/python2.7/mailbox.pyt
   add_folder  s    c         C   s  t  j j |  j d |  } xw t  j t  j j | d   t  j t  j j | d   D]; } t |  d k  s | d d k rW t d |   qW qW Wxu t  j |  D]d } | d k r | d k r | d k r t  j j t  j j | |   r t d | | f   q q Wx t  j | d	 t	 D]i \ } } } x* | D]" } t  j
 t  j j | |   q:Wx* | D]" } t  j t  j j | |   qgWq$Wt  j |  d
 S(   s-   Delete the named folder, which must be empty.R   Rh   Ri   i   i    s   Folder contains message(s): %sRg   s%   Folder contains subdirectory '%s': %st   topdownN(   R   R   Rj   R   R   R   t   NotEmptyErrorR   t   walkR=   R!   t   rmdir(   R   R   R   R   t   roott   dirst   files(    (    s   /usr/lib/python2.7/mailbox.pyt   remove_folder  s     #"$!% $c         C   s   t  j    } xp t j t j j |  j d   D]M } t j j |  j d |  } | t j j |  d k r. t j |  q. q. Wd S(   s   Delete old files in "tmp".Rg   i@ N(   t   timeR   R   R   Rj   R   R   R!   (   R   t   nowR   R   (    (    s   /usr/lib/python2.7/mailbox.pyt   clean  s
    (i   c         C   sI  t  j    } t j   } d | k r9 | j d d  } n  d | k rZ | j d d  } n  d t |  t | d d  t j   t j | f } t j	 j
 |  j d |  } y t j |  Wnv t k
 r4} | j t j k r.t j d 7_ y t |  SWq1t k
 r*} | j t j k r+  q+q1Xq5  n Xt d	 |   d
 S(   s=   Create a file in the tmp subdirectory and open and return it.t   /s   \057Rf   s   \072s   %s.M%sP%sQ%s.%si   g    .ARg   s&   Name clash prevented file creation: %sN(   R   t   sockett   gethostnameRP   t   intR   t   getpidR   t   _countR   Rj   R   t   statR   R   R   t   _create_carefullyR   R   (   R   R   t   hostnameR   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyRu     s,    &c         C   s?  t  j    |  j d |  j k r t } xS |  j D]H } t j j |  j |  } | |  j | k rk t	 } n  | |  j | <q0 W| s d Sn  i  |  _
 x |  j D] } |  j | } xv t j |  D]e } t j j | |  } t j j |  r q n  | j |  j  d } t j j | |  |  j
 | <q Wq Wt  j    |  _ d S(   s!   Update table of contents mapping.i   Ni    (   R   Rq   Rr   R=   Rp   R   R   R   Rk   R>   Ro   R   Rj   R   R}   Rz   (   R   t   refreshR   t   mtimeR   R   t   pR   (    (    s   /usr/lib/python2.7/mailbox.pyR     s&     		$c         C   s   y: t  j j t  j j |  j |  j |   r9 |  j | SWn t k
 rM n X|  j   y |  j | SWn! t k
 r t d |   n Xd S(   s=   Use TOC to return subpath for given key, or raise a KeyError.s   No message with key: %sN(   R   R   Rl   Rj   R   Ro   R#   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR     s    +
c         C   so   t  |  d  s! |  j   |  _ n  xG t rj y |  |  j j   SWq$ t k
 rS d St k
 rf q$ q$ Xq$ Wd S(   s0   Return the next message in a one-time iteration.t   _onetime_keysN(   R<   R,   R   R>   t   nextt   StopIterationRV   R#   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   '  s    	(    Rc   Rd   Re   Rz   t   rfc822R   R>   R   R   R!   R$   R%   R)   R+   R*   R,   R5   R7   RC   RD   RE   RF   R   R   R   R   R   R   Ru   R   R   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR      s6   	)							
										
				$	t   _singlefileMailboxc           B   s   e  Z d  Z d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d d  Z d   Z RS(   s   A single-file mailbox.c         C   s   t  j |  | | |  y t |  j d  } Wn t k
 r } | j t j k r} | rk t |  j d  } q t |  j   q | j t j t j	 f k r t |  j d  } q   n X| |  _
 d |  _ d |  _ t |  _ t |  _ t |  _ d |  _ d S(   s!   Initialize a single-file mailbox.s   rb+s   wb+R   i    N(   R   R   R   R   t   IOErrorR   R   Rn   t   EACCESt   EROFSt   _fileRV   Ro   t	   _next_keyR=   t   _pendingt   _pending_synct   _lockedt   _file_length(   R   R   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   7  s$    						c         C   sF   |  j    |  j |  |  j |  j <|  j d 7_ t |  _ |  j d S(   s$   Add message and return assigned key.i   (   R   t   _append_messageRo   R   R>   R   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   N  s
    
	c         C   s$   |  j  |  |  j | =t |  _ d S(   s=   Remove the keyed message; raise KeyError if it doesn't exist.N(   R   Ro   R>   R   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR!   X  s    
c         C   s0   |  j  |  |  j |  |  j | <t |  _ d S(   s>   Replace the keyed message; raise KeyError if it doesn't exist.N(   R   R   Ro   R>   R   (   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyR%   ^  s    c         c   s-   |  j    x |  j j   D] } | Vq Wd S(   s   Return an iterator over keys.N(   R   Ro   R.   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR,   d  s    
c         C   s   |  j    | |  j k S(   s9   Return True if the keyed message exists, False otherwise.(   R   Ro   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR5   j  s    
c         C   s   |  j    t |  j  S(   s*   Return a count of messages in the mailbox.(   R   R   Ro   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR7   o  s    
c         C   s&   |  j  s" t |  j  t |  _  n  d S(   s   Lock the mailbox.N(   R   t
   _lock_fileR   R>   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRD   t  s    	c         C   s&   |  j  r" t |  j  t |  _  n  d S(   s#   Unlock the mailbox if it is locked.N(   R   t   _unlock_fileR   R=   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRE   z  s    	c         C   s  |  j  s/ |  j r+ t |  j  t |  _ n  d S|  j d k	 sD t  |  j j d d  |  j j	   } | |  j
 k r t d |  j
 | f   n  t |  j  } y i  } |  j |  x t |  j j    D] } |  j | \ } } |  j j |  |  j |  | j	   } xO t r_|  j j t d | |  j j	     } | d k rOPn  | j |  qW| | j	   f | | <|  j |  q W| j	   |  _
 Wn$ | j   t j | j    n Xt |  |  j j   t j |  j  j }	 t j | j |	  y t j | j |  j  Wnr t  k
 r}
 |
 j! t! j" k s\t j d k r|
 j! t! j# k rt j |  j  t j | j |  j  q  n Xt$ |  j d  |  _ | |  _ t |  _  t |  _ |  j% rt& |  j d	 t n  d S(
   s"   Write any pending changes to disk.Ni    i   s4   Size of mailbox file changed (expected %i, found %i)i   RH   t   os2s   rb+t   dotlock('   R   R   t   _sync_flushR   R=   Ro   RV   t   AssertionErrorRO   t   tellR   R   t   _create_temporaryR   t   _pre_mailbox_hookt   sortedR.   t   _pre_message_hookR>   RG   t   minRR   t   _post_message_hookRF   R   R!   Rw   Rx   R   t   st_modet   chmodR   R   R   R   R   R   R   R   (   R   t   cur_lent   new_filet   new_tocR    t   startt   stopt	   new_startR]   t   modeR   (    (    s   /usr/lib/python2.7/mailbox.pyRC     sf    			

!				c         C   s   d S(   s,   Called before writing the mailbox to file f.N(    (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s   d S(   s-   Called before writing each message to file f.N(    (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s   d S(   s,   Called after writing each message to file f.N(    (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   sA   z |  j    Wd z |  j r* |  j   n  Wd |  j j   XXd S(   s   Flush and close the mailbox.N(   RC   R   RE   R   RF   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRF     s    	c         C   sb   |  j  d k r |  j   n  | d k	 r^ y |  j  | SWq^ t k
 rZ t d |   q^ Xn  d S(   s'   Return (start, stop) or raise KeyError.s   No message with key: %sN(   Ro   RV   t   _generate_tocR#   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s   |  j  j d d  |  j  j   } t |  j  d k rT |  j rT |  j |  j   n  y3 |  j |  j   |  j |  } |  j	 |  j   Wn$ t
 k
 r |  j  j |    n X|  j  j   |  j  j   |  _ | S(   s;   Append message to mailbox and return (start, stop) offsets.i    i   (   R   RO   R   R   Ro   R   R   R   t   _install_messageR   Rv   t   truncateRC   R   (   R   R   t   beforet   offsets(    (    s   /usr/lib/python2.7/mailbox.pyR     s    N(   Rc   Rd   Re   RV   R>   R   R   R!   R%   R,   R5   R7   RD   RE   RC   R   R   R   RF   R   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   4  s"   	
								D				
t	   _mboxMMDFc           B   s>   e  Z d  Z e Z d   Z e d  Z e d  Z d   Z	 RS(   s   An mbox or MMDF mailbox.c         C   s   |  j  |  \ } } |  j j |  |  j j   j t j d  } |  j j | |  j j    } |  j	 | j t j d   } | j
 | d  | S(   s4   Return a Message representation or raise a KeyError.RH   s   
i   (   R   R   RO   RW   RP   R   RQ   RG   R   t   _message_factoryt   set_from(   R   R    R   R   t	   from_linet   stringR   (    (    s   /usr/lib/python2.7/mailbox.pyR)     s    c         C   sm   |  j  |  \ } } |  j j |  | s; |  j j   n  |  j j | |  j j    } | j t j d  S(   s3   Return a string representation or raise a KeyError.s   
(	   R   R   RO   RW   RG   R   RP   R   RQ   (   R   R    t   from_R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR+     s    c         C   sW   |  j  |  \ } } |  j j |  | s; |  j j   n  t |  j |  j j   |  S(   s6   Return a file-like representation or raise a KeyError.(   R   R   RO   RW   t   _PartialFileR   (   R   R    R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR*     s
    c         C   s/  d } t | t  ri | j d  ri | j d  } | d k rZ | |  } | | d } q | } d } nF t | t  r d | j   } n$ t | t j j	  r | j
   } n  | d k r d t j t j    } n  |  j j   } |  j j | t j  |  j | |  j |  j  |  j j   } | | f S(   s1   Format a message and blindly write to self._file.s   From s   
ii   RH   s   From MAILER-DAEMON %sN(   RV   RI   RU   RX   t   findt   _mboxMMDFMessaget   get_fromRJ   R   R   t   get_unixfromR   t   asctimet   gmtimeR   R   RR   R   RQ   Rb   t   _mangle_from_(   R   R   R   t   newlineR   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s&    
	(
   Rc   Rd   Re   R>   R   R)   R=   R+   R*   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   	
	c           B   s;   e  Z d  Z e Z e Z d e d  Z d   Z d   Z	 RS(   s   A classic mbox mailbox.c         C   s#   t  |  _ t j |  | | |  d S(   s   Initialize an mbox mailbox.N(   R
   R   R   R   (   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   =  s    	c         C   s   | j  t j  d S(   s,   Called after writing each message to file f.N(   RR   R   RQ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   B  s    c         C   s\  g  g  } } t  } |  j j d  x t r|  j j   } |  j j   } | j d  r t |  t |  k  r | r | j | t t	 j
   q | j |  n  | j |  t  } q& | s | r | j | t t	 j
   n | j |  Pq& | t	 j
 k rt } q& t  } q& Wt t t | |    |  _ t |  j  |  _ |  j j   |  _ d S(   s0   Generate key-to-(start, stop) table of contents.i    s   From N(   R=   R   RO   R>   R   RW   RX   R   R   R   RQ   t   dictt	   enumeratet   zipRo   R   R   (   R   t   startst   stopst   last_was_emptyt   line_posRa   (    (    s   /usr/lib/python2.7/mailbox.pyR   F  s0    			
N(
   Rc   Rd   Re   R>   R   RS   RV   R   R   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   4  s   	c           B   s8   e  Z d  Z d e d  Z d   Z d   Z d   Z RS(   s   An MMDF mailbox.c         C   s#   t  |  _ t j |  | | |  d S(   s   Initialize an MMDF mailbox.N(   R   R   R   R   (   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   k  s    	c         C   s   | j  d t j  d S(   s-   Called before writing each message to file f.s   N(   RR   R   RQ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   p  s    c         C   s   | j  t j d t j  d S(   s,   Called after writing each message to file f.s   N(   RR   R   RQ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   t  s    c         C   sb  g  g  } } |  j  j d  d } x t r| } |  j  j   } |  j  j   } | j d t j  r | j |  x t r | } |  j  j   } |  j  j   } | d t j k r | j | t	 t j   Pqv | d k rv | j |  Pqv qv Wq& | d k r& Pq& q& Wt
 t t | |    |  _ t	 |  j  |  _ |  j  j d d  |  j  j   |  _ d S(   s0   Generate key-to-(start, stop) table of contents.i    s   RH   i   N(   R   RO   R>   RW   R   RX   R   RQ   R   R   R   R   R   Ro   R   R   (   R   R  R  t   next_posR  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR   x  s2    		N(	   Rc   Rd   Re   RV   R>   R   R   R   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   h  s
   		c           B   s   e  Z d  Z d e d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   An MH mailbox.c         C   s   t  j |  | | |  t j j |  j  s | r t j |  j d  t j t j t j j	 |  j d  t j
 t j Bt j Bd   q t |  j   n  t |  _ d S(   s   Initialize an MH instance.i  s   .mh_sequencesi  N(   R   R   R   R   Rl   R   Rm   RF   R   Rj   R   t   O_EXCLR   Rn   R=   R   (   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    !!c         C   s:  |  j    } t |  d k r' d } n t |  d } t j j |  j t |   } t |  } t	 } z |  j
 r t |  n  z y |  j | |  WnG t k
 r |  j
 r t |  n  t |  t } t j |    n Xt | t  r|  j | |  n  Wd |  j
 rt |  n  XWd | s5t |  n  X| S(   s$   Add message and return assigned key.i    i   N(   R.   R   t   maxR   R   Rj   R   RU   R   R=   R   R   Rb   Rv   R   Rx   R>   R!   RI   R   t   _dump_sequences(   R   R   R.   t   new_keyR   R   t   closed(    (    s   /usr/lib/python2.7/mailbox.pyR     s6    			
	c         C   s   t  j j |  j t |   } y t | d  } Wn; t k
 rn } | j t j k rh t	 d |   q   n X| j
   t  j |  d S(   s=   Remove the keyed message; raise KeyError if it doesn't exist.s   rb+s   No message with key: %sN(   R   R   Rj   R   RU   R   R   R   R   R#   RF   R!   (   R   R    R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR!     s    
c         C   s  t  j j |  j t |   } y t | d  } Wn; t k
 rn } | j t j k rh t	 d |   qo   n Xz |  j
 r t |  n  zY t  j t  j | t  j t  j B  |  j | |  t | t  r |  j | |  n  Wd |  j
 r t |  n  XWd t |  Xd S(   s>   Replace the keyed message; raise KeyError if it doesn't exist.s   rb+s   No message with key: %sN(   R   R   Rj   R   RU   R   R   R   R   R#   R   R   RF   R   t   O_TRUNCRb   RI   R   R  R   Rx   (   R   R    R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR%     s$    	#	c         C   s1  y^ |  j  r6 t t j j |  j t |   d  } n' t t j j |  j t |   d  } Wn; t k
 r } | j t j	 k r t
 d |   q   n XzD |  j  r t |  n  z t |  } Wd |  j  r t |  n  XWd | j   Xx< |  j   j   D]( \ } } | | k r| j |  qqW| S(   s4   Return a Message representation or raise a KeyError.s   r+R   s   No message with key: %sN(   R   R   R   R   Rj   R   RU   R   R   R   R#   R   R   R   RF   t   get_sequencesR3   t   add_sequence(   R   R    R   R   R   Rw   t   key_list(    (    s   /usr/lib/python2.7/mailbox.pyR)     s(    	*+		c         C   s   y^ |  j  r6 t t j j |  j t |   d  } n' t t j j |  j t |   d  } Wn; t k
 r } | j t j	 k r t
 d |   q   n XzB |  j  r t |  n  z | j   SWd |  j  r t |  n  XWd | j   Xd S(   s3   Return a string representation or raise a KeyError.s   r+R   s   No message with key: %sN(   R   R   R   R   Rj   R   RU   R   R   R   R#   R   RG   R   RF   (   R   R    R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR+     s     	*+		c         C   ss   y+ t  t j j |  j t |   d  } Wn; t k
 rh } | j t j k rb t	 d |   qi   n Xt
 |  S(   s6   Return a file-like representation or raise a KeyError.R   s   No message with key: %s(   R   R   R   Rj   R   RU   R   R   R   R#   R   (   R   R    R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR*     s    +c         C   s&   t  t d   t j |  j  D   S(   s   Return an iterator over keys.c         s   s'   |  ] } | j    r t |  Vq d  S(   N(   t   isdigitR   (   t   .0R   (    (    s   /usr/lib/python2.7/mailbox.pys	   <genexpr>+  s    (   t   iterR   R   R   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR,   )  s    c         C   s(   t  j j t  j j |  j t |    S(   s9   Return True if the keyed message exists, False otherwise.(   R   R   Rl   Rj   R   RU   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR5   .  s    c         C   s   t  t |  j     S(   s*   Return a count of messages in the mailbox.(   R   R-   R,   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR7   2  s    c         C   sJ   |  j  sF t t j j |  j d  d  |  _ t |  j  t |  _  n  d S(   s   Lock the mailbox.s   .mh_sequencess   rb+N(	   R   R   R   R   Rj   R   R   R   R>   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRD   6  s    	$c         C   s9   |  j  r5 t |  j  t |  j  |  ` t |  _  n  d S(   s#   Unlock the mailbox if it is locked.N(   R   R   R   Rx   R=   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRE   =  s
    	c         C   s   d S(   s&   Write any pending changes to the disk.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRC   E  s    c         C   s   |  j  r |  j   n  d S(   s   Flush and close the mailbox.N(   R   RE   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRF   I  s    	c         C   s[   g  } xN t  j |  j  D]: } t  j j t  j j |  j |   r | j |  q q W| S(   s   Return a list of folder names.(   R   R   R   R   R   Rj   R   (   R   R9   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   N  s
    $c         C   s+   t  t j j |  j |  d |  j d t S(   s+   Return an MH instance for the named folder.R   R   (   R   R   R   Rj   R   R   R=   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   V  s    c         C   s%   t  t j j |  j |  d |  j S(   s:   Create a folder and return an MH instance representing it.R   (   R   R   R   Rj   R   R   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   [  s    c         C   s   t  j j |  j |  } t  j |  } | d g k rU t  j t  j j | d   n" | g  k rd n t d |  j   t  j |  d S(   s-   Delete the named folder, which must be empty.s   .mh_sequencess   Folder not empty: %sN(   R   R   Rj   R   R   R!   R   R   (   R   R   R   t   entries(    (    s   /usr/lib/python2.7/mailbox.pyR   `  s    c         C   sm  i  } t  t j j |  j d  d  } z4t |  j    } x| D]} y | j d  \ } } t   } xo | j   D]a } | j   r | j	 t
 |   qw d   | j d  D \ }	 }
 | j t |	 |
 d   qw Wg  t |  D] } | | k r | ^ q | | <t | |  d k r+| | =n  WqC t k
 rUt d | j     qC XqC WWd	 | j   X| S(
   s=   Return a name-to-key-list dictionary to define each sequence.s   .mh_sequencesR   Rf   c         s   s   |  ] } t  |  Vq d  S(   N(   R   (   R  t   x(    (    s   /usr/lib/python2.7/mailbox.pys	   <genexpr>z  s    t   -i   i    s"   Invalid sequence specification: %sN(   R   R   R   Rj   R   t   setR.   R}   R  R   R   RB   t   rangeR   R   t
   ValueErrort   FormatErrort   rstripRF   (   R   t   resultsR   t   all_keysRa   Rw   t   contentsR.   t   specR   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR  l  s,    !	c         C   se  t  t j j |  j d  d  } z2t j t j  | j t j t j B  x| j	   D] \ } } t
 |  d k r{ qW n  | j d |  d
 } t } x t t |   D]r } | d | k r | st } | j d  qn7 | rt } | j d | | f  n | j d |  | } q W| rA| j t |  d	  qW | j d	  qW WWd
 t |  Xd
 S(   s:   Set sequences using the given name-to-key-list dictionary.s   .mh_sequencess   r+i    s   %s:i   R  s   %s %ss    %ss   
N(   R   R   R   Rj   R   RF   Rw   R   R  R3   R   RR   RV   R=   R   R  R>   RU   Rx   (   R   t	   sequencesR   Rw   R.   t   prevt
   completingR    (    (    s   /usr/lib/python2.7/mailbox.pyt   set_sequences  s.    !&
c   	      C   s  |  j    } d } g  } x|  j   D] } | d | k r| j | | d f  t t d  r t j t j j |  j t	 |   t j j |  j t	 | d    t j
 t j j |  j t	 |    qt j t j j |  j t	 |   t j j |  j t	 | d    n  | d 7} q% W| d |  _ t |  d k rEd SxS | j   D]E \ } } x6 | D]. \ } } | | k re| | | j |  <qeqeWqRW|  j |  d S(   s?   Re-name messages to eliminate numbering gaps. Invalidates keys.i    i   Rt   N(   R  R,   R   R<   R   Rt   R   Rj   R   RU   t   unlinkR   R   R   R4   t   indexR!  (	   R   R  R  t   changesR    Rw   R  t   oldRh   (    (    s   /usr/lib/python2.7/mailbox.pyt   pack  s*    !#(!&c         C   s   | j    } |  j    } xU | j   D]G \ } } | | k rM | j |  q% | | k r% | | j |  =q% q% Wx* | D]" } | | k rw | g | | <qw qw W|  j |  d S(   s;   Inspect a new MHMessage and update sequences appropriately.N(   R  R3   R   R#  R!  (   R   R   R    t   pending_sequencest   all_sequencesRw   R  t   sequence(    (    s   /usr/lib/python2.7/mailbox.pyR    s    N(   Rc   Rd   Re   RV   R>   R   R   R!   R%   R)   R+   R*   R,   R5   R7   RD   RE   RC   RF   R   R   R   R   R  R!  R&  R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s.   	"																			c           B   s   e  Z d  Z e d  Z d e d  Z d	   Z d
   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   An Rmail-style Babyl mailbox.t   unseent   deletedt   filedt   answeredt	   forwardedt   editedt   resentc         C   s#   t  j |  | | |  i  |  _ d S(   s   Initialize a Babyl mailbox.N(   R   R   t   _labels(   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s;   t  j |  |  } t | t  r7 | j   |  j | <n  | S(   s$   Add message and return assigned key.(   R   R   RI   R   t
   get_labelsR1  (   R   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s0   t  j |  |  | |  j k r, |  j | =n  d S(   s=   Remove the keyed message; raise KeyError if it doesn't exist.N(   R   R!   R1  (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR!     s    c         C   s<   t  j |  | |  t | t  r8 | j   |  j | <n  d S(   s>   Replace the keyed message; raise KeyError if it doesn't exist.N(   R   R%   RI   R   R2  R1  (   R   R    R   (    (    s   /usr/lib/python2.7/mailbox.pyR%     s    c   	      C   s}  |  j  |  \ } } |  j j |  |  j j   t j   } xX t r |  j j   } | d t j k su | d k ry Pn  | j | j	 t j d   qA Wt j   } xT t r |  j j   } | t j k s | d k r Pn  | j | j	 t j d   q W|  j j
 | |  j j    j	 t j d  } t | j   |  } | j | j    | |  j k ry| j |  j |  n  | S(   s4   Return a Message representation or raise a KeyError.s   *** EOOH ***RH   s   
(   R   R   RO   RW   RK   R>   R   RQ   RR   RP   RG   R   R   t   getvaluet   set_visibleR1  t
   set_labels(	   R   R    R   R   t   original_headersRa   t   visible_headerst   bodyR   (    (    s   /usr/lib/python2.7/mailbox.pyR)     s,    	 	 %	c         C   s
  |  j  |  \ } } |  j j |  |  j j   t j   } xX t r |  j j   } | d t j k su | d k ry Pn  | j | j	 t j d   qA Wx8 t r |  j j   } | t j k s | d k r Pq q W| j
   |  j j | |  j j    j	 t j d  S(   s3   Return a string representation or raise a KeyError.s   *** EOOH ***RH   s   
(   R   R   RO   RW   RK   R>   R   RQ   RR   RP   R3  RG   R   (   R   R    R   R   R6  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR+     s     	 		%c         C   s%   t  j  |  j |  j d t j   S(   s6   Return a file-like representation or raise a KeyError.s   
(   RK   R+   RP   R   RQ   (   R   R    (    (    s   /usr/lib/python2.7/mailbox.pyR*     s    c         C   sT   |  j    t   } x$ |  j j   D] } | j |  q# W| j |  j  t |  S(   s4   Return a list of user-defined labels in the mailbox.(   R   R  R1  R2   RB   t   difference_updatet   _special_labelsR-   (   R   t   labelst
   label_list(    (    s   /usr/lib/python2.7/mailbox.pyR2    s    
	c   	      C   s  g  g  } } |  j  j d  d } g  } x[t r| } |  j  j   } |  j  j   } | d t j k rt |  t |  k  r | j | t t j   n  | j |  g  |  j  j   d j	 d  D]$ } | j
   d k r | j
   ^ q } | j |  q, | d k s!| d t j k rYt |  t |  k  r| j | t t j   qq, | d k r, | j | t t j   Pq, q, Wt t t | |    |  _ t t |   |  _ t |  j  |  _ |  j  j d d  |  j  j   |  _ d S(	   s0   Generate key-to-(start, stop) table of contents.i    s   i   t   ,RH   s   i   N(   R   RO   R>   RW   R   R   RQ   R   R   R}   t   stripR   R   R   Ro   R1  R   R   (	   R   R  R  R  t   label_listsR  Ra   t   labelR;  (    (    s   /usr/lib/python2.7/mailbox.pyR   $  s6    	 $ c         C   s9   | j  d t j t j d j |  j    t j f  d S(   s,   Called before writing the mailbox to file f.s(   BABYL OPTIONS:%sVersion: 5%sLabels:%s%sR=  N(   RR   R   RQ   Rj   R2  (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   B  s    	c         C   s   | j  d t j  d S(   s-   Called before writing each message to file f.s   N(   RR   R   RQ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   H  s    c         C   s   | j  t j d  d S(   s,   Called after writing each message to file f.s   N(   RR   R   RQ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   L  s    c         C   s,  |  j  j   } t | t  r g  } g  } x@ | j   D]2 } | |  j k r\ | j |  q7 | j |  q7 W|  j  j d  x" | D] } |  j  j d |  q W|  j  j d  x& | D] } |  j  j d | d  q W|  j  j t j	  n |  j  j d t j	  t | t
 j j  rt j   } t
 j j | t d  } | j |  | j d  xQ t r| j   } |  j  j | j d t j	   | d k s| d	 k r^Pq^q^W|  j  j d
 t j	  t | t  rct j   }	 t
 j j |	 t d  }
 |
 j | j    x t r_|	 j   } |  j  j | j d t j	   | d k sX| d	 k rPqqWna | j d  xQ t r| j   } |  j  j | j d t j	   | d k s| d	 k rsPqsqsWxLt r| j d  } | d	 k rPn  |  j  j | j d t j	   qWnt | t  r| j d  d } | d d k r|  j  j | |  j d t j	   |  j  j d
 t j	  |  j  j | |  j d t j	   |  j  j | | j d t j	   q|  j  j d
 t j	 t j	  |  j  j | j d t j	   nt | d  r| j   } t } x t r| j   } |  j  j | j d t j	   | d k st| d	 k r+| rt } |  j  j d
 t j	  | j |  qPq+q+Wxa t r| j d  } | d	 k rPn  |  j  j | j d t j	   qWn t d t |    |  j  j   } | | f S(   s0   Write message contents and return (start, stop).t   1s   , s   ,,t    R=  s   1,,i    s   
RH   s   *** EOOH ***i   s   

i   iRW   s   Invalid message type: %s(   R   R   RI   R   R2  R:  R   RR   R   RQ   RJ   R   R   RK   RL   RM   R=   RN   RO   R>   RW   RP   t   get_visibleRG   RU   R   R<   RY   RZ   (   R   R   R   t   special_labelsR;  R@  t   orig_buffert   orig_generatorRa   t
   vis_buffert   vis_generatorR]   t
   body_startt   original_post
   first_passR   (    (    s   /usr/lib/python2.7/mailbox.pyR   P  s    				&"		&(   R*  R+  R,  R-  R.  R/  R0  N(   Rc   Rd   Re   t	   frozensetR:  RV   R>   R   R   R!   R%   R)   R+   R*   R2  R   R   R   R   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s    													c           B   s,   e  Z d  Z d d  Z d   Z d   Z RS(   s0   Message with mailbox-format-specific properties.c         C   s   t  | t j j  rM |  j t j |   t  | t  r | j |   q n t  | t  ru |  j t j	 |   n` t
 | d  r |  j t j |   n8 | d k r t j j j |   n t d t |    d S(   s   Initialize a Message instance.RG   s   Invalid message type: %sN(   RI   RJ   R   R   t   _become_messaget   copyt   deepcopyt   _explain_toRU   t   message_from_stringR<   t   message_from_fileRV   R   RY   RZ   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s)   x" d
 D] } | j  | |  j  | <q Wd	 S(   s0   Assume the non-format-specific state of message.t   _headerst	   _unixfromt   _payloadt   _charsett   preamblet   epiloguet   defectst   _default_typeN(   RS  RT  RU  RV  RW  RX  RY  RZ  (   t   __dict__(   R   R   Rw   (    (    s   /usr/lib/python2.7/mailbox.pyRM    s    
c         C   s#   t  | t  r d St d   d S(   s:   Copy format-specific state to message insofar as possible.Ns    Cannot convert to specified type(   RI   R   RY   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyRP    s    N(   Rc   Rd   Re   RV   R   RM  RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   	c           B   s}   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z RS(   s)   Message with Maildir-specific properties.c         C   s5   d |  _  d |  _ t j   |  _ t j |  |  d S(   s%   Initialize a MaildirMessage instance.Rh   RH   N(   t   _subdirt   _infoR   t   _dateR   R   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    		c         C   s   |  j  S(   s   Return 'new' or 'cur'.(   R\  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRy     s    c         C   s8   | d k s | d k r$ | |  _  n t d |   d S(   s   Set subdir to 'new' or 'cur'.Rh   Ri   s!   subdir must be 'new' or 'cur': %sN(   R\  R  (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s%   |  j  j d  r |  j  d Sd Sd S(   s*   Return as a string the flags that are set.s   2,i   RH   N(   R]  RX   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyt	   get_flags  s    c         C   s    d d j  t |   |  _ d S(   s)   Set the given flags and unset all others.s   2,RH   N(   Rj   R   R]  (   R   t   flags(    (    s   /usr/lib/python2.7/mailbox.pyt	   set_flags  s    c         C   s0   |  j  d j t |  j    t |  B  d S(   s.   Set the given flag(s) without changing others.RH   N(   Ra  Rj   R  R_  (   R   t   flag(    (    s   /usr/lib/python2.7/mailbox.pyt   add_flag  s    c         C   sE   |  j    d k rA |  j d j t |  j     t |    n  d S(   s7   Unset the given string flag(s) without changing others.RH   N(   R_  Ra  Rj   R  (   R   Rb  (    (    s   /usr/lib/python2.7/mailbox.pyt   remove_flag  s    c         C   s   |  j  S(   s<   Return delivery date of message, in seconds since the epoch.(   R^  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s;   y t  |  |  _ Wn! t k
 r6 t d |   n Xd S(   s9   Set delivery date of message, in seconds since the epoch.s   can't convert to float: %sN(   t   floatR^  R  RY   (   R   t   date(    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   s   |  j  S(   s%   Get the message's "info" as a string.(   R]  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR{     s    c         C   s5   t  | t  r | |  _ n t d t |    d S(   s    Set the message's "info" string.s   info must be a string: %sN(   RI   RU   R]  RY   RZ   (   R   t   info(    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   sX  t  | t  rK | j |  j    | j |  j    | j |  j    n	t  | t  r t	 |  j    } d | k r | j
 d  n  |  j   d k r | j
 d  n  d | k r | j
 d  n  d | k r | j
 d  n  d | k r | j
 d  n  | j d	 t j |  j     n4t  | t  rt	 |  j    } d | k r]| j d
  n  d | k ry| j d  n  d | k rT| j d  qTn t  | t  r,t	 |  j    } d | k r| j d
  n  d | k r| j d  n  d | k r| j d  n  d | k rT| j d  qTn( t  | t  r>n t d t |    d S(   s;   Copy Maildir-specific state to message insofar as possible.t   St   RRi   t   Ot   Tt   Dt   Ft   As   MAILER-DAEMONR*  t   repliedt   flaggedR+  R-  t   PR.  s$   Cannot convert to specified type: %sN(   RI   R	   Ra  R_  R   Ry   R   R   R   R  Rc  R   R   R   R   R  R   t	   add_labelR   RY   RZ   (   R   R   R`  (    (    s   /usr/lib/python2.7/mailbox.pyRP    sN    "N(   Rc   Rd   Re   RV   R   Ry   R   R_  Ra  Rc  Rd  R   R   R{   R   RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR	     s   										R   c           B   s\   e  Z d  Z d	 d  Z d   Z d	 d  Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   s/   Message with mbox- or MMDF-specific properties.c         C   sw   |  j  d t  t | t j j  rc | j   } | d k	 rc | j d  rc |  j  | d  qc n  t j	 |  |  d S(   s'   Initialize an mboxMMDFMessage instance.s   MAILER-DAEMONs   From i   N(
   R   R>   RI   RJ   R   R   R   RV   RX   R   (   R   R   t   unixfrom(    (    s   /usr/lib/python2.7/mailbox.pyR   7  s    c         C   s   |  j  S(   s    Return contents of "From " line.(   t   _from(   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   @  s    c         C   sN   | d k	 rA | t k r' t j   } n  | d t j |  7} n  | |  _ d S(   s>   Set "From " line, formatting and appending time_ if specified.RB  N(   RV   R>   R   R   R   Rt  (   R   R   t   time_(    (    s   /usr/lib/python2.7/mailbox.pyR   D  s
    c         C   s    |  j  d d  |  j  d d  S(   s*   Return as a string the flags that are set.t   StatusRH   s   X-Status(   R(   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR_  L  s    c         C   s  t  |  } d
 \ } } x4 d D], } | | k r | | 7} | j |  q q Wx4 d D], } | | k rV | | 7} | j |  qV qV W| d j t |   7} y |  j d |  Wn! t k
 r |  j d |  n Xy |  j d |  Wn! t k
 r|  j d |  n Xd	 S(   s)   Set the given flags and unset all others.RH   Ri  Rj  Rl  Rm  Rn  Rv  s   X-StatusN(   RH   RH   (   Ri  Rj  (   Rl  Rm  Rn  (   R  R!   Rj   R   t   replace_headerR#   t
   add_header(   R   R`  t   status_flagst   xstatus_flagsRb  (    (    s   /usr/lib/python2.7/mailbox.pyRa  P  s&    

c         C   s0   |  j  d j t |  j    t |  B  d S(   s.   Set the given flag(s) without changing others.RH   N(   Ra  Rj   R  R_  (   R   Rb  (    (    s   /usr/lib/python2.7/mailbox.pyRc  f  s    c         C   sK   d |  k s d |  k rG |  j  d j t |  j    t |    n  d S(   s7   Unset the given string flag(s) without changing others.Rv  s   X-StatusRH   N(   Ra  Rj   R  R_  (   R   Rb  (    (    s   /usr/lib/python2.7/mailbox.pyRd  j  s    c         C   s  t  | t  rt |  j    } d | k r= | j d  n  d | k rY | j d  n  d | k ru | j d  n  d | k r | j d  n  d | k r | j d  n  | d	 =| d
 =d j |  j   j   d  } y& | j	 t
 j t j | d    Wqt t f k
 rqXnlt  | t  rU| j |  j    | j |  j    n4t  | t  rt |  j    } d | k r| j d  n  d | k r| j d  n  d | k r| j d  n  | d	 =| d
 =n t  | t  rat |  j    } d | k r| j d  n  d | k r4| j d  n  d | k rP| j d  n  | d	 =| d
 =n( t  | t  rsn t d t |    d S(   sA   Copy mbox- or MMDF-specific state to message insofar as possible.Rj  Ri   Rm  Rn  Ri  Rh  Rl  Rk  t   statuss   x-statusRB  is   %a %b %d %H:%M:%S %YR*  Ro  Rp  R+  R-  s$   Cannot convert to specified type: %sN(   RI   R	   R  R_  R   Rc  Rj   R   R}   R   t   calendart   timegmR   t   strptimeR  t   OverflowErrorR   Ra  R   R   R  R   Rr  R   RY   RZ   (   R   R   R`  t
   maybe_date(    (    s   /usr/lib/python2.7/mailbox.pyRP  o  s^    

N(   Rc   Rd   Re   RV   R   R   R   R_  Ra  Rc  Rd  RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR   4  s   						c           B   s   e  Z d  Z RS(   s&   Message with mbox-specific properties.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR
     s   c           B   sG   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 RS(   s$   Message with MH-specific properties.c         C   s   g  |  _  t j |  |  d S(   s!   Initialize an MHMessage instance.N(   t
   _sequencesR   R   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    	c         C   s   |  j  S(   s4   Return a list of sequences that include the message.(   R  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR    s    c         C   s   t  |  |  _ d S(   s3   Set the list of sequences that include the message.N(   R-   R  (   R   R  (    (    s   /usr/lib/python2.7/mailbox.pyR!    s    c         C   sN   t  | t  r4 | |  j k rJ |  j j |  qJ n t d t |    d S(   s8   Add sequence to list of sequences including the message.s   sequence must be a string: %sN(   RI   RU   R  R   RY   RZ   (   R   R)  (    (    s   /usr/lib/python2.7/mailbox.pyR    s    c         C   s,   y |  j  j |  Wn t k
 r' n Xd S(   sA   Remove sequence from the list of sequences including the message.N(   R  R!   R  (   R   R)  (    (    s   /usr/lib/python2.7/mailbox.pyt   remove_sequence  s    c         C   s  t  | t  r t |  j    } d | k r= | j d  n | j d  | j d  d | k rs | j d  n  d | k r| j d  qn?t  | t  rt |  j    } d | k r | j d  n | j d	  d | k r | j d  n  d | k r| j d
  qn t  | t  rMx |  j   D] } | j |  q3Wn t  | t	  rt |  j    } d | k r| j
 d  n  d | k r| j
 d  qn( t  | t  rn t d t |    d S(   s6   Copy MH-specific state to message insofar as possible.R*  Ri   Rh  Rp  Rm  Ro  Ri  t   RORj  Rn  R-  s$   Cannot convert to specified type: %sN(   RI   R	   R  R  R   Rc  R   R   R  R   Rr  R   RY   RZ   (   R   R   R  R)  (    (    s   /usr/lib/python2.7/mailbox.pyRP    s@    N(
   Rc   Rd   Re   RV   R   R  R!  R  R  RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   				c           B   sb   e  Z d  Z d
 d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z RS(   s'   Message with Babyl-specific properties.c         C   s)   g  |  _  t   |  _ t j |  |  d S(   s#   Initialize a BabylMessage instance.N(   R1  R   t   _visibleR   (   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    	c         C   s   |  j  S(   s'   Return a list of labels on the message.(   R1  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR2    s    c         C   s   t  |  |  _ d S(   s&   Set the list of labels on the message.N(   R-   R1  (   R   R;  (    (    s   /usr/lib/python2.7/mailbox.pyR5    s    c         C   sN   t  | t  r4 | |  j k rJ |  j j |  qJ n t d t |    d S(   s+   Add label to list of labels on the message.s   label must be a string: %sN(   RI   RU   R1  R   RY   RZ   (   R   R@  (    (    s   /usr/lib/python2.7/mailbox.pyRr    s    c         C   s,   y |  j  j |  Wn t k
 r' n Xd S(   s4   Remove label from the list of labels on the message.N(   R1  R!   R  (   R   R@  (    (    s   /usr/lib/python2.7/mailbox.pyt   remove_label  s    c         C   s   t  |  j  S(   s3   Return a Message representation of visible headers.(   R   R  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRC    s    c         C   s   t  |  |  _ d S(   s2   Set the Message representation of visible headers.N(   R   R  (   R   t   visible(    (    s   /usr/lib/python2.7/mailbox.pyR4    s    c         C   s   xG |  j  j   D]6 } | |  k r< |  j  j | |  |  q |  j  | =q Wx= d D]5 } | |  k rQ | |  j  k rQ |  | |  j  | <qQ qQ Wd S(	   s9   Update and/or sensibly generate a set of visible headers.t   Datet   Froms   Reply-Tot   Tot   CCt   SubjectN(   R  R  s   Reply-ToR  R  R  (   R  R.   Rw  (   R   t   header(    (    s   /usr/lib/python2.7/mailbox.pyt   update_visible  s    c         C   s  t  | t  r t |  j    } d | k r= | j d  n | j d  | j d  d | k so d | k r | j d  n  d | k r | j d  n  d	 | k r| j d
  qnRt  | t  r?t |  j    } d | k r | j d  n | j d  d	 | k r | j d  n  d | k r| j d  qn t  | t  rt |  j    } d | k r|| j d  n  d | k r| j d  qnq t  | t	  r| j
 |  j    xL |  j   D] } | j |  qWn( t  | t  rn t d t |    d S(   s9   Copy Babyl-specific state to message insofar as possible.R*  Ri   Rh  R.  R0  Rq  R-  Ri  R+  Rk  R  Rj  Rl  Rn  Ro  s$   Cannot convert to specified type: %sN(   RI   R	   R  R2  R   Rc  R   R   R  R   R4  RC  Rr  R   RY   RZ   (   R   R   R;  R@  (    (    s   /usr/lib/python2.7/mailbox.pyRP     sF    N(   Rc   Rd   Re   RV   R   R2  R5  Rr  R  RC  R4  R  RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   							c           B   s   e  Z d  Z RS(   s&   Message with MMDF-specific properties.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   J  s   R   c           B   sn   e  Z d  Z d d  Z d d  Z d d  Z d d  Z d   Z d   Z	 d d  Z
 d	   Z d
   Z RS(   s   A read-only wrapper of a file.c         C   s4   | |  _  | d k r' | j   |  _ n	 | |  _ d S(   s   Initialize a _ProxyFile.N(   R   RV   R   t   _pos(   R   R   t   pos(    (    s   /usr/lib/python2.7/mailbox.pyR   Q  s    	c         C   s   |  j  | |  j j  S(   s   Read bytes.(   t   _readR   RG   (   R   t   size(    (    s   /usr/lib/python2.7/mailbox.pyRG   Y  s    c         C   s   |  j  | |  j j  S(   s   Read a line.(   R  R   RW   (   R   R  (    (    s   /usr/lib/python2.7/mailbox.pyRW   ]  s    c         C   sW   g  } xJ |  D]B } | j  |  | d k	 r | t |  8} | d k rO PqO q q W| S(   s   Read multiple lines.i    N(   R   RV   R   (   R   t   sizehintR9   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyt	   readlinesa  s    c         C   s   t  |  j d  S(   s   Iterate over lines.RH   (   R  RW   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR1   l  s    c         C   s   |  j  S(   s   Return the position.(   R  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR   p  s    i    c         C   sK   | d k r" |  j  j |  j  n  |  j  j | |  |  j  j   |  _ d S(   s   Change position.i   N(   R   RO   R  R   (   R   t   offsett   whence(    (    s   /usr/lib/python2.7/mailbox.pyRO   t  s    c         C   s>   t  |  d  r: t  |  j d  r1 |  j j   n  |  ` n  d S(   s   Close the file.R   RF   N(   R<   R   RF   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRF   {  s    c         C   sJ   | d k r d } n  |  j j |  j  | |  } |  j j   |  _ | S(   s"   Read size bytes using read_method.iN(   RV   R   RO   R  R   (   R   R  t   read_methodR9   (    (    s   /usr/lib/python2.7/mailbox.pyR    s    	N(   Rc   Rd   Re   RV   R   RG   RW   R  R1   R   RO   RF   R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR   N  s   			R   c           B   sD   e  Z d  Z d d d  Z d   Z d d  Z d   Z d   Z RS(   s&   A read-only wrapper of part of a file.c         C   s)   t  j |  | |  | |  _ | |  _ d S(   s   Initialize a _PartialFile.N(   R   R   t   _startt   _stop(   R   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    	c         C   s   t  j |   |  j S(   s*   Return the position with respect to start.(   R   R   R  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    i    c         C   sY   | d k r! |  j  |  _ d } n! | d k rB |  j |  _ d } n  t j |  | |  d S(   s8   Change position, possibly with respect to start or stop.i    i   i   N(   R  R  R  R   RO   (   R   R  R  (    (    s   /usr/lib/python2.7/mailbox.pyRO     s    		c         C   s`   |  j  |  j } | d k r  d S| d k sD | d k  sD | | k rM | } n  t j |  | |  S(   s;   Read size bytes using read_method, honoring start and stop.i    RH   N(   R  R  RV   R   R  (   R   R  R  t	   remaining(    (    s   /usr/lib/python2.7/mailbox.pyR    s    $	c         C   s   t  |  d  r |  ` n  d  S(   NR   (   R<   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRF     s    N(	   Rc   Rd   Re   RV   R   R   RO   R  RF   (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   	
		c         C   s  t  } yt r y t j |  t j t j B Wq t k
 r| } | j t j t j t j	 f k rv t
 d |  j   q}   q Xn  | ry! t |  j d  } | j   Wn5 t k
 r } | j t j t j	 f k r d S  n Xyf t t d  r$t j | j |  j d  t } t j | j  n  t j | j |  j d  t } Wqt k
 r} | j t j k st j d k r| j t j k rt j | j  t
 d |  j   q  qXn  WnC t rt j |  t j  n  | rt j |  j d  n    n Xd S(   s(   Lock file f using lockf and dot locking.s   lockf: lock unavailable: %ss   .lockNRt   R   s   dot lock unavailable: %s(   R=   t   fcntlt   lockft   LOCK_EXt   LOCK_NBR   R   t   EAGAINR   R   R   Rw   R   RF   R<   R   Rt   R>   R"  R   R   R   R!   t   LOCK_UN(   R   R   t   dotlock_doneR   t   pre_lock(    (    s   /usr/lib/python2.7/mailbox.pyR     sL    !

!c         C   sP   t  r t  j |  t  j  n  t j j |  j d  rL t j |  j d  n  d S(   s*   Unlock file f using lockf and dot locking.s   .lockN(   R  R  R  R   R   Rl   Rw   R!   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    c         C   sL   t  j |  t  j t  j Bt  j Bd  } z t |  d  SWd t  j |  Xd S(   sC   Create a file if it doesn't exist and open for reading and writing.i  s   rb+N(   R   R   R   R  t   O_RDWRRF   (   R   t   fd(    (    s   /usr/lib/python2.7/mailbox.pyR     s    &c         C   s2   t  d |  t t j    t j   t j   f  S(   sB   Create a temp file based on path and open for reading and writing.s   %s.%s.%s.%s(   R   R   R   R   R   R   R   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    	c         C   s3   |  j    t t d  r/ t j |  j    n  d S(   s0   Ensure changes to file f are physically on disk.t   fsyncN(   RC   R<   R   R  t   fileno(   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    
c         C   s   t  |   |  j   d S(   s:   Close file f, ensuring all changes are physically on disk.N(   R   RF   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRx     s    
t   _Mailboxc           B   s)   e  Z e j d   Z d   Z d   Z RS(   c         C   s   | |  _  d |  _ | |  _ d  S(   Ni    (   t   fpt   seekpR   (   R   R  R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    		c         C   s   t  |  j d   S(   N(   R  R   RV   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR1     s    c         C   s   x |  j  j |  j  y |  j   Wn$ t k
 rJ |  j  j   |  _ d  SX|  j  j   } |  j   |  j  j   |  _ } | | k r Pq q W|  j t	 |  j  | |   S(   N(
   R  RO   R  t   _search_startt   EOFErrorR   RV   t   _search_endR   R   (   R   R   R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    
(   Rc   Rd   R   R   R   R1   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR    s   	c           B   s>   e  Z d    Z d   Z d Z d Z d   Z d   Z e Z	 RS(   c         C   sk   xd |  j  j   } |  j  j   } | s0 t  n  | d  d k r |  j |  r |  j  j |  d  Sq Wd  S(   Ni   s   From (   R  R   RW   R  t   _isrealfromlineRO   (   R   R  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR  !  s    	c         C   ss   |  j  j   x_ |  j  j   } |  j  j   } | s8 d  S| d  d k r |  j |  r |  j  j |  d  Sq Wd  S(   Ni   s   From (   R  RW   R   R  RO   (   R   R  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR  +  s    sa   From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*[^\s]*\s*$c         C   s=   |  j  s- d d  l } | j |  j  |  _  n  |  j  j |  S(   Ni(   t   _regexpt   ret   compilet   _fromlinepatternt   match(   R   Ra   R  (    (    s   /usr/lib/python2.7/mailbox.pyt   _strict_isrealfromlineU  s    	c         C   s   t  S(   N(   R>   (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyt   _portable_isrealfromline[  s    N(
   Rc   Rd   R  R  R  RV   R  R  R  R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   	
	$		c           B   s   e  Z e j Z RS(    (   Rc   Rd   R   R  R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR   a  s   c           B   s   e  Z d    Z d   Z RS(   c         C   s=   x6 |  j  j   } | s! t  n  | d  d k r d  Sq Wd  S(   Ni   s   
(   R  RW   R  (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR  g  s    	c         C   sS   xL |  j  j   } |  j  j   } | s+ d  S| d k r |  j  j |  d  Sq Wd  S(   Ns   
(   R  R   RW   RO   (   R   R  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR  o  s    (   Rc   Rd   R  R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR   e  s   	c           B   s)   e  Z e j d   Z d   Z d   Z RS(   c         C   s   d d  l  } | j d  } | |  _ t j |  j  } t | j |  } t t |  } | j	   t t
 |  |  _ |  j j   | |  _ d  S(   Nis   ^[1-9][0-9]*$(   R  R  Rs   R   R   t   filterR  t   mapt   longt   sortRU   t   boxest   reverseR   (   R   Rs   R   R  t   patR-   (    (    s   /usr/lib/python2.7/mailbox.pyR   |  s    	
c         C   s   t  |  j d   S(   N(   R  R   RV   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR1     s    c         C   st   |  j  s d  S|  j  j   } t t j j |  j |   } |  j |  } y | | _	 Wn t
 t f k
 ro n X| S(   N(   R  RV   R:   R   R   R   Rj   Rs   R   t	   _mh_msgnot   AttributeErrorRY   (   R   t   fnR  R   (    (    s   /usr/lib/python2.7/mailbox.pyR     s    	(   Rc   Rd   R   R   R   R1   R   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   z  s   	c           B   s   e  Z d    Z d   Z RS(   c         C   s9   x2 |  j  j   } | s! t  n  | d k r d  Sq Wd  S(   Ns   *** EOOH ***
(   R  RW   R  (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR    s    	c         C   s_   xX |  j  j   } |  j  j   } | s+ d  S| d k sC | d k r |  j  j |  d  Sq Wd  S(   Ns   
s   (   R  R   RW   RO   (   R   R  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR    s    (   Rc   Rd   R  R  (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   	t   Errorc           B   s   e  Z d  Z RS(   s"   Raised for module-specific errors.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR    s   Rn   c           B   s   e  Z d  Z RS(   s:   The specified mailbox does not exist and won't be created.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyRn     s   R   c           B   s   e  Z d  Z RS(   s>   The specified mailbox is not empty and deletion was requested.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   R   c           B   s   e  Z d  Z RS(   s)   Another process caused an action to fail.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR     s   R  c           B   s   e  Z d  Z RS(   s)   A file appears to have an invalid format.(   Rc   Rd   Re   (    (    (    s   /usr/lib/python2.7/mailbox.pyR    s   (<   Re   t   sysR   R   R|  R   R   RN  RJ   t   email.messaget   email.generatorRK   t   platformt   ImportErrorR  RV   t   warningst   catch_warningst   py3kwarningt   filterwarningst   DeprecationWarningR   t   __all__R   R   R   R   R   R   R   R   R   R   R	   R   R
   R   R   R   R   R   R>   R   R   R   R   R   Rx   R  R   R   R   R   R   t	   ExceptionR  Rn   R   R   R  (    (    (    s   /usr/lib/python2.7/mailbox.pyt   <module>   s~   	
	
	 C84- 8 koF]>'-					
B"