-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /usr/lib/python2.7/dist-packages/bzrlib/
File Upload :
Current File : //usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyc

ó
¯˜)Oc@@s
ddlmZddlZddlZddlZddlZddlZddlZddlmZ	m
Z
mZmZm
Z
mZmZejƒZdefd„ƒYZdefd„ƒYZejded	ejƒd
efd„ƒYZdefd
„ƒYZdefd„ƒYZejded	ejƒdefd„ƒYZejded	ejƒdefd„ƒYZejded	ejƒdefd„ƒYZejded	ejƒdefd„ƒYZejded	ejƒdefd„ƒYZejded	ejƒd efd!„ƒYZejd"ed	ejƒd#efd$„ƒYZ ejd%e d	e jƒd&efd'„ƒYZ!ejd(e!d	e!jƒd)efd*„ƒYZ"ejd+e"d	e"jƒd+e_#e	j$d,ed	d-d.d/ƒZ%dS(0i(tabsolute_importN(tconfigt
email_messageterrorst	msgeditortosutilsturlutilstregistryt
MailClientcB@s>eZdZd„Zddd„Zddd„Zd„ZRS(s7A mail client that can send messages with attachements.cC@s
||_dS(N(R(tselfR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt__init__*sc		C@s
t‚dS(sCompose (and possibly send) an email message

        Must be implemented by subclasses.

        :param prompt: A message to tell the user what to do.  Supported by
            the Editor client, but ignored by others
        :param to: The address to send the message to
        :param subject: The contents of the subject line
        :param attachment: An email attachment, as a bytestring
        :param mime_subtype: The attachment is assumed to be a subtype of
            Text.  This allows the precise subtype to be specified, e.g.
            "plain", "x-patch", etc.
        :param extension: The file extension associated with the attachment
            type, e.g. ".patch"
        :param basename: The name to use for the attachment, e.g.
            "send-nick-3252"
        N(tNotImplementedError(	R	tpromptttotsubjectt
attachmenttmime_subtypet	extensiontbasenametbody((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pytcompose-sc	C@s>|jd|||ƒ}|j||||dd||ƒdS(ssCompose (and possibly send) a merge request

        :param to: The address to send the request to
        :param subject: The subject line to use for the request
        :param directive: A merge directive representing the merge request, as
            a bytestring.
        :param basename: The name to use for the attachment, e.g.
            "send-nick-3252"
        sPlease describe these changes:sx-patchs.patchN(t_get_merge_promptR(R	R
Rt	directiveRRR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pytcompose_merge_requestBscC@sdS(s"Generate a prompt string.  Overridden by Editor.

        :param prompt: A string suggesting what user should do
        :param to: The address the mail will be sent to
        :param subject: The subject line of the mail
        :param attachment: The attachment that will be used
        t((R	RR
RR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRRsN(t__name__t
__module__t__doc__R
tNoneRRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR's	tEditorcB@s,eZdZeZd„Zddd„ZRS(s/DIY mail client that uses commit message editorcC@s d||||jddƒfS(s See MailClient._get_merge_promptu%s

To: %s
Subject: %s

%ssutf-8treplace(tdecode(R	RR
RR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRbs	c			C@s}|stjƒ‚ntj|d|ƒ}|dkrEtjƒ‚ntjj|j|jj	dƒ||||d|ƒdS(sSee MailClient.composet
start_messageRtemailtattachment_mime_subtypeN(
RtNoMailAddressSpecifiedRtedit_commit_messagetNoMessageSuppliedRtEmailMessagetsendRtget(	R	RR
RRRRRR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRjsN(RRRtTruet
supports_bodyRRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR]s		teditorthelptBodyExternalMailClientcB@sPeZeZd„Zddd„Zddd„Zd„Zd„Z	d„Z
RS(cC@sItjdkr>ddl}g|jD]}|j|ƒ^q%S|jSdS(s:Provide a list of commands that may invoke the mail clienttwin32iN(tsystplatformt
win32utilst_client_commandstget_app_path(R	R1ti((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt_get_client_commandss#c	
C@s°|dkrd}ntjddƒ}	tj|	||ƒ}
t|
dƒ}z|j|ƒWd|jƒX|dk	r‡i|d6}ni}|j||||
|||dS(sfSee MailClient.compose.

        Writes the attachment to a temporary file, invokes _compose.
        Rtprefixs	bzr-mail-twbNR(RRtmkdtemptpathjointopentwritetcloset_compose(
R	RR
RRRRRRtpathnametattach_pathtoutfiletkwargs((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR‰s	c	
C@sÜxÕ|jƒD]µ}	|j|	dƒg}
|dk	rDi|d6}ni}|dk	rc||d<n|
j|j||||ƒytj|
ƒWn+tk
rÀ}|jtj	kr‚qÂq
XPq
Wt
j|jƒ‚dS(sMInvoke a mail client as a commandline process.

        Overridden by MAPIClient.
        :param to: The address to send the mail to
        :param subject: The subject line for the mail
        :param pathname: The path to the attachment
        :param mime_subtype: The attachment is assumed to have a major type of
            "text", but the precise subtype can be specified here
        :param extension: A file extension (including period) associated with
            the attachment type.
        :param body: Optional body text.
        :param from_: Optional From: header.
        t
executableRtfrom_N(
R5t_encode_pathRtextendt_get_compose_commandlinet
subprocesstcalltOSErrorterrnotENOENTRtMailClientNotFoundR2(
R	RR
RR?RRRRCtnametcmdlineRAte((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR=Ÿs"


cC@s
t‚dS(sDetermine the commandline to use for composing a message

        Implemented by various subclasses
        :param to: The address to send the mail to
        :param subject: The subject line for the mail
        :param attach_path: The path to the attachment
        N(R(R	R
RR?R((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFÃscC@s)t|tƒr%|jtjƒdƒS|S(s
Encode possible unicode string argument to 8-bit string
        in user_encoding. Unencodable characters will be replaced
        with '?'.

        :param  u:  possible unicode string.
        :return:    encoded string if u is unicode, u itself otherwise.
        R(t
isinstancetunicodetencodeRtget_user_encoding(R	tu((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt_encode_safeÍscC@sSt|tƒrOy|jtjƒƒSWqOtk
rKtj||ƒ‚qOXn|S(s2Encode unicode path in user encoding.

        :param  path:   possible unicode path.
        :param  kind:   path kind ('executable' or 'attachment').
        :return:        encoded path if path is unicode,
                        path itself otherwise.
        :raise:         UnableEncodePath.
        (RPRQRRRRStUnicodeEncodeErrorRtUnableEncodePath(R	tpathtkind((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRDÙs	
N(RRR)R*R5RRR=RFRURD(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR-}s		#	
	tExternalMailClientcB@seZdZeZRS(sAn external mail client.(RRRtFalseR*(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRZêst	EvolutioncB@s#eZdZdgZdd„ZRS(sEvolution mail client.t	evolutionc	C@s¸i}|dk	r||d<n|dk	r8||d<n|dk	rQ||d<ngt|jƒƒD]%\}}d|tj|ƒf^qd}d|j|p¡dƒdj|ƒfgS(	s/See ExternalMailClient._get_compose_commandlineRtattachRs%s=%ssmailto:%s?%sRt&N(Rtsortedt	iteritemsRtescapeRUtjoin(	R	R
RR?Rtmessage_optionstktvtoptions_list((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFõs


;N(RRRR2RRF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR\ðs	R]tMuttcB@s#eZdZdgZdd„ZRS(sMutt mail client.tmuttcC@sîg}|d
k	r1|jd|j|ƒgƒn|d
k	r_|jd|j|dƒgƒn|d
k	r¿tjddddƒ|_|jj|ƒ|jjƒ|jd|jj	gƒn|d
k	rê|jd	|j|ƒgƒn|S(s/See ExternalMailClient._get_compose_commandlines-ss-aRR6s
mutt-body-tsuffixs.txts-is--N(
RRERURDttempfiletNamedTemporaryFilet
_temp_fileR;tflushRM(R	R
RR?RRd((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFs		
N(RRRR2RRF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRhs	RitThunderbirdcB@s/eZdZdddddgZdd„ZRS(sMozilla Thunderbird (or Icedove)

    Note that Thunderbird 1.5 is buggy and does not support setting
    "to" simultaneously with including a attachment.

    There is a workaround if no attachment is present, but we always need to
    send attachments.
    tthunderbirdsmozilla-thunderbirdticedovesD/Applications/Mozilla/Thunderbird.app/Contents/MacOS/thunderbird-bins</Applications/Thunderbird.app/Contents/MacOS/thunderbird-binc	C@sïi}|dk	r(|j|ƒ|d<n|dk	rJ|j|ƒ|d<n|dk	rltj|ƒ|d<n|dk	ršdtj|j|ƒƒg}ng}|jgt|jƒƒD]\}}d||f^q¹ƒddj|ƒgS(	s/See ExternalMailClient._get_compose_commandlineR
RRsbody=%ss%s='%s's-composet,N(	RRURtlocal_path_to_urltquoteRER`RaRc(	R	R
RR?RRdRgReRf((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRF0s"	3N(RRRR2RRF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRo"s
		RptKMailcB@s eZdZdgZd„ZRS(sKDE mail client.tkmailcC@s‹g}|dk	r1|jd|j|ƒgƒn|dk	r_|jd|j|dƒgƒn|dk	r‡|j|j|ƒgƒn|S(s/See ExternalMailClient._get_compose_commandlines-ss--attachRN(RRERURD(R	R
RR?Rd((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFJs	(RRRR2RF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRuEs	RvtClawscB@s;eZdZeZdgZddd„Zddd„ZRS(sClaws mail client.s
claws-mailcC@sg}|d	k	r/|jdtj|ƒƒn|d	k	ra|jdtj|j|ƒƒƒn|d	k	r“|jdtj|j|ƒƒƒn|d	kr®tjƒ‚nd|j|ƒdj|ƒf}d|g}|d	k	r
|jd|j	|dƒgƒn|S(
s/See ExternalMailClient._get_compose_commandlinesfrom=ssubject=sbody=smailto:%s?%sR_s	--composes--attachRN(
RtappendRRtRURR#RcRERD(R	R
RR?RRCtcompose_urlRd((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRF`s$  c			C@sP|dkr!|jjdƒ}ntt|ƒj||||||||ƒdS(sSee ExternalMailClient._composeR!N(RRR(tsuperRwR=(	R	RR
RR?RRRRC((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR=zsN(	RRRR)R*R2RRFR=(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRwYs	tclawstXDGEmailcB@s#eZdZdgZdd„ZRS(s=xdg-email attempts to invoke the user's preferred mail clients	xdg-emailcC@s¯|stjƒ‚n|j|ƒg}|dk	rR|jd|j|ƒgƒn|dk	r€|jd|j|dƒgƒn|dk	r«|jd|j|ƒgƒn|S(s/See ExternalMailClient._get_compose_commandlines	--subjects--attachRs--bodyN(RR#RURRERD(R	R
RR?Rtcommandline((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFŒs	N(RRRR2RRF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR|‡s	s	xdg-emailt	EmacsMailcB@s2eZdZdgZd„Zd„Zd„ZRS(s«Call emacsclient to have a mail buffer.

    This only work for emacs >= 22.1 due to recent -e/--eval support.

    The good news is that this implementation will work with all mail
    agents registered against ``mail-user-agent``. So there is no need
    to instantiate ExternalMailClient for each and every GNU Emacs
    MUA.

    Users just have to ensure that ``mail-user-agent`` is set according
    to their tastes.
    temacsclientcC@s#tt|ƒj|ƒd|_dS(N(RzR~R
Rtelisp_tmp_file(R	R((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR
­scC@sMd}tjddddƒ\}}ztj||ƒWdtj|ƒX|S(sWrite our wrapper function into a temporary file.

        This temporary file will be loaded at runtime in
        _get_compose_commandline function.

        This function does not remove the file.  That's a wanted
        behaviour since _get_compose_commandline won't run the send
        mail function directly but return the eligible command line.
        Removing our temporary file here would prevent our sendmail
        function to work.  (The file is deleted by some elisp code
        after being read by Emacs.)
        s¡(defun bzr-add-mime-att (file)
  "Attach FILE to a mail buffer as a MIME attachment."
  (let ((agent mail-user-agent))
    (if (and file (file-exists-p file))
        (cond
         ((eq agent 'sendmail-user-agent)
          (progn
            (mail-text)
            (newline)
            (if (functionp 'etach-attach)
              (etach-attach file)
              (mail-attach-file file))))
         ((or (eq agent 'message-user-agent)
              (eq agent 'gnus-user-agent)
              (eq agent 'mh-e-user-agent))
          (progn
            (mml-attach-file file "text/x-patch" "BZR merge" "inline")))
         ((eq agent 'mew-user-agent)
          (progn
            (mew-draft-prepare-attachments)
            (mew-attach-link file (file-name-nondirectory file))
            (let* ((nums (mew-syntax-nums))
                   (syntax (mew-syntax-get-entry mew-encode-syntax nums)))
              (mew-syntax-set-cd syntax "BZR merge")
              (mew-encode-syntax-print mew-encode-syntax))
            (mew-header-goto-body)))
         (t
          (message "Unhandled MUA, report it on bazaar@lists.canonical.com")))
      (error "File %s does not exist." file))))
R6semacs-bzr-send-Rjs.elN(RktmkstemptosR;R<(R	t_defuntfdt	temp_file((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt_prepare_send_function±s+cC@sdg}d}d}|dk	rCd|j|ƒjddƒ}n|dk	rqd|j|ƒjddƒ}nd||f}|j|ƒ|dk	r|jƒ}||_d|}	d|j|d	ƒ}
d
|}|j|	ƒ|j|
ƒ|j|ƒn|S(Ns--evaltnils"%s"t"s\"s(compose-mail %s %s)s(load "%s")s(bzr-add-mime-att "%s")Rs(delete-file "%s")(RRURRxR†R€RD(R	R
RR?R}t_tot_subjecttmail_cmdtelisptlmmformtmmformtrmform((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRFæs*	"
	



(RRRR2R
R†RF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR~s
			5Rt
MAPIClientcB@seZdZdd„ZRS(s0Default Windows mail client launched using MAPI.c
C@sŠddlm}y,|j|p"d|p+d|p4d|ƒWnG|jk
r…}	|	j|jkr†tjd|	jfgƒ‚q†nXdS(srSee ExternalMailClient._compose.

        This implementation uses MAPI via the simplemapi ctypes wrapper
        i(t
simplemapiRs%MAPI supported mail client (error %d)N(tbzrlib.utilR‘tSendMailt	MAPIErrortcodetMAPI_USER_ABORTRRL(
R	RR
RR?RRRR‘RO((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR=s!	N(RRRRR=(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRstmapitMailAppcB@s&eZdZdgZddd„ZRS(snUse MacOS X's Mail.app for sending email messages.

    Although it would be nice to use appscript, it's not installed
    with the shipped Python installations.  We instead build an
    AppleScript and invoke the script using osascript(1).  We don't
    use the _encode_safe() routines as it's not clear what encoding
    osascript expects the script to be in.
    t	osascriptcC@s‹tjddddƒ\}|_zOtj|dƒtj|dƒtj|dƒ|dk	rwtj|d|ƒn|dk	r¦tj|d	tjd
dƒƒn|dk	rÕtj|d|jd
dƒƒn|dk	rtj|d
|jd
dƒjddƒƒn|dk	r?tj|d|j|dƒƒntj|dƒtj|dƒtj|dƒWdtj	|ƒX|jgS(s/See ExternalMailClient._get_compose_commandlineR6s	bzr-send-Rjs.scptstell application "Mail"
s,set newMessage to make new outgoing message
stell newMessage
s5make new to recipient with properties {address:"%s"}
sset sender to "%s"
Rˆs\"sset subject to "%s"
sset content to "%s\n
"
s
s\nsatell content to make new attachment with properties {file name:"%s"} at after the last paragraph
Rsset visible to true
s	end tell
N(
RkRR…R‚R;RtsenderRRDR<(R	R
RR?RRCR„((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRF,s4#N(RRRR2RRF(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR˜ s	smail.apptDefaultMailcB@s;eZdZeZd„Zddd„Zddd„ZRS(s[Default mail handling.  Tries XDGEmail (or MAPIClient on Windows),
    falls back to EditorcC@s*tjƒrt|jƒSt|jƒSdS(s5Determine the preferred mail client for this platformN(Rt
supports_mapiRRR|(R	((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt_mail_clientas
c			C@sly,|jƒj||||||||ƒSWn9tjk
rgt|jƒj|||||||ƒSXdS(sSee MailClient.composeN(RRRRLRR(	R	RR
RRRRRR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRhscC@siy)|jƒj|||d|d|ƒSWn9tjk
rdt|jƒj|||d|d|ƒSXdS(s$See MailClient.compose_merge_requestRRN(RRRRLRR(R	R
RRRR((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyRssN(	RRRR)R*RRRR(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyR›[s	
tdefaulttmail_clientsE-mail client to use.tinvalidterror(&t
__future__RRJR‚RGR/RktbzrlibRt_mod_configRRRRRRtRegistrytmail_client_registrytobjectRRtregisterRR-RZR\RhRoRuRwR|R~RR˜R›tdefault_keytRegistryOptiontopt_mail_client(((s6/usr/lib/python2.7/dist-packages/bzrlib/mail_client.pyt<module>s^4
6
m



*

j

7
!
		

Copyright © 2017 || Recoded By Mr.Bumblebee