;ò
¢)?Bc           @   s¿   d  Z  d k Z d k Z d k Z d k l Z d k l Z d k l	 Z	 d k l
 Z
 d k l Z d k l Z d k l Z d	 k l Z e i d
 e i e i Bƒ Z d e f d „  ƒ  YZ d S(   s®  Maildir pre-queue runner.

Most MTAs can be configured to deliver messages to a `Maildir'[1].  This
runner will read messages from a maildir's new/ directory and inject them into
Mailman's qfiles/in directory for processing in the normal pipeline.  This
delivery mechanism contrasts with mail program delivery, where incoming
messages end up in qfiles/in via the MTA executing the scripts/post script
(and likewise for the other -aliases for each mailing list).

The advantage to Maildir delivery is that it is more efficient; there's no
need to fork an intervening program just to take the message from the MTA's
standard output, to the qfiles/in directory.

[1] http://cr.yp.to/proto/maildir.html

We're going to use the :info flag == 1, experimental status flag for our own
purposes.  The :1 can be followed by one of these letters:

- P means that MaildirRunner's in the process of parsing and enqueuing the
  message.  If successful, it will delete the file.

- X means something failed during the parse/enqueue phase.  An error message
  will be logged to log/error and the file will be renamed <filename>:1,X.
  MaildirRunner will never automatically return to this file, but once the
  problem is fixed, you can manually move the file back to the new/ directory
  and MaildirRunner will attempt to re-process it.  At some point we may do
  this automatically.

See the variable USE_MAILDIR in Defaults.py.in for enabling this delivery
mechanism.
N(   s   Parser(   s	   parseaddr(   s   mm_cfg(   s   Utils(   s   Message(   s   Runner(   s   get_switchboard(   s   syslogs  
 ^                        # start of string
 (?P<listname>[^-@]+)     # listname@ or listname-subq@
 (?:                      # non-grouping
   -                      # dash separator
   (?P<subq>[^-+@]+)      # everything up to + or - or @
 )?                       # if it exists
 s   MaildirRunnerc           B   s)   t  Z e d d „ Z d „  Z d „  Z RS(   Ni   c         C   sR   d |  _ t i i t i d ƒ |  _ t i i t i d ƒ |  _ t	 t
 ƒ |  _ d  S(   Ni    s   news   cur(   s   selfs   _stops   oss   paths   joins   mm_cfgs   MAILDIR_DIRs   _dirs   _curs   Parsers   Messages   _parser(   s   selfs   slices	   numslices(    (    s+   /var/mailman/Mailman/Queue/MaildirRunner.pys   __init__T   s    	c         C   s  t  i ƒ  } y t i |  i ƒ } Wn3 t j
 o' } | i
 t
 i j o ‚  n d Sn Xx¤| D]œ} t i i |  i | ƒ } t i i |  i | d ƒ } t i i |  i | d ƒ } y t i | | ƒ WnB t j
 o6 } | i
 t
 i j o q_ n t d d | ƒ ‚  n Xy²t | ƒ } z |  i i | ƒ } Wd  | i ƒ  Xg  } x0 d d d f D] } | i | i | g  ƒ ƒ qWWx˜ | D]m }	 t  |	 ƒ d	 }
 |
 o qn t" i# |
 ƒ } | o qn | i% d
 d ƒ \ } } | | j o PqqWt d d | ƒ t i | | ƒ w_ h  d
 | <} | d d f j o t) t* i+ ƒ } nY| d j o d	 | d <t) t* i- ƒ } n/| d d f j o d	 | d <t) t* i- ƒ } nÿ | d d f j o d	 | d <t) t* i- ƒ } nÏ | d j oJ | i. h  d d	 <d t  i/ d d ƒ <d t* i0 <ƒ t) t* i1 ƒ } nx | t2 j o d	 | d <t) t* i1 ƒ } nN | d j o d	 | d <t) t* i- ƒ } n$ t d d | ƒ t i | | ƒ w_ | i3 | | ƒ t i4 | ƒ Wq_ t5 j
 o, } t i | | ƒ t d t6 | ƒ ƒ q_ Xq_ Wd  S(    Ni    s   :1,Ps   :1,Xs   errors!   Could not rename maildir file: %ss   delivered-tos   envelope-tos   apparently-toi   s   listnames   subqs'   Message apparently not for any list: %ss   bouncess   admins   confirms	   toconfirms   joins	   subscribes   tojoins   leaves   unsubscribes   toleaves   owners   toowners	   envsenders   extras   pipelines   tolists   requests	   torequests   Unknown sub-queue: %s(7   s   Utilss
   list_namess	   listnamess   oss   listdirs   selfs   _dirs   filess   OSErrors   es   errnos   ENOENTs   files   paths   joins   srcnames   _curs   dstnames   xdstnames   renames   syslogs   opens   fps   _parsers   parses   msgs   closes   valss   headers   extends   get_alls   fields	   parseaddrs   tos   lres   matchs   mos   groups   listnames   subqs   msgdatas   get_switchboards   mm_cfgs   BOUNCEQUEUE_DIRs   queues   CMDQUEUE_DIRs   updates   get_site_emails   OWNER_PIPELINEs   INQUEUE_DIRs   Nones   enqueues   unlinks	   Exceptions   str(   s   selfs	   listnamess   subqs   headers   fps   files   listnames   xdstnames   queues   fields   tos   msgs   filess   dstnames   valss   es   mos   msgdatas   srcname(    (    s+   /var/mailman/Mailman/Queue/MaildirRunner.pys   _oneloop\   s’     	    		


7

c         C   s   d  S(   N(    (   s   self(    (    s+   /var/mailman/Mailman/Queue/MaildirRunner.pys   _cleanup·   s    (   s   __name__s
   __module__s   Nones   __init__s   _oneloops   _cleanup(    (    (    s+   /var/mailman/Mailman/Queue/MaildirRunner.pys   MaildirRunnerN   s   	[(   s   __doc__s   oss   res   errnos   email.Parsers   Parsers   email.Utilss	   parseaddrs   Mailmans   mm_cfgs   Utilss   Mailman.Messages   Messages   Mailman.Queue.Runners   Runners   Mailman.Queue.sbcaches   get_switchboards   Mailman.Logging.Syslogs   syslogs   compiles   VERBOSEs
   IGNORECASEs   lres   MaildirRunner(   s	   parseaddrs   lres   get_switchboards   syslogs   Runners   errnos   Utilss   Parsers   res   mm_cfgs   Messages   oss   MaildirRunner(    (    s+   /var/mailman/Mailman/Queue/MaildirRunner.pys   ?/   s   			