Viewing File: /usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyc

ó
)¿Úhc@s_dZddlZddlmZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZd	Zejd
ejƒZegejƒjdƒD]Zeeƒ^q܃Zdejjfd
„ƒYZdejjfd„ƒYZdefd„ƒYZdefd„ƒYZdS(s¢Standard Mailman message object.

This is a subclass of email.Message but provides a slightly extended interface
which is more convenient for use inside Mailman.
iÿÿÿÿN(tStringIO(tCharset(tHeader(tListTypet
StringType(tmm_cfg(tUtilss, s([\d.]+)t.t	GeneratorcBs)eZdZeddd„Zd„ZRS(s…Generates output from a Message object tree, keeping signatures.

       Headers will by default _not_ be folded in attachments.
    iNicCs/tjjj||d|d|ƒ||_dS(Ntmangle_from_tmaxheaderlen(temailRt__init__t!_Generator__children_maxheaderlen(tselftoutfpR	R
tchildren_maxheaderlen((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR3s
cCs|j||j|j|jƒS(s7Clone this generator with maxheaderlen set for children(t	__class__t
_mangle_from_R
(Rtfp((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pytclone9s(t__name__t
__module__t__doc__tTrueRR(((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR.stMessagecBs\eZd„Zd„Zd„Zddd„Zddd„Zdd„Ze	e
d„ZRS(	cCs t|_tjjj|ƒdS(N(tVERSIONt__version__RRR(R((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyRAs	cCs
|jƒS(N(t__str__(R((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyt__repr__GscCsA||_|jddƒ}t|d<|tkr5dS|jdƒsPd|_n|jdƒskd|_ng}d}x±|jD]¦\}}t|t	ƒrg}d}xN|j
D]C\}	}
t|
tƒrât|
ƒ}
d}n|j
|	|
fƒq²W|r||_
d}qn|j
||fƒqW|r=||_ndS(NRit_charsett
_default_types
text/plaini(iii(t__dict__tgetRthas_keytNoneRRt_headerst
isinstanceRt_chunksRRtappend(Rtdtversiontheadersthchangedtktvtchunkstcchangedtstcharset((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyt__setstate__Js4	
		icCsøtj}|dk	r|}n|r-d}nd}x®|D]{}||}|sVq:ndj|jƒƒ}tjj|gƒ}y|d\}}	Wntk
rªq:nX|	r:Pq:q:W|j	ƒ}
|
rÞ|
j
ƒd}	nd}	|sô|	jƒS|	S(	sÆReturn the address considered to be the author of the email.

        This can return either the From: header, the Sender: header or the
        envelope header (a.k.a. the unixfrom header).  The first non-empty
        header value found is returned.  However the search order is
        determined by the following:

        - If mm_cfg.USE_ENVELOPE_SENDER is true, then the search order is
          Sender:, From:, unixfrom

        - Otherwise, the search order is From:, Sender:, unixfrom

        The optional argument use_envelope, if given overrides the
        mm_cfg.USE_ENVELOPE_SENDER setting.  It should be set to either 0 or 1
        (don't use None since that indicates no-override).

        unixfrom should never be empty.  The return address is always
        lowercased, unless preserve_case is true.

        This method differs from get_senders() in that it returns one and only
        one address, and uses a different search order.
        tsendertfromtiiN(ssendersfrom(sfromssender(RtUSE_ENVELOPE_SENDERR#tjoint
splitlinesRRtgetaddressest
IndexErrortget_unixfromtsplittlower(Rtuse_envelopet
preserve_casetsenderfirstR*thtfieldvaltaddrstrealnametaddresstunixfrom((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyt
get_senderss2			



cCs2|dkrtj}ng}x½|D]µ}|dkr|jƒpFd}y!|jd|jƒdfƒWqÚtk
r}qÚXq%|j|ƒ}|r%g|D]}dj|j	ƒƒ^q}|j
tjj
|ƒƒq%q%Wg}xG|D]?}	|	d}
|
dk	r|r|
jƒ}
n|j|
ƒqëW|S(sReturn a list of addresses representing the author of the email.

        The list will contain the following addresses (in order)
        depending on availability:

        1. From:
        2. unixfrom
        3. Reply-To:
        4. Sender:

        The return addresses are always lower cased, unless `preserve_case' is
        true.  Optional `headers' gives an alternative search order, with None
        meaning, search the unixfrom header.  Items in `headers' are field
        names without the trailing colon.
        R5iN(R#RtSENDER_HEADERSR;R'R<R:tget_allR7R8textendRRR9R=(RR?R*tpairsRARBt	fieldvalstfvtauthorstpairRE((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pytget_senders³s,
!
% 

cCsBy tjjj||ƒ}|SWntttfk
r=|SXdS(sSome MUA have bugs in RFC2231 filename encoding and cause
        Mailman to stop delivery in Scrubber.py (called from ToDigest.py).
        N(RRtget_filenametUnicodeErrortLookupErrort
ValueError(Rtfailobjtfilename((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyRQßs
cCs8tƒ}t|d|ƒ}|j|d|ƒ|jƒS(sùReturn entire formatted message as a string using
        Mailman.Message.Generator.

        Operates like email.Message.Message.as_string, only
        using Mailman's Message.Generator class. Only the top headers will
        get folded.
        R	RF(RRtflattentgetvalue(RRFR	Rtg((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyt	as_stringês	N(RRRRR2R#RGRPRQtFalseRRZ(((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR@s			)@,tUserNotificationcBs5eZdZdddd„Zed„Zd„ZRS(s&Class for internally crafted messages.cCsÜtj|ƒd}|dk	r7ttj|ƒƒ}n|dk	rV|j||ƒn|dkrkd}nt||ddddƒ|d<||d<t|t	ƒrÂt
j|ƒ|d<||_n||d<|g|_dS(Ns(no subject)theader_nametSubjectterrorstreplacetFromtTo(
RRR#RRt
GetCharSettset_payloadRR%Rt
COMMASPACER7trecips(RtrecipR3tsubjectttexttlangR1((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyRüs 
	


cKs®|jdƒs%tj|ƒ|d<n|jdƒsPtjjddƒ|d<n|jdƒpb|sš|jdƒ|jƒkrd	|d
<qšd|d
<n|j||dS(
s|Sends the message by enqueuing it to the `virgin' queue.

        This is used for all internally crafted messages.
        s
message-ids
Message-IDtdatet	localtimeitDatet
precedencettotlistt
PrecedencetbulkN(R"Rtunique_message_idRt
formatdateR!t
GetOwnerEmailt_enqueue(Rtmlisttnoprecedencet_kws((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pytsends

cKsTddlm}|tjƒ}|j|d|jƒd|jdddd|dS(Niÿÿÿÿ(tget_switchboardtlistnameRft
nodecorateitreduced_list_headers(tMailman.Queue.sbcacheR{RtVIRGINQUEUE_DIRtenqueuet
internal_nameRf(RRwRyR{tvirginq((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyRv(s	N(RRRR#RR[RzRv(((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR\ùstOwnerNotificationcBs)eZdZdddd„Zd„ZRS(sBLike user notifications, but this message goes to the list owners.icCs‹|j}|r#|j|jƒntj|jdƒ}|j}tj||||||ƒ|d=|j	ƒ|d<||_
d|d<dS(NtbouncesRoRbRpRq(townerRJt	moderatorRtget_site_emailt	host_nametpreferred_languageR\RRut_sender(RRwRhRittomoderatorsRfR3Rj((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR9s
		c
Ks]ddlm}|tjƒ}|j|d|jƒd|jddddd|j|dS(	Niÿÿÿÿ(R{R|RfR}iR~t	envsender(RR{RR€RR‚RfR‹(RRwRyR{Rƒ((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyRvMs	N(RRRR#RRv(((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyR„6s( Rtret	cStringIORRtemail.Generatort
email.Messagetemail.Utilst
email.CharsetRtemail.HeaderRttypesRRtMailmanRRRetmatchRtmottupletgroupR<R0tintRRRR\R„(((s5/usr/local/cpanel/3rdparty/mailman/Mailman/Message.pyt<module>s$4¹=
Back to Directory File Manager