
M9c       s    d  Z  6 C d Z D d Z E d Z F d Z K d k Z L d k Z M d k l Z N d k	 Z	 O d k
 Z
 P d k Z Q d k Z R d k Z S d k l Z X d e f d	     YZ \ d
 f  d     YZ  e	 i d  Z  d   Z  d f  d     YZ d e i f d     YZ d e f d     YZ d f  d     YZ d d  Z d d  Z d   Z e d j o e   n d S(   s	  MH interface -- purely object-oriented (well, almost)

Executive summary:

import mhlib

mh = mhlib.MH()         # use default mailbox directory and profile
mh = mhlib.MH(mailbox)  # override mailbox location (default from profile)
mh = mhlib.MH(mailbox, profile) # override mailbox and profile

mh.error(format, ...)   # print error message -- can be overridden
s = mh.getprofile(key)  # profile entry (None if not set)
path = mh.getpath()     # mailbox pathname
name = mh.getcontext()  # name of current folder
mh.setcontext(name)     # set name of current folder

list = mh.listfolders() # names of top-level folders
list = mh.listallfolders() # names of all folders, including subfolders
list = mh.listsubfolders(name) # direct subfolders of given folder
list = mh.listallsubfolders(name) # all subfolders of given folder

mh.makefolder(name)     # create new folder
mh.deletefolder(name)   # delete folder -- must have no subfolders

f = mh.openfolder(name) # new open folder object

f.error(format, ...)    # same as mh.error(format, ...)
path = f.getfullname()  # folder's full pathname
path = f.getsequencesfilename() # full pathname of folder's sequences file
path = f.getmessagefilename(n)  # full pathname of message n in folder

list = f.listmessages() # list of messages in folder (as numbers)
n = f.getcurrent()      # get current message
f.setcurrent(n)         # set current message
list = f.parsesequence(seq)     # parse msgs syntax into list of messages
n = f.getlast()         # get last message (0 if no messagse)
f.setlast(n)            # set last message (internal use only)

dict = f.getsequences() # dictionary of sequences in folder {name: list}
f.putsequences(dict)    # write sequences back to folder

f.createmessage(n, fp)  # add message from file f as number n
f.removemessages(list)  # remove messages in list from folder
f.refilemessages(list, tofolder) # move messages in list to other folder
f.movemessage(n, tofolder, ton)  # move one message to a given destination
f.copymessage(n, tofolder, ton)  # copy one message to a given destination

m = f.openmessage(n)    # new open message object (costs a file descriptor)
m is a derived class of mimetools.Message(rfc822.Message), with:
s = m.getheadertext()   # text of message's headers
s = m.getheadertext(pred) # text of message's headers, filtered by pred
s = m.getbodytext()     # text of message's body, decoded
s = m.getbodytext(0)    # text of message's body, not decoded
s   ~/.mh_profiles   ~/Mails   .mh_sequencesi  N(   s   ST_NLINK(   s   bisects   Errorc      s   X Y RS(   N(    (    s"   /mit/python/lib/python2.0/mhlib.pys   ErrorX s   s   MHc      s   \ d  Z  a c e e d  Z o d   Z s d   Z w d   Z { d   Z  d   Z  d   Z  d   Z	  d	   Z
  d
   Z  d   Z  d   Z  d   Z  d   Z RS(   s<  Class representing a particular collection of folders.
    Optional constructor arguments are the pathname for the directory
    containing the collection, and the MH profile to use.
    If either is omitted or empty a default is used; the default
    directory is taken from the MH profile if it is specified there.c    s   c d e | o e t } n f t i i |  |  _  g | o g |  i d  } n h | o h t } n i t i i |  o | d d j o j t i i	 d |  } n k t i i |  } l t i i
 |  o l t d  n m | |  _ d S(   s   Constructor.s   Pathi    s   ~s   MH() path not foundN(   s   profiles
   MH_PROFILEs   oss   paths
   expandusers   selfs
   getprofiles   PATHs   isabss   joins   isdirs   Error(   s   selfs   paths   profiles"   /mit/python/lib/python2.0/mhlib.pys   __init__c s      ( c    s#   o p q d |  i |  i f Sd S(   s   String representation.s
   MH(%s, %s)N(   s   selfs   paths   profile(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   __repr__o s   c    s%   s t u t  i i d | |  d S(   sA   Routine to print an error.  May be overridden by a derived class.s   MH error: %s
N(   s   syss   stderrs   writes   msgs   args(   s   selfs   msgs   argss"   /mit/python/lib/python2.0/mhlib.pys   errors s   c    s   w x y t  |  i |  Sd S(   s*   Return a profile entry, None if not found.N(   s   picklines   selfs   profiles   key(   s   selfs   keys"   /mit/python/lib/python2.0/mhlib.pys
   getprofilew s   c    s   { | } |  i Sd S(   s9   Return the path (the name of the collection's directory).N(   s   selfs   path(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getpath{ s   c    sS      t  t i i |  i   d   d  }  | o  d } n  | Sd S(   s&   Return the name of the current folder.s   contexts   Current-Folders   inboxN(   s   picklines   oss   paths   joins   selfs   getpaths   context(   s   selfs   contexts"   /mit/python/lib/python2.0/mhlib.pys
   getcontext s    c    s[      t  i i |  i   d  }  t | d  }  | i d |   | i
   d S(   s#   Set the name of the current folder.s   contexts   ws   Current-Folder: %s
N(   s   oss   paths   joins   selfs   getpaths   fns   opens   fs   writes   contexts   close(   s   selfs   contexts   fns   fs"   /mit/python/lib/python2.0/mhlib.pys
   setcontext s
   c    s      g  }  |  i   }  x^ t i |  d  rH }  t i i | |  }  t i i	 |  o  | i
 |  n q3 W | i    | Sd S(   s*   Return the names of the top-level folders.i    N(   s   folderss   selfs   getpaths   paths   oss   listdirs   names   joins   fullnames   isdirs   appends   sort(   s   selfs   folderss   paths   names   fullnames"   /mit/python/lib/python2.0/mhlib.pys   listfolders s   	 	c 
   s&     t  i i |  i |  }  t  i |  }  | t }  | d j o  g  Sn  g  }  t  i |  }  x | d  r }  t  i i | |  }  t  i i |  oQ  t  i i | |  }	  | i |	   | d }  | d j o  Pn n q W | i    | Sd S(   sc   Return the names of the subfolders in a given folder
        (prefixed with the given folder name).i   i    i   N(   s   oss   paths   joins   selfs   names   fullnames   stats   sts   ST_NLINKs   nlinkss
   subfolderss   listdirs   subnamess   subnames   fullsubnames   isdirs   name_subnames   appends   sort(
   s   selfs   names   fullnames   sts   nlinkss
   subfolderss   subnamess   subnames   fullsubnames   name_subnames"   /mit/python/lib/python2.0/mhlib.pys   listsubfolders s&   	 	c    s      |  i d  Sd S(   s<   Return the names of all folders and subfolders, recursively.s    N(   s   selfs   listallsubfolders(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   listallfolders s   c    s     t  i i |  i |  }  t  i |  }  | t }  | d j o  g  Sn  g  }  t  i |  }  x | d  r }  | d d j p
 t |  o
  q n  t  i i | |  }  t  i i |  o  t  i i | |  }	  | i |	   t  i i |  o#  |  i |	  }
  | |
 } n  | d }  | d j o  Pn n q W | i    | Sd S(   s>   Return the names of subfolders in a given folder, recursively.i   i    s   ,i   N(   s   oss   paths   joins   selfs   names   fullnames   stats   sts   ST_NLINKs   nlinkss
   subfolderss   listdirs   subnamess   subnames	   isnumerics   fullsubnames   isdirs   name_subnames   appends   islinks   listallsubfolderss   subsubfolderss   sort(   s   selfs   names   fullnames   sts   nlinkss
   subfolderss   subnamess   subnames   fullsubnames   name_subnames   subsubfolderss"   /mit/python/lib/python2.0/mhlib.pys   listallsubfolders s0   	 	! 
c    s      t  |  |  Sd S(   s0   Return a new Folder object for the named folder.N(   s   Folders   selfs   name(   s   selfs   names"   /mit/python/lib/python2.0/mhlib.pys
   openfolder s   c    s      t  |  i d  }  | o
 t |  o  t i | d  } n
  t }  t	 i
 t	 i i |  i   |  |  d S(   s@   Create a new folder (or raise os.error if it cannot be created).s   Folder-Protecti   N(   s   picklines   selfs   profiles   protects	   isnumerics   strings   atois   modes   FOLDER_PROTECTs   oss   mkdirs   paths   joins   getpaths   name(   s   selfs   names   protects   modes"   /mit/python/lib/python2.0/mhlib.pys
   makefolder s   	c    s      t  i i |  i   |  }  x{ t  i |  d  re }  t  i i | |  }  y  t  i
 |  Wn-  t  i j
 o  |  i d |  n Xq9 W t  i |  d S(   s   Delete a folder.  This removes files in the folder but not
        subdirectories.  Raise os.error if deleting the folder itself fails.i    s   %s not deleted, continuing...N(   s   oss   paths   joins   selfs   getpaths   names   fullnames   listdirs   subnames   fullsubnames   unlinks   errors   rmdir(   s   selfs   names   fullnames   subnames   fullsubnames"   /mit/python/lib/python2.0/mhlib.pys   deletefolder s    	(   s   __doc__s   Nones   __init__s   __repr__s   errors
   getprofiles   getpaths
   getcontexts
   setcontexts   listfolderss   listsubfolderss   listallfolderss   listallsubfolderss
   openfolders
   makefolders   deletefolder(    s"   /mit/python/lib/python2.0/mhlib.pys   MH\ s   		s   ^[1-9][0-9]*$c    s     t  i |   t j	 Sd  S(   N(   s   numericprogs   matchs   strs   None(   s   strs"   /mit/python/lib/python2.0/mhlib.pys	   isnumeric s   s   Folderc      s=   d  Z    d   Z  d   Z  d   Z d   Z d   Z d   Z d   Z d   Z d	   Z	 (d
   Z
 <d   Z Md   Z Ud   Z Yd   Z d   Z d   Z d   Z d d  Z d   Z !d   Z Ad   Z [d   Z ud   Z d   Z d   Z RS(   s'   Class representing a particular folder.c    sS      | |  _   | |  _  t i i |  i    o  t d |  n d S(   s   Constructor.s   no folder %sN(   s   mhs   selfs   names   oss   paths   isdirs   getfullnames   Error(   s   selfs   mhs   names"   /mit/python/lib/python2.0/mhlib.pys   __init__ s
   c    s#      d |  i |  i f Sd S(   s   String representation.s   Folder(%s, %s)N(   s   selfs   mhs   name(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   __repr__ s   c    s      t  |  i i |  d S(   s   Error message handler.N(   s   applys   selfs   mhs   errors   args(   s   selfs   argss"   /mit/python/lib/python2.0/mhlib.pys   error s   c    s)   t  i i |  i i |  i  Sd S(   s'   Return the full pathname of the folder.N(   s   oss   paths   joins   selfs   mhs   name(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getfullnames   c    s&   	t  i i |  i   t  Sd S(   s8   Return the full pathname of the folder's sequences file.N(   s   oss   paths   joins   selfs   getfullnames   MH_SEQUENCES(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getsequencesfilenames   c    s,   t  i i |  i   t |   Sd S(   s4   Return the full pathname of a message in the folder.N(   s   oss   paths   joins   selfs   getfullnames   strs   n(   s   selfs   ns"   /mit/python/lib/python2.0/mhlib.pys   getmessagefilenames   c    s    |  i i |  i  Sd S(   s!   Return list of direct subfolders.N(   s   selfs   mhs   listsubfolderss   name(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   listsubfolderss   c    s    |  i i |  i  Sd S(   s   Return list of all subfolders.N(   s   selfs   mhs   listallsubfolderss   name(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   listallsubfolderss   c    s   g  } t i } | i } xC t i |  i    d r' } | |  o | |  n qB W t	 t
 i |  } !| i   "| o #| d |  _ n %d |  _ &| Sd S(   s   Return the list of messages currently present in the folder.
        As a side effect, set self.last to the last message (or 0).i    i   N(   s   messagess   numericprogs   matchs   appends   oss   listdirs   selfs   getfullnames   names   maps   strings   atois   sorts   last(   s   selfs   messagess   matchs   appends   names"   /mit/python/lib/python2.0/mhlib.pys   listmessagess   	 	
c    s3  ()*h  } +|  i   } ,y -t | d  } Wn .t j
 o /| Sn X0x 0d o 1| i   } 2| o 2Pn 3t	 i
 | d  } 4t |  d j o' 5|  i d | t	 i |  f  n 7t	 i | d  } 8t t	 i | d  d  i   } 9| | | <q] W:| Sd S(	   s+   Return the set of sequences for the folder.s   ri   s   :i   s   bad sequence in %s: %si    s    N(   s	   sequencess   selfs   getsequencesfilenames   fullnames   opens   fs   IOErrors   readlines   lines   strings   splitfieldss   fieldss   lens   errors   strips   keys   IntSets   tolists   value(   s   selfs	   sequencess   fullnames   fs   lines   fieldss   keys   values"   /mit/python/lib/python2.0/mhlib.pys   getsequences(s&   	 
 '%c    s   <=>|  i   } ?t } @x | i   d @rm } At d d  } B| i
 | |  C| o Ct | d  } n D| i d | | i   f  q0 WE| o: Fy Gt i |  Wn Ht i j
 o
 In Xn K| i   d S(   s.   Write the set of sequences back to the folder.i    s    s    s   ws   %s: %s
N(   s   selfs   getsequencesfilenames   fullnames   Nones   fs	   sequencess   keyss   keys   IntSets   ss   fromlists   opens   writes   tostrings   oss   unlinks   errors   close(   s   selfs	   sequencess   fullnames   fs   keys   ss"   /mit/python/lib/python2.0/mhlib.pys   putsequences<s    	 	 $c    s\   MNO|  i   } Py Qt | d  SWn( Rt t f j
 o St d  n Xd S(   s<   Return the current message.  Raise Error when there is none.s   curs   no cur messageN(   s   selfs   getsequencess   seqss   maxs
   ValueErrors   KeyErrors   Error(   s   selfs   seqss"   /mit/python/lib/python2.0/mhlib.pys
   getcurrentMs   c    s,   UVWt  |  i   d t |  d  d S(   s   Set the current message.s   curi    N(   s
   updatelines   selfs   getsequencesfilenames   strs   n(   s   selfs   ns"   /mit/python/lib/python2.0/mhlib.pys
   setcurrentUs   c    sl  Y]b|  i   } d| o et d |  i  n g| d j o h| Sn jt i | d  } k| d j oQl| |  d | | d f \ } } } m| d  d j o! n| d  | d f \ } } n ot |  o pt d |  n qy rt i |  } Wn+ st t f j
 o ut |  } n Xvy w|  i | |  } Wn xt j
 o }	 y|  i   }
 z|
 i |  o9 {|	 o |d | }	 n }t |	 t i   d	  n ~|
 | } | o t d
 |  n | d j o | | Sn | |  Sn X| o' | d d f j o d } n n | d j o1 t | |  } | t d | |  | !Sn) t | | d  } | | | | !Sn t i | d  } | d j o |  i | |  |  } |  i | | d |  } t | | d  } t | |  } | | | !} | o t d |  n | Sn y |  i | |  } Wnr t j
 oc }	 |  i   }
 |
 i |  o, |	 o d | }	 n t |	  n |
 | SnT X| | j o8 t |  o t d |  n t d |  n | g Sd S(   s   Parse an MH sequence specification into a message list.
        Attempt to mimic mh-sequence(5) as close as possible.
        Also attempt to mimic observed behavior regarding which
        conditions cause which error messages.s   no messages in %ss   alls   :i    s    i   s   -+s   bad message list %si   s   sequence %s emptys   -s   prevs   lasts   message %d doesn't exists   no %s messageN("   s   selfs   listmessagess   alls   Errors   names   seqs   strings   finds   is   heads   dirs   tails	   isnumerics   atois   counts
   ValueErrors   OverflowErrors   lens   _parseindexs   anchors   msgs   getsequencess   seqss   has_keys   syss   exc_infos   msgss   bisects   maxs   begins   ends   js   rs   n(   s   selfs   seqs   alls   is   heads   dirs   tails   counts   anchors   msgs   seqss   msgss   begins   ends   js   rs   ns"   /mit/python/lib/python2.0/mhlib.pys   parsesequenceYs~   '!c    s  t  |  oD y t i |  SWn& t t f j
 o t i Sn Xn | d d f j o |  i	   Sn | d j o | d Sn | d j o | d Sn | d j o\ |  i	   } t | |  } y | | SWn" t j
 o t d  n Xn | d	 j o |  i	   } t | | d  } | d j o t d
  n y | | d SWn" t j
 o t d
  n Xn t t  d S(   s7   Internal: parse a message number (or cur, first, etc.).s   curs   .s   firsti    s   lasti   s   nexts   no next messages   prevs   no prev messageN(   s	   isnumerics   seqs   strings   atois   OverflowErrors
   ValueErrors   syss   maxints   selfs
   getcurrents   alls   ns   bisects   is
   IndexErrors   Errors   None(   s   selfs   seqs   alls   ns   is"   /mit/python/lib/python2.0/mhlib.pys   _parseindexs:   c    s   t  |  |  Sd S(   s+   Open a message -- returns a Message object.N(   s   Messages   selfs   n(   s   selfs   ns"   /mit/python/lib/python2.0/mhlib.pys   openmessages   c    s_  g  } g  } x | d r } |  i |  } |  i d t |   } y t	 i
 |  Wn t	 i j
 o
 n Xy t	 i | |  Wn+ t	 i j
 o } | i |  n X| i |  q$ W| o |  i |  n | oF t |  d j o t	 i | d  n t	 i d | f  n d S(   s2   Remove one or more messages -- may raise os.error.i    s   ,i   s   multiple errors:N(   s   errorss   deleteds   lists   ns   selfs   getmessagefilenames   paths   strs	   commapaths   oss   unlinks   errors   renames   msgs   appends   removefromallsequencess   len(   s   selfs   lists   errorss   deleteds   ns   paths	   commapaths   msgs"   /mit/python/lib/python2.0/mhlib.pys   removemessagess,   		 	

c    s  g  } h  } x7| d r*} | i   d } |  i |  } | i |  }	 y t i | |	  Wn t i j
 o y' t i | |	  t i |  Wnm t t i f j
 oU }
 | i |
  y t i |	  Wn t i j
 o
 n Xq$ n Xn X | i |  | | | <q$ W| oA | o | i |  | i    n |  i | i    n | oF t |  d j o t i | d  n 
t i d | f  n d S(   s_   Refile one or more messages -- may raise os.error.
        'tofolder' is an open folder object.i    i   s   multiple errors:N(   s   errorss   refileds   lists   ns   tofolders   getlasts   tons   selfs   getmessagefilenames   paths   topaths   oss   renames   errors   shutils   copy2s   unlinks   IOErrors   msgs   appends   setlasts   keepsequencess   _copysequencess   itemss   removefromallsequencess   keyss   len(   s   selfs   lists   tofolders   keepsequencess   errorss   refileds   ns   tons   paths   topaths   msgs"   /mit/python/lib/python2.0/mhlib.pys   refilemessagess>   		 	


i    c    s  | i   } |  i   } d } x | i   d r \ } } y | | } d }	 Wn g  } d }	 n XxF | d r9 \ }
 } |
 | j o | i |  d } n q W|	 o | o | | | <n q? W| o |  i |  n d S(   s.   Helper for refilemessages() to copy sequences.i    i   N(   s
   fromfolders   getsequencess   fromsequencess   selfs   tosequencess   changeds   itemss   names   seqs   toseqs   news   refileditemss   fromns   tons   appends   putsequences(   s   selfs
   fromfolders   refileditemss   fromsequencess   tosequencess   changeds   names   seqs   toseqs   news   fromns   tons"   /mit/python/lib/python2.0/mhlib.pys   _copysequencess*   	 	 
c 	   s  !#$|  i |  } &t |  } '| i   (~ )| i |  } *| i d |  } +y ,t i | |  Wn -t i j
 o
 .n X/y 0t i | |  Wn 1t i j
 o 3d } 4z0 5| i t  6t i | |  7d } Wd 89| o: :y ;t i |  Wn <t i j
 o
 =n Xn X>t i |  n X?|  i | g  d S(   sa   Move one message over a specific destination message,
        which may or may not already exist.s   ,%di    i   N(   s   selfs   getmessagefilenames   ns   paths   opens   fs   closes   tofolders   tons   topaths   backuptopaths   oss   renames   errors   oks   setlasts   Nones   shutils   copy2s   unlinks   removefromallsequences(	   s   selfs   ns   tofolders   tons   paths   fs   topaths   backuptopaths   oks"   /mit/python/lib/python2.0/mhlib.pys   movemessage!s6   	c 	   s'  ACD|  i |  } Ft |  } G| i   H~ I| i |  } J| i d |  } Ky Lt i | |  Wn Mt i j
 o
 Nn XOd } Pz0 Q| i t  Rt i | |  Sd } Wd TU| o: Vy Wt i |  Wn Xt i j
 o
 Yn Xn Xd S(   sa   Copy one message over a specific destination message,
        which may or may not already exist.s   ,%di    i   N(   s   selfs   getmessagefilenames   ns   paths   opens   fs   closes   tofolders   tons   topaths   backuptopaths   oss   renames   errors   oks   setlasts   Nones   shutils   copy2s   unlink(	   s   selfs   ns   tofolders   tons   paths   fs   topaths   backuptopaths   oks"   /mit/python/lib/python2.0/mhlib.pys   copymessageAs,   	c 	   sF  [\]|  i |  } ^|  i d |  } _y `t i | |  Wn at i j
 o
 bn Xcd } dd d } ezv ft
 | d  } gxD gd o9 h| i |  } i| o jPn k| i |  q Wl| i   md } Wd no| o: py qt i |  Wn rt i j
 o
 sn Xn Xd S(   s3   Create a message, with text from the open file txt.s   ,%di    i   i   s   wi   N(   s   selfs   getmessagefilenames   ns   paths
   backuppaths   oss   renames   errors   oks   BUFSIZEs   opens   fs   txts   reads   bufs   writes   closes   unlink(	   s   selfs   ns   txts   paths
   backuppaths   oks   BUFSIZEs   fs   bufs"   /mit/python/lib/python2.0/mhlib.pys   createmessage[s2   	 
c    s  uwxt  |  d  o |  i | j o y|  ` n z|  i   } {d } |x | i   d |r \ } } }| d j o
 ~q` n xY | d rL } | | j o6 | i |  d } | o | | =n n q Wq` W| o |  i |  n d S(   s`   Remove one or more messages from all sequences (including last)
        -- but not from 'cur'!!!s   lasti    s   curi   N(   s   hasattrs   selfs   lasts   lists   getsequencess	   sequencess   changeds   itemss   names   seqs   ns   removes   putsequences(   s   selfs   lists	   sequencess   changeds   names   seqs   ns"   /mit/python/lib/python2.0/mhlib.pys   removefromallsequencesus$   #	 
 		
c    s;   t  |  d  o |  i   } n |  i Sd S(   s   Return the last message number.s   lastN(   s   hasattrs   selfs   listmessagess   messagess   last(   s   selfs   messagess"   /mit/python/lib/python2.0/mhlib.pys   getlasts   c    sJ   | t j o$ t |  d  o |  `  n n | |  _  d S(   s   Set the last message number.s   lastN(   s   lasts   Nones   hasattrs   self(   s   selfs   lasts"   /mit/python/lib/python2.0/mhlib.pys   setlasts
   (   s   __doc__s   __init__s   __repr__s   errors   getfullnames   getsequencesfilenames   getmessagefilenames   listsubfolderss   listallsubfolderss   listmessagess   getsequencess   putsequencess
   getcurrents
   setcurrents   parsesequences   _parseindexs   openmessages   removemessagess   refilemessagess   _copysequencess   movemessages   copymessages   createmessages   removefromallsequencess   getlasts   setlast(    s"   /mit/python/lib/python2.0/mhlib.pys   Folder s4   	T# s   Messagec      sV   e  d  Z d   Z e  d  Z d d  Z d   Z d   Z RS(   Nc    sk   | |  _ | |  _ | o( | i |  } t | d  } n t	 i
 i |  |  d S(   s   Constructor.s   rN(   s   fs   selfs   folders   ns   numbers   fps   getmessagefilenames   paths   opens	   mimetoolss   Messages   __init__(   s   selfs   fs   ns   fps   paths"   /mit/python/lib/python2.0/mhlib.pys   __init__s   c    s'   d t  |  i  |  i f Sd S(   s   String representation.s   Message(%s, %s)N(   s   reprs   selfs   folders   number(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   __repr__s   c    s   | o t i |  i d  Sn g  } d } x |  i d r } | d t i j oI t i | d  } | d j o  | t i
 | |    } n n | o | i |  n qL Wt i | d  Sd S(   s   Return the message's header text as a string.  If an
        argument is specified, it is used as a filter predicate to
        decide which headers to return (its argument is the header
        name converted to lower case).s    i    s   :N(   s   preds   strings
   joinfieldss   selfs   headerss   hits   lines
   whitespaces   finds   is   lowers   append(   s   selfs   preds   headerss   hits   lines   is"   /mit/python/lib/python2.0/mhlib.pys   getheadertexts   		 	$
 c    s   |  i i |  i  |  i   } | p | d d d d f j o |  i i   Sn d k l } |   } t
 i |  i | |  | i   Sd S(   s   Return the message's body text as string.  This undoes a
        Content-Transfer-Encoding, but does not interpret other MIME
        features (e.g. multipart messages).  To suppress decoding,
        pass 0 as an argument.s    s   7bits   8bits   binary(   s   StringION(   s   selfs   fps   seeks   startofbodys   getencodings   encodings   decodes   reads   StringIOs   outputs	   mimetoolss   getvalue(   s   selfs   decodes   encodings   StringIOs   outputs"   /mit/python/lib/python2.0/mhlib.pys   getbodytexts   $i   c    s  |  i   d j o t d  n |  i d  } | o t d  n |  i i |  i  t i	 |  i  } | i |  g  } xb | i   oQ t |  i  d d t |  } t |  i | |  } | i |  q W| i   | Sd S(   s   Only for multipart messages: return the message's body as a
        list of SubMessage objects.  Each submessage object behaves
        (almost) as a Message object.s	   multiparts   Content-Type is not multipart/*s   boundarys"   multipart/* without boundary params   .i   N(   s   selfs   getmaintypes   Errors   getparams   bdrys   fps   seeks   startofbodys	   multifiles	   MultiFiles   mfs   pushs   partss   nexts   strs   numbers   lens   ns
   SubMessages   folders   parts   appends   pop(   s   selfs   bdrys   mfs   partss   ns   parts"   /mit/python/lib/python2.0/mhlib.pys   getbodypartss"   	 %c    s>   |  i   d j o |  i   Sn |  i   Sd S(   s3   Return body, either a string or a list of messages.s	   multipartN(   s   selfs   getmaintypes   getbodypartss   getbodytext(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getbodys   (   s   Nones   __init__s   __repr__s   getheadertexts   getbodytexts   getbodypartss   getbody(    s"   /mit/python/lib/python2.0/mhlib.pys   Messages   	s
   SubMessagec      sD   d   Z  d   Z d d  Z d   Z d   Z RS(   Nc    s   t  i |  | | |  |  i   d j o t  i |   |  _ n t  i	 |   |  _ t  i	 |  d d |  _
 d S(   s   Constructor.s	   multiparts   decodei    N(   s   Messages   __init__s   selfs   fs   ns   fps   getmaintypes   getbodypartss   bodys   getbodytexts   bodyencoded(   s   selfs   fs   ns   fps"   /mit/python/lib/python2.0/mhlib.pys   __init__s   c    sB   |  i |  i |  i f \ } } } d | | | f Sd S(   s   String representation.s   SubMessage(%s, %s, %s)N(   s   selfs   folders   numbers   fps   fs   n(   s   selfs   fs   ns   fps"   /mit/python/lib/python2.0/mhlib.pys   __repr__s   $c    sM   | o |  i Sn t |  i  t d  j o |  i Sn d  S(   Ns    (   s   decodes   selfs   bodyencodeds   types   body(   s   selfs   decodes"   /mit/python/lib/python2.0/mhlib.pys   getbodytexts   i   c    s4   t  |  i  t  g   j o |  i Sn d  S(   N(   s   types   selfs   body(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getbodypartss   c    s   |  i Sd  S(   N(   s   selfs   body(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   getbodys   (   s   __init__s   __repr__s   getbodytexts   getbodypartss   getbody(    s"   /mit/python/lib/python2.0/mhlib.pys
   SubMessages
   
s   IntSetc      s   d  Z  e d d d  Z d   Z d   Z "d   Z %d   Z )d   Z 4d	   Z =d
   Z	 Dd   Z
 Hd   Z Md   Z Pd   Z Sd   Z Xd   Z qd   Z vd   Z RS(   s  Class implementing sets of integers.

    This is an efficient representation for sets consisting of several
    continuous ranges, e.g. 1-100,200-400,402-1000 is represented
    internally as a list of three pairs: [(1,100), (200,400),
    (402,1000)].  The internal representation is always kept normalized.

    The constructor has up to three arguments:
    - the string used to initialize the set (default ''),
    - the separator between ranges (default ',')
    - the separator between begin and end of a range (default '-')
    The separators must be strings (not regexprs) and should be different.

    The tostring() function yields a string that can be passed to another
    IntSet constructor; __repr__() is a valid IntSet constructor itself.
    c    sI   g  |  _ | |  _ | |  _ | o |  i |  n d  S(   N(   s   selfs   pairss   seps   rngs   datas
   fromstring(   s   selfs   datas   seps   rngs"   /mit/python/lib/python2.0/mhlib.pys   __init__s
   
 s   ,s   -c    s   g  |  _ d  S(   N(   s   selfs   pairs(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   resets   c    s    t  |  i | i  Sd  S(   N(   s   cmps   selfs   pairss   other(   s   selfs   others"   /mit/python/lib/python2.0/mhlib.pys   __cmp__s   c    s   "#t  |  i  Sd  S(   N(   s   hashs   selfs   pairs(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   __hash__"s   c    s*   %&d |  i   |  i |  i f Sd  S(   Ns   IntSet(%s, %s, %s)(   s   selfs   tostrings   seps   rng(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   __repr__%s   c    s   )*|  i i   +d } ,x ,| t |  i  j  o -|  i | d \ } } .|  i | \ } } /| | d j o1 0| t	 | |  f g |  i | d | d +n 2| d } q" Wd  S(   Ni   (
   s   selfs   pairss   sorts   is   lens   alos   ahis   blos   bhis   max(   s   selfs   is   alos   ahis   blos   bhis"   /mit/python/lib/python2.0/mhlib.pys	   normalize)s   	 1c    s   45d } 6x{ |  i d 6rk \ } } 7| | j o 7| } n 8| |  i | } 9| o 9| |  i | } n
 :| } q W;| Sd  S(   Ns    i    (   s   ss   selfs   pairss   los   his   ts   rngs   sep(   s   selfs   ss   los   his   ts"   /mit/python/lib/python2.0/mhlib.pys   tostring4s   	  
 c    s\   =>g  } ?x? |  i d ?r/ \ } } @t | | d  } A| | } q WB| Sd  S(   Ni    i   (   s   ls   selfs   pairss   los   his   ranges   m(   s   selfs   ls   los   his   ms"   /mit/python/lib/python2.0/mhlib.pys   tolist=s   	 c    s0   DEx# | d Er } F|  i |  q Wd  S(   Ni    (   s   lists   is   selfs   append(   s   selfs   lists   is"   /mit/python/lib/python2.0/mhlib.pys   fromlistDs    	c    s*   HIt    } J|  i | _ K| Sd  S(   N(   s   IntSets   news   selfs   pairs(   s   selfs   news"   /mit/python/lib/python2.0/mhlib.pys   cloneHs   c    s   MN|  i d d Sd  S(   Ni    (   s   selfs   pairs(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   minMs   c    s   PQ|  i d d Sd  S(   Ni   (   s   selfs   pairs(   s   selfs"   /mit/python/lib/python2.0/mhlib.pys   maxPs   c    s\   STxH |  i d Tr8 \ } } U| | j o
 | j n o Ud Sn q WVd Sd  S(   Ni    i   (   s   selfs   pairss   los   his   x(   s   selfs   xs   los   his"   /mit/python/lib/python2.0/mhlib.pys   containsSs
    ! c    s  XYx*t  t |  i   d Yr} Z|  i | \ } } [| | j  o \| d | j o ]| | f |  i | <n _|  i i | | | f  `| d j o | d |  i | d d j oB b|  i | d d |  i | d f g |  i | d | d +n fd  Sn g| | j o hd  Sn q Wit |  i  d } j| d j oO k|  i | \ } } l| d | j o! m| | f |  i | <nd  Sn n o|  i i	 | | f  d  S(   Ni    i   (
   s   ranges   lens   selfs   pairss   is   los   his   xs   inserts   append(   s   selfs   xs   is   los   his"   /mit/python/lib/python2.0/mhlib.pys   appendXs&    	0Bc    sH   qr| | j o rd  Sn s|  i i | | f  t|  i   d  S(   N(   s   xlos   xhis   selfs   pairss   appends	   normalize(   s   selfs   xlos   xhis"   /mit/python/lib/python2.0/mhlib.pys   addpairqs    c    sQ  vwd  k  } xg  } yx| i | |  i  d yr } zg  } {xM | i | |  i  d {r1 } || i
 |  } }| i | i |   q` W~t |  d j o" | i | d | d f  nZ t |  d j o | d | d j o" | i | d | d f  n t d  q3 W|  i | |  _ |  i   d  S(   Ni    i   i   s   bad data passed to IntSet(   s   strings   news   splitfieldss   datas   selfs   seps   parts   lists   rngs   subps   strips   ss   appends   atois   lens
   ValueErrors   pairss	   normalize(   s   selfs   datas   strings   news   parts   lists   subps   ss"   /mit/python/lib/python2.0/mhlib.pys
   fromstringvs    	 		 	"+"(   s   __doc__s   Nones   __init__s   resets   __cmp__s   __hash__s   __repr__s	   normalizes   tostrings   tolists   fromlists   clones   mins   maxs   containss   appends   addpairs
   fromstring(    s"   /mit/python/lib/python2.0/mhlib.pys   IntSets"   		c    sI  y t  |  d  } Wn t j
 o t Sn Xt i |  d } t i	 | | o t i  } x d o | i   } | o Pn | i |  o | t |  d } xR d oG | i   } | p | d t i j o Pn | | } q Wt i |  Sn qw Wt Sd  S(   Ns   rs   :i   i    (   s   opens   files   fs   IOErrors   Nones   res   escapes   keys   pats   compiles   casefolds
   IGNORECASEs   progs   readlines   lines   matchs   lens   texts   strings
   whitespaces   strip(   s   files   keys   casefolds   fs   pats   progs   lines   texts"   /mit/python/lib/python2.0/mhlib.pys   picklines*    
  
i   c    s  y2 t  |  d  } | i   } | i   Wn t j
 o g  } n Xt i |  d } t i | | o t i  } | t j o t } n d | | f } x t t |   d rY }	 | |	 }
 | i |
  o3 | t j o | |	 =n | | |	 <Pn q W| t j	 o | i |  n |  d } t  | d  } x# | d r }
 | i |
  qW| i   t i | |   d  S(   Ns   rs   :(.*)
s   %s: %s
i    s   ~s   w(   s   opens   files   fs	   readliness   liness   closes   IOErrors   res   escapes   keys   pats   compiles   casefolds
   IGNORECASEs   progs   values   Nones   newlines   ranges   lens   is   lines   matchs   appends   tempfiles   writes   oss   rename(   s   files   keys   values   casefolds   fs   liness   pats   progs   newlines   is   lines   tempfiles"   /mit/python/lib/python2.0/mhlib.pys
   updatelines8    	 	c  	   s  t  i d  t   a d   }  |  d  |  d  d d d d d	 d
 g } x% | d r } |  d |  qo W|  d  |  d  t i d  a |  d  |  d  |  d  t i	   } t d d  i   | d <| GHt i |  |  d  | i   x% | d r } |  d |  qJW|  d  t i   } t i |  a |  d  x d d d d d d d d d  d! d" d# d$ d% d& d' d( d) d* g d r } y |  d+ |  Wn$ t j
 o } d, G| GHn Xt  i d- |  i   } t t i t i |   } | Gd. GHqW|  d/  d  S(0   Ns   rm -rf $HOME/Mail/@testc    s   |  GHt |   GHd  S(   N(   s   ss   eval(   s   ss"   /mit/python/lib/python2.0/mhlib.pys   dos    s   mh.listfolders()s   mh.listallfolders()s   @tests   @test/test1s   @test/test2s   @test/test1/test11s   @test/test1/test12s   @test/test1/test11/test111i    s   mh.makefolder(%s)s   mh.listsubfolders('@test')s   mh.listallsubfolders('@test')s   f.listsubfolders()s   f.listallsubfolders()s   f.getsequences()s
   1-10 12-20s    s   foos   mh.deletefolder(%s)s   mh.getcontext()s   f.getcurrent()s   firsts   lasts   curs   .s   prevs   nexts   first:3s   last:3s   cur:3s   cur:-3s   prev:3s   next:3s   1:3s   1:-3s   100:3s   100:-3s   10000:3s   10000:-3s   alls   f.parsesequence(%s)s   Error:s   pick %s 2>/dev/nulls   <-- picks   f.listmessages()(   s   oss   systems   MHs   mhs   dos   testfolderss   ts
   openfolders   fs   getsequencess   seqss   IntSets   tolists   putsequencess   reverses
   getcontexts   contexts   seqs   Errors   msgs   popens   reads   stuffs   maps   strings   atois   splits   list(	   s   dos   testfolderss   ts   seqss   contexts   seqs   msgs   stuffs   lists"   /mit/python/lib/python2.0/mhlib.pys   testsN    	  	 E 	s   __main__(   s   __doc__s
   MH_PROFILEs   PATHs   MH_SEQUENCESs   FOLDER_PROTECTs   oss   syss   stats   ST_NLINKs   res   strings	   mimetoolss	   multifiles   shutils   bisects	   Exceptions   Errors   MHs   compiles   numericprogs	   isnumerics   Folders   Messages
   SubMessages   IntSets   picklines
   updatelines   tests   __name__(    s"   /mit/python/lib/python2.0/mhlib.pys   ?6 s6   				 J"+