ó
—êé[c           @   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.iÿÿÿÿNt   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.iÿÿÿÿRH   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   s1   |  j  ƒ  |  j r  |  j ƒ  n  |  j j ƒ  d 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   
iÿÿÿÿi   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   9  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à   >  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ê   B  s0    			
N(
   Rc   Rd   Re   R>   Rü   RS   RV   R   Rà   Rê   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   0  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   g  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Þ   l  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à   p  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ê   t  s2    		N(	   Rc   Rd   Re   RV   R>   R   RÞ   Rà   Rê   (    (    (    s   /usr/lib/python2.7/mailbox.pyR   d  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   .  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   2  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   9  s
    	c         C   s   d S(   s&   Write any pending changes to the disk.N(    (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRC   A  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   E  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¦   J  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¨   R  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­   W  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>v  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  h  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Ü   >  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Þ   D  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à   H  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   iÿÿÿÿRW   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ë   L  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   3  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ñ   @  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_  H  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  L  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  b  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  f  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  iûÿÿÿs   %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  k  s^    

N(   Rc   Rd   Re   RV   R   Rø   Rñ   R_  Ra  Rc  Rd  RP  (    (    (    s   /usr/lib/python2.7/mailbox.pyR÷   0  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 an 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   F  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   M  s    	c         C   s   |  j  | |  j j ƒ S(   s   Read bytes.(   t   _readRÍ   RG   (   R   t   size(    (    s   /usr/lib/python2.7/mailbox.pyRG   U  s    c         C   s   |  j  | |  j j ƒ S(   s   Read a line.(   R�  RÍ   RW   (   R   R‘  (    (    s   /usr/lib/python2.7/mailbox.pyRW   Y  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	   readlines]  s    c         C   s   t  |  j d ƒ S(   s   Iterate over lines.RH   (   R  RW   (   R   (    (    s   /usr/lib/python2.7/mailbox.pyR1   h  s    c         C   s   |  j  S(   s   Return the position.(   RŽ  (   R   (    (    s   /usr/lib/python2.7/mailbox.pyRÚ   l  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   p  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   w  s    c         C   sJ   | d k r d } n  |  j j |  j ƒ | | ƒ } |  j j ƒ  |  _ | S(   s"   Read size bytes using read_method.iÿÿÿÿN(   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ž   J  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 |  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   sj   xc |  j  j ƒ  } |  j  j ƒ  } | s0 t ‚ n  | d  d k r |  j | ƒ r |  j  j | ƒ d  Sq d  S(   Ni   s   From (   R§  RÚ   RW   Rª  t   _isrealfromlineRO   (   R   R�  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR©    s    	c         C   sr   |  j  j ƒ  x^ |  j  j ƒ  } |  j  j ƒ  } | s8 d  S| d  d k r |  j | ƒ r |  j  j | ƒ d  Sq d  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_isrealfromlineQ  s    	c         C   s   t  S(   N(   R>   (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyt   _portable_isrealfromlineW  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   ]  s   c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s<   x5 |  j  j ƒ  } | s! t ‚ n  | d  d k r d  Sq d  S(   Ni   s   
(   R§  RW   Rª  (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR©  c  s    	c         C   sR   xK |  j  j ƒ  } |  j  j ƒ  } | s+ d  S| d k r |  j  j | ƒ d  Sq d  S(   Ns   
(   R§  RÚ   RW   RO   (   R   R�  Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR«  k  s    (   Rc   Rd   R©  R«  (    (    (    s   /usr/lib/python2.7/mailbox.pyR   a  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(   Niÿÿÿÿs   ^[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   x  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   v  s   	c           B   s   e  Z d  „  Z d „  Z RS(   c         C   s8   x1 |  j  j ƒ  } | s! t ‚ n  | d k r d  Sq d  S(   Ns   *** EOOH ***
(   R§  RW   Rª  (   R   Ra   (    (    s   /usr/lib/python2.7/mailbox.pyR©  š  s    	c         C   s^   xW |  j  j ƒ  } |  j  j ƒ  } | s+ d  S| d k sC | d k r |  j  j | ƒ d  Sq d  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"