ó
Xü½cc           @   sª   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 y e
 e f Wn e k
 r‰ d Z
 d Z n Xd	 Z d
 e	 f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   mm_cfg(   t   Utils(   t   _(   t   syslog(   t   GUIBasei   i    t   |t   Topicsc           B   s&   e  Z d  „  Z d d „ Z d „  Z RS(   c         C   s   d t  d ƒ f S(   Nt   topicsR   (   R   (   t   self(    (    s1   /export/web/mailman/mailman/Mailman/Gui/Topics.pyt   GetConfigCategory%   s    c      
   C   s¤   | d k r d  St j } t d ƒ d t j t d ƒ t d ƒ f d t d ƒ t d ƒ f d	 t j d
 d t d ƒ t d ƒ f d t j d d t d ƒ t d ƒ f g S(   NR   s   List topic keywordst   topics_enabledt   Disabledt   Enabledi    s/   Should the topic filter be enabled or disabled?sC  The topic filter categorizes each incoming email message
             according to <a
            href="https://docs.python.org/2/library/re.html">regular
             expression filters</a> you specify below.  If the message's
             <code>Subject:</code> or <code>Keywords:</code> header contains a
             match against a topic filter, the message is logically placed
             into a topic <em>bucket</em>.  Each user can then choose to only
             receive messages from the mailing list for a particular topic
             bucket (or buckets).  Any message not categorized in a topic
             bucket registered with the user is not delivered to the list.

             <p>Note that this feature only works with regular delivery, not
             digest delivery.

             <p>The body of the message can also be optionally scanned for
             <code>Subject:</code> and <code>Keywords:</code> headers, as
             specified by the <a
       href="?VARHELP=topics/topics_bodylines_limit">topics_bodylines_limit</a>
             configuration variable.t   topics_bodylines_limiti   s2   How many body lines should the topic matcher scan?sV  The topic matcher will scan this many lines of the message
             body looking for topic keyword matches.  Body scanning stops when
             either this many lines have been looked at, or a non-header-like
             body line is encountered.  By setting this value to zero, no body
             lines will be scanned (i.e. only the <code>Keywords:</code> and
             <code>Subject:</code> headers will be scanned).  By setting this
             value to a negative number, then all body lines will be scanned
             until a non-header-like line is encountered.
             s<   Topic keywords, one per line, to match against each message.s­  Each topic keyword is actually a regular expression, which is
             matched against certain parts of a mail message, specifically the
             <code>Keywords:</code> and <code>Subject:</code> message headers.
             Note that the first few lines of the body of the message can also
             contain a <code>Keywords:</code> and <code>Subject:</code>
             "header" on which matching is also performed.(   t   NoneR    t   TEXTFIELDWIDTHR   t   Radiot   NumberR   (   R   t   mlistt   categoryt   subcatt   WIDTH(    (    s1   /export/web/mailman/mailman/Mailman/Gui/Topics.pyt   GetConfigInfo(   s     		!					c         C   s¡  | j  d ƒ s d  Sg  } d } xt r'd | } d | }	 d | }
 d | } d | } d | } d	 | } | d 7} | j  | ƒ r q" n  | j |	 ƒ } | j |
 ƒ } | j | ƒ } | d  k rÊ Pn  | j  | ƒ r | sç | r | j t d
 ƒ ƒ q" n  t j | ƒ } y& t j	 | j
 ƒ  ƒ } t j | ƒ Wn? t j t f k
 rvt j | ƒ } | j t d ƒ ƒ q" n X| j  | ƒ r| j | ƒ } | d k rÖ| j d d d t f ƒ | j | | | t f ƒ q$| j | | | t f ƒ | j d d d t f ƒ q" | j | | | t f ƒ q" W| | _ y" t | j d | j ƒ ƒ | _ Wn t k
 rfn Xy" t | j d | j ƒ ƒ | _ Wn t k
 rœn Xd  S(   Nt   topic_box_01i   s   topic_delete_%02ds   topic_box_%02ds   topic_rebox_%02ds   topic_desc_%02ds   topic_where_%02ds   topic_add_%02ds   topic_new_%02dsk   Topic specifications require both a name and
                a pattern.  Incomplete topics will be ignored.sm   The topic pattern '%(safepattern)s' is not a
                legal regular expression.  It will be discarded.t   beforet    R
   R   (   t   has_keyt   Truet   getfirstR   t   addErrorR   R   t   websafet   ORt   joint
   splitlinest   ret   compilet   errort	   TypeErrort   appendt   FalseR   t   intR
   t
   ValueErrorR   (   R   R   R   R   t   cgidatat   docR   t   it   deltagt   boxtagt   reboxtagt   desctagt   wheretagt   addtagt   newtagt   namet   patternt   desct	   orpatternt   safepatternt   where(    (    s1   /export/web/mailman/mailman/Mailman/Gui/Topics.pyt
   handleForm`   sl    	







	
	
			N(   t   __name__t
   __module__R	   R   R   R:   (    (    (    s1   /export/web/mailman/mailman/Mailman/Gui/Topics.pyR   $   s   	8(   R"   t   MailmanR    R   t   Mailman.i18nR   t   Mailman.Logging.SyslogR   t   Mailman.Gui.GUIBaseR   R   R'   t	   NameErrorR   R   (    (    (    s1   /export/web/mailman/mailman/Mailman/Gui/Topics.pyt   <module>   s   
