;ò
›A?c           @   s&  d  Z  d k Z d k Z d k 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 y e e f Wn e j
 o d	 Z d
 Z n Xy d k l Z Wn e j
 o d „  Z n Xd k Z d k l Z l Z d Z d Z  d Z! d Z" e i# d ƒ Z$ e i# d ƒ Z% d „  Z& d „  Z' d „  Z( d „  Z) d „  Z* d „  Z+ e i# d e i, e i- Bƒ Z. d „  Z/ d d d „ Z0 e1 e d „ Z2 e1 d  „ Z3 d! „  Z d" „  Z d# „  Z4 d$ „  Z5 d% „  Z6 e1 e1 d& „ Z7 e i# d' ƒ Z8 d( „  Z9 d S()   s   Miscellaneous utilities.
N(   s   StringIO(   s   ListType(   s   quote(   s   AddressList(   s	   mktime_tz(   s	   parsedate(   s   parsedate_tzi   i    (   s   decodestringc         C   s   d  k  } |  o |  Sn t |  ƒ } t ƒ  } | i | | ƒ | i ƒ  } |  i	 d ƒ o | i	 d ƒ o | d  Sn | Sd  S(   Ns   
iÿÿÿÿ(
   s   quopris   _quopris   ss   StringIOs   infps   outfps   decodes   getvalues   values   endswith(   s   ss   outfps   values   _quopris   infp(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   _qdecode"   s    		!(   s   _bencodes   _qencodes   , s    u    s   
s   [][\\()<>@,:;".]s	   [][\\()"]c         C   s   |  Sd  S(   N(   s   s(   s   s(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys	   _identity@   s    c         C   sT   |  o |  Sn t i |  ƒ } |  i d ƒ o | i d ƒ o | d  Sn | Sd  S(   Ns   
iÿÿÿÿ(   s   ss   base64s   decodestrings   values   endswith(   s   ss   value(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   _bdecodeD   s    !c         C   s2   t  i d t |  ƒ }  t  i d t |  ƒ }  |  Sd S(   s+   Replace all line-ending characters with 
.s	   (?<!\r)\ns   \r(?!\n)N(   s   res   subs   CRLFs   s(   s   s(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   fix_eolsP   s     c         C   se   |  \ } } | oJ d } t i | ƒ o
 d } n t i d | ƒ } d | | | | f Sn | Sd S(   s  The inverse of parseaddr(), this takes a 2-tuple of the form
    (realname, email_address) and returns the string value suitable
    for an RFC 2822 From, To or Cc header.

    If the first element of pair is false, then the second element is
    returned unmodified.
    s    s   "s   \\\g<0>s   %s%s%s <%s>N(   s   pairs   names   addresss   quotess
   specialsres   searchs	   escapesres   sub(   s   pairs   names   quotess   address(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys
   formataddrZ   s     
c         C   s!   t  i d t d ƒ t |  ƒ Sd  S(   Ns$   Use email.Utils.formataddr() insteadi   (   s   warningss   warns   DeprecationWarnings
   formataddrs   pair(   s   pair(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   dump_address_pairl   s    	
c         C   s&   t  i |  ƒ } t | ƒ } | i Sd S(   s7   Return a list of (REALNAME, EMAIL) for each fieldvalue.N(   s
   COMMASPACEs   joins   fieldvaluess   alls   _AddressLists   as   addresslist(   s   fieldvaluess   as   all(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   getaddressess   s     s_  
  =\?                   # literal =?
  (?P<charset>[^?]*?)   # non-greedy up to the next ? is the charset
  \?                    # literal ?
  (?P<encoding>[qb])    # either a "q" or a "b", case insensitive
  \?                    # literal ?
  (?P<atom>.*?)         # non-greedy up to the next ?= is the atom
  \?=                   # literal ?=
  c         C   s§   t  i d t d ƒ d k l } | |  ƒ } t | t ƒ o |  Sn g  } xH | D]@ \ } } | t j o | i | ƒ qR | i t | | ƒ ƒ qR Wt i | ƒ Sd S(   s•   Return a decoded string according to RFC 2047, as a unicode string.

    NOTE: This function is deprecated.  Use Header.decode_header() instead.
    s#   Use Header.decode_header() instead.i   (   s   decode_headerN(   s   warningss   warns   DeprecationWarnings   email.Headers   decode_headers   ss   Ls
   isinstances   ListTypes   rtns   atoms   charsets   Nones   appends   unicodes   UEMPTYSTRINGs   join(   s   ss   atoms   charsets   rtns   Ls   decode_header(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   decode†   s      s
   iso-8859-1s   qc         C   s   t  i d t d ƒ | i ƒ  } | d j o t |  ƒ } n+ | d j o t |  ƒ } n t	 d | ‚ d | i ƒ  | | f Sd S(   s&   Encode a string according to RFC 2047.s#   Use Header.Header.encode() instead.i   s   qs   bs   Illegal encoding code: s   =?%s?%s?%s?=N(   s   warningss   warns   DeprecationWarnings   encodings   lowers   _qencodes   ss   estrs   _bencodes
   ValueErrors   charset(   s   ss   charsets   encodings   estr(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   encode¡   s     c         C   sK  |  t j o t i ƒ  }  n | o t i |  ƒ } t i o | d o t i } n
 t i } t	 t
 | ƒ d ƒ \ } } | d j o
 d } n d } d | | | d f } n t i |  ƒ } d } d	 d
 d d d d d d g | d | d d d d d d d d d d d d d g | d d | d | d  | d! | d" | f Sd# S($   s²  Returns a date string as specified by RFC 2822, e.g.:

    Fri, 09 Nov 2001 01:08:47 -0000

    Optional timeval if given is a floating point time value as accepted by
    gmtime() and localtime(), otherwise the current time is used.

    Optional localtime is a flag that when True, interprets timeval, and
    returns a date relative to the local timezone instead of UTC, properly
    taking daylight savings time into account.
    iÿÿÿÿi  i    s   -s   +s
   %s%02d%02di<   s   -0000s"   %s, %02d %s %04d %02d:%02d:%02d %ss   Mons   Tues   Weds   Thus   Fris   Sats   Suni   i   s   Jans   Febs   Mars   Aprs   Mays   Juns   Juls   Augs   Seps   Octs   Novs   Deci   i   i   i   N(   s   timevals   Nones   times	   localtimes   nows   daylights   altzones   offsets   timezones   divmods   abss   hourss   minutess   signs   zones   gmtime(   s   timevals	   localtimes   zones   signs   hourss   offsets   nows   minutes(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys
   formatdate¯   s      	
c         C   s   t  i  ƒ  } t  i d t  i | ƒ ƒ } t i ƒ  } t i	 d ƒ } |  t j o
 d }  n d |  }  t i ƒ  } d | | | |  | f } | Sd S(   sè   Returns a string suitable for RFC 2822 compliant Message-ID, e.g:

    <20020201195627.33539.96671@nightshade.la.mastaler.com>

    Optional idstring if given is a string used to strengthen the
    uniqueness of the message id.
    s   %Y%m%d%H%M%Si † s    s   .s   <%s.%s.%s%s@%s>N(   s   times   timevals   strftimes   gmtimes   utcdates   oss   getpids   pids   randoms	   randranges   randints   idstrings   Nones   sockets   getfqdns   idhosts   msgid(   s   idstrings   utcdates   randints   msgids   pids   timevals   idhost(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys
   make_msgidÝ   s     

c         C   s   |  o t Sn t |  ƒ Sd  S(   N(   s   datas   Nones
   _parsedate(   s   data(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys	   parsedateö   s    c         C   s   |  o t Sn t |  ƒ Sd  S(   N(   s   datas   Nones   _parsedate_tz(   s   data(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   parsedate_tzü   s    c         C   s1   t  |  ƒ i } | o d d f Sn | d Sd  S(   Ns    i    (   s   _AddressLists   addrs   addresslists   addrs(   s   addrs   addrs(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys	   parseaddr  s    c         C   s•   t  |  ƒ d j oz |  i d ƒ o |  i d ƒ o' |  d d !i d d ƒ i d d ƒ Sn |  i d ƒ o |  i d ƒ o |  d d !Sq n |  Sd	 S(
   s   Remove quotes from a string.i   s   "iÿÿÿÿs   \\s   \s   \"s   <s   >N(   s   lens   strs
   startswiths   endswiths   replace(   s   str(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   unquote
  s      ' c         C   sq   d k  } |  i d d ƒ } t | ƒ d j o t t | i |  ƒ f Sn | \ } } }  | | | i |  ƒ f Sd S(   s#   Decode string according to RFC 2231Ns   'i   i   (	   s   urllibs   ss   splits   partss   lens   Nones   unquotes   charsets   language(   s   ss   languages   charsets   partss   urllib(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   decode_rfc2231  s     	c         C   sl   d k  } | i |  d d ƒ}  | t j o
 | t j o |  Sn | t j o
 d } n d | | |  f Sd S(   sÜ   Encode string according to RFC 2231.

    If neither charset nor language is given, then s is returned as-is.  If
    charset is given but not language, the string is encoded using the empty
    string for language.
    Ns   safes    s   %s'%s'%s(   s   urllibs   quotes   ss   charsets   Nones   language(   s   ss   charsets   languages   urllib(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   encode_rfc2231   s     	
s&   ^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$c         C   s  g  } h  }
 |  d \ } } | i | | f ƒ xµ |  d D]© \ } } t | ƒ } t i | ƒ } | o^ | i
 d d ƒ \ } } | t j	 o t | ƒ } n |
 i | g  ƒ }	 |	 i | | f ƒ q: | i | d t | ƒ f ƒ q: W|
 o™ x– |
 i ƒ  D]„ \ } } g  } | i ƒ  x! | D] \ } } | i | ƒ qWt t i | ƒ ƒ \ } } } | i | | | d t | ƒ f f ƒ qû Wn | Sd S(   s   Decode parameters list according to RFC 2231.

    params is a sequence of 2-tuples containing (content type, string value).
    i    i   s   names   nums   "%s"N(   s
   new_paramss   rfc2231_paramss   paramss   names   values   appends   unquotes   rfc2231_continuations   matchs   mos   groups   nums   Nones   ints
   setdefaults   rfc2231_param1s   quotes   itemss   continuationss   sorts   continuations   decode_rfc2231s   EMPTYSTRINGs   joins   charsets   language(   s   paramss   names   languages
   new_paramss   mos   charsets   values   continuationss   nums   rfc2231_param1s   rfc2231_paramss   continuation(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   decode_params2  s6      ! 
 .(:   s   __doc__s   times   sockets   res   randoms   oss   warningss	   cStringIOs   StringIOs   typess   ListTypes   email._parseaddrs   quotes   AddressLists   _AddressLists	   mktime_tzs	   parsedates
   _parsedates   parsedate_tzs   _parsedate_tzs   Trues   Falses	   NameErrors   quopris   decodestrings   _qdecodes   ImportErrors   base64s   email.Encoderss   _bencodes   _qencodes
   COMMASPACEs   EMPTYSTRINGs   UEMPTYSTRINGs   CRLFs   compiles
   specialsres	   escapesres	   _identitys   _bdecodes   fix_eolss
   formataddrs   dump_address_pairs   getaddressess   VERBOSEs
   IGNORECASEs   ecres   decodes   encodes   Nones
   formatdates
   make_msgids	   parseaddrs   unquotes   decode_rfc2231s   encode_rfc2231s   rfc2231_continuations   decode_params(,   s	   parsedates   unquotes   UEMPTYSTRINGs   _qencodes   randoms   EMPTYSTRINGs   _AddressLists
   formataddrs   decodes
   specialsres   _bdecodes   base64s
   make_msgids   res   parsedate_tzs
   formatdates	   _identitys	   escapesres   rfc2231_continuations   Trues   decode_rfc2231s   _qdecodes   getaddressess   warningss   quotes   encodes   encode_rfc2231s   CRLFs   ListTypes   decode_paramss   dump_address_pairs	   parseaddrs   ecres   Falses   sockets   StringIOs   oss   fix_eolss   _bencodes   times
   _parsedates   _parsedate_tzs	   mktime_tzs
   COMMASPACE(    (    s-   /usr/pkg/lib/mailman/pythonlib/email/Utils.pys   ?   sb   										
				.					
