-í
�H ?c       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 l Z T d d	 d
 d g 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   MHs   Errors   Folders   Messagec      s   X Y RS(   N(    (    (    (    s"   /mit/python/lib/python2.2/mhlib.pys   ErrorX s   c      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   profile(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/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   args(    (    s"   /mit/python/lib/python2.2/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   key(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/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   context(    (    s"   /mit/python/lib/python2.2/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   fs   fn(    (    s"   /mit/python/lib/python2.2/mhlib.pys
   setcontext† s
   c    s˜   � Ž � g  } � |  i ƒ  } ‘ x\ t i | ƒ D‘ ]H } ’ t i i | | ƒ } “ t i i	 | ƒ o ” | i
 | ƒ n q1 W• | i ƒ  – | Sd S(   s*   Return the names of the top-level folders.N(   s   folderss   selfs   getpaths   paths   oss   listdirs   names   joins   fullnames   isdirs   appends   sort(   s   selfs   folderss   names   paths   fullname(    (    s"   /mit/python/lib/python2.2/mhlib.pys   listfolders� s   	 	c 
   s$  ˜ š › t  i i |  i | ƒ } ž t  i | ƒ } Ÿ | t }   | d j o ¡ g  Sn ¢ g  } £ t  i | ƒ } ¤ x� | D¤ ]… } ¥ 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   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   subnamess   fullsubnames   sts
   subfolderss   subnames   nlinkss   fullnames   name_subname(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   listallfolders± s   c    s‰  µ ¶ · t  i i |  i | ƒ } º t  i | ƒ } » | t } ¼ | d j o ½ g  Sn ¾ g  } ¿ t  i | ƒ } À xõ | DÀ ]ê } Á | 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   subnamess   fullsubnames   sts
   subfolderss   subnames   nlinkss   fullnames   name_subnames   subsubfolders(    (    s"   /mit/python/lib/python2.2/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   name(    (    s"   /mit/python/lib/python2.2/mhlib.pys
   openfolderÒ s   c    s}   Ö × Ø t  |  i d ƒ } Ù | o
 t | ƒ o Ú t | 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   ints   modes   FOLDER_PROTECTs   oss   mkdirs   paths   joins   getpaths   name(   s   selfs   names   protects   mode(    (    s"   /mit/python/lib/python2.2/mhlib.pys
   makefolderÖ s   	c    s·   ß á â t  i i |  i ƒ  | ƒ } ã xy t  i | ƒ Dã ]e } ä t  i i | | ƒ } å y æ t  i
 | ƒ Wn- ç t  i j
 o è |  i d | ƒ n Xq7 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.s   %s not deleted, continuing...N(   s   oss   paths   joins   selfs   getpaths   names   fullnames   listdirs   subnames   fullsubnames   unlinks   errors   rmdir(   s   selfs   names   subnames   fullsubnames   fullname(    (    s"   /mit/python/lib/python2.2/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.2/mhlib.pys   MH\ s   		s   ^[1-9][0-9]*$c    s   î ï t  i |  ƒ t j	 Sd  S(   N(   s   numericprogs   matchs   strs   None(   s   str(    (    s"   /mit/python/lib/python2.2/mhlib.pys	   isnumericî s   c      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   name(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __repr__û s   c    s    ÿ  t  |  i i | ƒ d S(   s   Error message handler.N(   s   applys   selfs   mhs   errors   args(   s   selfs   args(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/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   n(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getmessagefilenames   c    s    |  i i |  i ƒ Sd S(   s!   Return list of direct subfolders.N(   s   selfs   mhs   listsubfolderss   name(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   listsubfolderss   c    s    |  i i |  i ƒ Sd S(   s   Return list of all subfolders.N(   s   selfs   mhs   listallsubfolderss   name(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   listallsubfolderss   c    sÂ   g  } t i } | i } xA t i |  i ƒ  ƒ D]' } | | ƒ o | | ƒ n q@ W t	 t
 | ƒ } !| 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   ints   sorts   last(   s   selfs   matchs   messagess   appends   name(    (    s"   /mit/python/lib/python2.2/mhlib.pys   listmessagess   	 	
c    s'  ()*h  } +|  i ƒ  } ,y -t | d ƒ } Wn .t j
 o /| Sn X0x¿ 0d o´ 1| i ƒ  } 2| o 2Pn 3| i	 d ƒ } 4t | ƒ d j o$ 5|  i d | | i ƒ  f ƒ n 7| d i ƒ  } 8t | d i ƒ  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   splits   fieldss   lens   errors   strips   keys   IntSets   tolists   value(   s   selfs   fs   fieldss   values   keys	   sequencess   lines   fullname(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getsequences(s&   	 
 $"c    sø   <=>|  i ƒ  } ?t } @x~ | i ƒ  D@]m } At d d ƒ } B| i
 | | ƒ C| o Ct | d ƒ } n D| i d | | i ƒ  f ƒ q. 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.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   keys   fs   ss   fullname(    (    s"   /mit/python/lib/python2.2/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   seqs(    (    s"   /mit/python/lib/python2.2/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   n(    (    s"   /mit/python/lib/python2.2/mhlib.pys
   setcurrentUs   c    sc  Y]b|  i ƒ  }
 d|
 o et d |  i ‚ n g| d j o h|
 Sn j| i d ƒ } k| d j oN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 | ƒ } 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 �| 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   finds   is   heads   dirs   tails	   isnumerics   ints   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   heads   begins   seqss   ns   msgs   counts   ends   msgss   alls   is   js   tails   rs   anchors   dir(    (    s"   /mit/python/lib/python2.2/mhlib.pys   parsesequenceYs~   '!c    sÌ  ­®¯t  | ƒ oA °y ±t | ƒ 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   previ   s   no prev messageN(   s	   isnumerics   seqs   ints   OverflowErrors
   ValueErrors   syss   maxints   selfs
   getcurrents   alls   ns   bisects   is
   IndexErrors   Errors   None(   s   selfs   seqs   alls   ns   i(    (    s"   /mit/python/lib/python2.2/mhlib.pys   _parseindex­s:   c    s   ÌÍÎt  |  | ƒ Sd S(   s+   Open a message -- returns a Message object.N(   s   Messages   selfs   n(   s   selfs   n(    (    s"   /mit/python/lib/python2.2/mhlib.pys   openmessageÌs   c    s]  ÐÑÒg  } Óg  } ÔxÍ | DÔ]Â } Õ|  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.s   ,i   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	   commapaths   deleteds   ns   msgs   path(    (    s"   /mit/python/lib/python2.2/mhlib.pys   removemessagesÐs,   		
 	

i    c    sò  éëìg  } íh  } îx5| Dî]*} ï| 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   topaths   errorss   refileds   ns   tons   msgs   path(    (    s"   /mit/python/lib/python2.2/mhlib.pys   refilemessagesés>   		
 	


c    s&  | i ƒ  } |  i ƒ  } d } xÑ | i ƒ  D]À \ } } y | | } d }
 Wn( t j
 o g  } d }
 n XxD | D]9 \ } }	 | | 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   KeyErrors   refileditemss   fromns   tons   appends   putsequences(   s   selfs
   fromfolders   refileditemss   fromns   toseqs   seqs   changeds   names   fromsequencess   tons   news   tosequences(    (    s"   /mit/python/lib/python2.2/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   topaths   oks   fs   backuptopaths   path(    (    s"   /mit/python/lib/python2.2/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   topaths   oks   fs   backuptopaths   path(    (    s"   /mit/python/lib/python2.2/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   oks   fs   bufs
   backuppaths   paths   BUFSIZE(    (    s"   /mit/python/lib/python2.2/mhlib.pys   createmessage[s2   	 
c    s
  uwxt  |  d ƒ o |  i | j o y|  ` n z|  i ƒ  } {d } |x” | i ƒ  D|]ƒ \ } } }| d j o
 ~q^ n xW | D]L } €| | 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   names   seqs	   sequencess   changeds   n(    (    s"   /mit/python/lib/python2.2/mhlib.pys   removefromallsequencesus$   #	 

 		
c    s9   ˆ‰Št  |  d ƒ o ‹|  i ƒ  n Œ|  i Sd S(   s   Return the last message number.s   lastN(   s   hasattrs   selfs   listmessagess   last(   s   self(    (    s"   /mit/python/lib/python2.2/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   last(    (    s"   /mit/python/lib/python2.2/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.2/mhlib.pys   Folderñ s4   	T# c      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   path(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __repr__¡s   c    sÞ   ¥©ª| o «d i |  i ƒ Sn ¬g  } ­d } ®xŠ |  i D®]| } ¯| d i ƒ  oC °| i d ƒ } ±| d j o ²| | |  i	 ƒ  ƒ } n n ³| o ³| i
 | ƒ n qG W´d i | ƒ 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   joins   selfs   headerss   hits   lines   isspaces   finds   is   lowers   append(   s   selfs   preds   headerss   hits   is   line(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getheadertext¥s   		 	!
 i   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   StringIOs   outputs   encoding(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getbodytext¶s   $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   part(    (    s"   /mit/python/lib/python2.2/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   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getbodyØs   (   s   Nones   __init__s   __repr__s   getheadertexts   getbodytexts   getbodypartss   getbody(    (    (    s"   /mit/python/lib/python2.2/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   fp(    (    s"   /mit/python/lib/python2.2/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   fps   ns   f(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __repr__ìs   $i   c    sM   ñò| o ó|  i Sn ôt |  i ƒ t d ƒ j o õ|  i Sn d  S(   Ns    (   s   decodes   selfs   bodyencodeds   types   body(   s   selfs   decode(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getbodytextñs   c    s4   ÷øt  |  i ƒ t  g  ƒ j o ù|  i Sn d  S(   N(   s   types   selfs   body(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getbodyparts÷s   c    s   ûü|  i Sd  S(   N(   s   selfs   body(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   getbodyûs   (   s   __init__s   __repr__s   getbodytexts   getbodypartss   getbody(    (    (    s"   /mit/python/lib/python2.2/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.
    s   ,s   -c    sI   g  |  _ | |  _ | |  _ | o |  i | ƒ n d  S(   N(   s   selfs   pairss   seps   rngs   datas
   fromstring(   s   selfs   datas   seps   rng(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __init__s
   
 c    s   g  |  _ d  S(   N(   s   selfs   pairs(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   resets   c    s    t  |  i | i ƒ Sd  S(   N(   s   cmps   selfs   pairss   other(   s   selfs   other(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __cmp__s   c    s   "#t  |  i ƒ Sd  S(   N(   s   hashs   selfs   pairs(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   __hash__"s   c    s*   %&d |  i ƒ  |  i |  i f Sd  S(   Ns   IntSet(%s, %s, %s)(   s   selfs   tostrings   seps   rng(   s   self(    (    s"   /mit/python/lib/python2.2/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   bhis   alos   blos   is   ahi(    (    s"   /mit/python/lib/python2.2/mhlib.pys	   normalize)s   	 1c    s–   45d } 6xy |  i D6]k \ } } 7| | j o 7| } n 8| |  i | } 9| o 9| |  i | } n
 :| } q W;| Sd  S(   Ns    (   s   ss   selfs   pairss   los   his   ts   rngs   sep(   s   selfs   los   his   ss   t(    (    s"   /mit/python/lib/python2.2/mhlib.pys   tostring4s   	  
 c    sZ   =>g  } ?x= |  i D?]/ \ } } @t | | d ƒ } A| | } q WB| Sd  S(   Ni   (   s   ls   selfs   pairss   los   his   ranges   m(   s   selfs   his   los   ms   l(    (    s"   /mit/python/lib/python2.2/mhlib.pys   tolist=s   	 c    s.   DEx! | DE] } F|  i | ƒ q Wd  S(   N(   s   lists   is   selfs   append(   s   selfs   lists   i(    (    s"   /mit/python/lib/python2.2/mhlib.pys   fromlistDs   
 	c    s*   HIt  ƒ  } J|  i | _ K| Sd  S(   N(   s   IntSets   news   selfs   pairs(   s   selfs   new(    (    s"   /mit/python/lib/python2.2/mhlib.pys   cloneHs   c    s   MN|  i d d Sd  S(   Ni    (   s   selfs   pairs(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   minMs   c    s   PQ|  i d d Sd  S(   Niÿÿÿÿ(   s   selfs   pairs(   s   self(    (    s"   /mit/python/lib/python2.2/mhlib.pys   maxPs   c    sZ   STxF |  i DT]8 \ } } 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   his   lo(    (    s"   /mit/python/lib/python2.2/mhlib.pys   containsSs
    ! c    sÃ  XYx(t  t |  i ƒ ƒ DY]} 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   his   los   i(    (    s"   /mit/python/lib/python2.2/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   xhi(    (    s"   /mit/python/lib/python2.2/mhlib.pys   addpairqs    c    s5  vwg  } xxÿ | i |  i ƒ Dx]è } yg  } zxB | i |  i ƒ Dz]+ } {| i	 ƒ  } || i t | ƒ ƒ qJ 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 ‚ q" Wƒ|  i | |  _ „|  i ƒ  d  S(   Ni   i    i   s   bad data passed to IntSet(   s   news   datas   splits   selfs   seps   parts   lists   rngs   subps   strips   ss   appends   ints   lens
   ValueErrors   pairss	   normalize(   s   selfs   datas   lists   ss   parts   subps   new(    (    s"   /mit/python/lib/python2.2/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.2/mhlib.pys   IntSetÿs"   		i   c    sD  ‰Š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 } •xP •d oE –| i ƒ  } —| p | d i ƒ  o ˜Pn ™| | } qÓ Wš| 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   isspaces   strip(   s   files   keys   casefolds   pats   fs   texts   progs   line(    (    s"   /mit/python/lib/python2.2/mhlib.pys   pickline‰s*    
  
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ª]Y } «| | } ¬|
 i | ƒ o3 ­| t j o ®| | =n °| | | <±Pn qÕ W³| t j	 o ´| i | ƒ n µ|  d }	 ¶t  |	 d ƒ } ·x! | D·] } ¸| i | ƒ q‚W¹| i ƒ  ºt i |	 |  ƒ d  S(   Ns   rs   :(.*)
s   %s: %s
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   pats   fs   is   newlines   liness   tempfiles   progs   line(    (    s"   /mit/python/lib/python2.2/mhlib.pys
   updateline�s8    	
 	c  	   s‚  ¿ÀÁt  i d ƒ Ât ƒ  a Ãd „  }  Ä|  d ƒ Å|  d ƒ Æd d d d d	 d
 g } Éx# | DÉ] } É|  d | ƒ qm WÊ|  d ƒ Ë|  d ƒ Ìt i d ƒ a Í|  d ƒ Î|  d ƒ Ï|  d ƒ Ðt i	 ƒ  } Ñt d d ƒ i ƒ  | d <Ò| GHÓt i | ƒ Ô|  d ƒ Õ| i ƒ  Öx# | DÖ] } Ö|  d | ƒ qF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Û]‡ } ày á|  d* | ƒ Wn$ ât j
 o } ãd+ G| GHn Xät  i d, | ƒ i ƒ  } åt t | i ƒ  ƒ } æ| Gd- GHqãWç|  d. ƒ d  S(/   Ns   rm -rf $HOME/Mail/@testc    s   ÃÃ|  GHt |  ƒ GHd  S(   N(   s   ss   eval(   s   s(    (    s"   /mit/python/lib/python2.2/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/test111s   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   ints   splits   list(	   s   dos   seqs   testfolderss   lists   msgs   stuffs   ts   contexts   seqs(    (    s"   /mit/python/lib/python2.2/mhlib.pys   test¿sN   
 	 
 	 C 	s   __main__(   s   __doc__s
   MH_PROFILEs   PATHs   MH_SEQUENCESs   FOLDER_PROTECTs   oss   syss   stats   ST_NLINKs   res	   mimetoolss	   multifiles   shutils   bisects   __all__s	   Exceptions   Errors   MHs   compiles   numericprogs	   isnumerics   Folders   Messages
   SubMessages   IntSets   picklines
   updatelines   tests   __name__(   s	   mimetoolss   picklines   IntSets   FOLDER_PROTECTs   syss	   isnumerics
   MH_PROFILEs   numericprogs   Errors   MH_SEQUENCESs   PATHs   Folders   shutils
   updatelines   ST_NLINKs   __all__s   bisects   tests   MHs   res	   multifiles
   SubMessages   Messages   os(    (    s"   /mit/python/lib/python2.2/mhlib.pys   ?6 s6   				‘ÿ ¦JŠ"+