§
    Ètºfº]  ã                   ó–  — d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZmZ d„ Zdd	„Z G d
„ d¦  «        Z ee¦  «         G d„ de¦  «        ¦   «         Z ee
j        ¦  «         G d„ d¦  «        ¦   «         Z ee¦  «         G d„ de¦  «        ¦   «         Z G d„ de¦  «        Z ee
j        ¦  «         G d„ d¦  «        ¦   «         Z G d„ dej        ¦  «        Z ee¦  «         G d„ de¦  «        ¦   «         Z ee
j        ¦  «         G d„ d¦  «        ¦   «         Z ee¦  «         G d„ de¦  «        ¦   «         ZdS )zD
Support for aliases(5) configuration files.

@author: Jp Calderone
é    N)Úimplementer)ÚdeferÚprotocolÚreactor)Úsmtp)ÚIAlias)ÚfailureÚlogc                 ó€  — d„ |                      dd¦  «        D ¦   «         }t          |¦  «        dk    rd}||f}t          j        ||z  ¦  «         dS |\  }}|                      |                     ¦   «         g ¦  «                             t          t          j        |                      d¦  «        ¦  «        ¦  «         dS )að  
    Parse a line from an aliases file.

    @type result: L{dict} mapping L{bytes} to L{list} of L{bytes}
    @param result: A dictionary mapping username to aliases to which
        the results of parsing the line are added.

    @type line: L{bytes}
    @param line: A line from an aliases file.

    @type filename: L{bytes}
    @param filename: The full or relative path to the aliases file.

    @type lineNo: L{int}
    @param lineNo: The position of the line within the aliases file.
    c                 ó6   — g | ]}|                      ¦   «         ‘ŒS © ©Ústrip)Ú.0Úps     úQ/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/mail/alias.pyú
<listcomp>zhandle.<locals>.<listcomp>)   s    € Ð3Ð3Ð3˜1ˆQ�WŠW‰YŒYÐ3Ð3Ð3ó    ú:é   é   z+Invalid format on line %d of alias file %s.ú,N)	ÚsplitÚlenr
   ÚerrÚ
setdefaultr   ÚextendÚmapÚstr)	ÚresultÚlineÚfilenameÚlineNoÚpartsÚfmtÚargÚuserÚaliass	            r   Úhandler)      s°   € ð" 4Ð3 §
¢
¨3°Ñ 2Ô 2Ð3Ñ3Ô3€EÝ
ˆ5�z„z�Q‚€Ø;ˆØ�xÐ ˆÝŒ��c‘	ÑÔÐÐÐà‰ˆˆeØ×Ò˜$Ÿ*š*™,œ,¨Ñ+Ô+×2Ò2µ3µs´yÀ%Ç+Â+ÈcÑBRÔBRÑ3SÔ3SÑTÔTÐTÐTÐTr   c                 óf  — i }d}|€t          |¦  «        }d}nt          |dd¦  «        }d}d}	 |D ]‰}|dz  }|                     ¦   «         }|                     ¦   «                              d	¦  «        rŒC|                     d
¦  «        s|                     d¦  «        r||z   }Œs|rt          ||||¦  «         |}ŒŠ	 |r|                     ¦   «          n# |r|                     ¦   «          w w xY w|rt          ||||¦  «         |                     ¦   «         D ]\  }}	t          |	| |¦  «        ||<   Œ|S )a¢  
    Load a file containing email aliases.

    Lines in the file should be formatted like so::

         username: alias1, alias2, ..., aliasN

    Aliases beginning with a C{|} will be treated as programs, will be run, and
    the message will be written to their stdin.

    Aliases beginning with a C{:} will be treated as a file containing
    additional aliases for the username.

    Aliases beginning with a C{/} will be treated as the full pathname to a file
    to which the message will be appended.

    Aliases without a host part will be assumed to be addresses on localhost.

    If a username is specified multiple times, the aliases for each are joined
    together as if they had all been on one line.

    Lines beginning with a space or a tab are continuations of the previous
    line.

    Lines beginning with a C{#} are comments.

    @type domains: L{dict} mapping L{bytes} to L{IDomain} provider
    @param domains: A mapping of domain name to domain object.

    @type filename: L{bytes} or L{None}
    @param filename: The full or relative path to a file from which to load
        aliases. If omitted, the C{fp} parameter must be specified.

    @type fp: file-like object or L{None}
    @param fp: The file from which to load aliases. If specified,
        the C{filename} parameter is ignored.

    @rtype: L{dict} mapping L{bytes} to L{AliasGroup}
    @return: A mapping from username to group of aliases.
    FNTÚnamez	<unknown>r   Ú r   ú#ú ú	)	ÚopenÚgetattrÚrstripÚlstripÚ
startswithr)   ÚcloseÚitemsÚ
AliasGroup)
Údomainsr"   Úfpr    r5   ÚiÚprevr!   ÚuÚas
             r   ÚloadAliasFiler>   3   ss  € ðR €FØ€EØ	€zÝ�(‰^Œ^ˆØˆˆå˜2˜v {Ñ3Ô3ˆØ	€AØ€DðØð 
	ð 
	ˆDØ�‰FˆAØ—;’;‘=”=ˆDØ�{Š{‰}Œ}×'Ò'¨Ñ,Ô,ð ØØ—’ Ñ%Ô%ð ¨¯ª¸Ñ)>Ô)>ð Ø˜d‘{��àð 6Ý˜6 4¨°1Ñ5Ô5Ð5Ø��ð
	ð ð 	Ø�HŠH‰JŒJˆJøøð ð 	Ø�HŠH‰JŒJˆJˆJð	øøøàð *Ýˆv�t˜X qÑ)Ô)Ð)Ø—’‘”ð .ð .‰ˆˆ1Ý˜q '¨1Ñ-Ô-ˆˆq‰	ˆ	Ø€Ms   ¯BC ÃC,c                   ó&   — e Zd ZdZd„ Zd„ Zdd„ZdS )Ú	AliasBasezª
    The default base class for aliases.

    @ivar domains: See L{__init__}.

    @type original: L{Address}
    @ivar original: The original address being aliased.
    c                 óF   — || _         t          j        |¦  «        | _        dS )zò
        @type domains: L{dict} mapping L{bytes} to L{IDomain} provider
        @param domains: A mapping of domain name to domain object.

        @type original: L{bytes}
        @param original: The original address being aliased.
        N)r8   r   ÚAddressÚoriginal)Úselfr8   rC   s      r   Ú__init__zAliasBase.__init__…   s    € ð ˆŒÝœ XÑ.Ô.ˆŒˆˆr   c                 ó0   — | j         | j        j                 S )z 
        Return the domain associated with original address.

        @rtype: L{IDomain} provider
        @return: The domain for the original address.
        )r8   rC   Údomain©rD   s    r   rG   zAliasBase.domain�   s   € ð Œ|˜DœMÔ0Ô1Ð1r   Nc                 ó|   — |€i }t          | ¦  «        |v rdS d|t          | ¦  «        <   |                      ¦   «         S ©aY  
        Map this alias to its ultimate destination.

        @type aliasmap: L{dict} mapping L{bytes} to L{AliasBase}
        @param aliasmap: A mapping of username to alias or group of aliases.

        @type memo: L{None} or L{dict} of L{AliasBase}
        @param memo: A record of the aliases already considered in the
            resolution process.  If provided, C{memo} is modified to include
            this alias.

        @rtype: L{IMessage <smtp.IMessage>} or L{None}
        @return: A message receiver for the ultimate destination or None for
            an invalid destination.
        N)r   ÚcreateMessageReceiver©rD   ÚaliasmapÚmemos      r   ÚresolvezAliasBase.resolve™   sE   € ð  ˆ<ØˆDÝˆt‰9Œ9˜ÐÐØ�4Øˆ�S�‰YŒY‰Ø×)Ò)Ñ+Ô+Ð+r   ©N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rE   rG   rO   r   r   r   r@   r@   {   sP   € € € € € ðð ð	/ð 	/ð 	/ð2ð 2ð 2ð,ð ,ð ,ð ,ð ,ð ,r   r@   c                   ó2   — e Zd ZdZd„ Zdefd„Zd„ Zdd„ZdS )	ÚAddressAliasz‹
    An alias which translates one email address into another.

    @type alias : L{Address}
    @ivar alias: The destination address.
    c                 ó\   — t          j        | g|¢R Ž  t          j        |¦  «        | _        dS )aQ  
        @type alias: L{Address}, L{User}, L{bytes} or object which can be
            converted into L{bytes}
        @param alias: The destination address.

        @type args: 2-L{tuple} of (0) L{dict} mapping L{bytes} to L{IDomain}
            provider, (1) L{bytes}
        @param args: Arguments for L{AliasBase.__init__}.
        N)r@   rE   r   rB   r(   )rD   r(   Úargss      r   rE   zAddressAlias.__init__º   s2   € õ 	Ô˜4Ð' $Ð'Ð'Ð'Ð'Ý”\ %Ñ(Ô(ˆŒ
ˆ
ˆ
r   Úreturnc                 ó   — d| j         › d�S )z©
        Build a string representation of this L{AddressAlias} instance.

        @rtype: L{bytes}
        @return: A string containing the destination address.
        z	<Address ú>)r(   rH   s    r   Ú__str__zAddressAlias.__str__Ç   s   € ð )˜4œ:Ð(Ð(Ð(Ð(r   c                 ót   — |                       ¦   «                              t          | j        ¦  «        ¦  «        S )zÃ
        Create a message receiver which delivers a message to
        the destination address.

        @rtype: L{IMessage <smtp.IMessage>} provider
        @return: A message receiver.
        )rG   Úexistsr   r(   rH   s    r   rK   z"AddressAlias.createMessageReceiverÐ   s(   € ð �{Š{‰}Œ}×#Ò#¥C¨¬
¡O¤OÑ4Ô4Ð4r   Nc           	      ó€  — |€i }t          | ¦  «        |v rdS d|t          | ¦  «        <   	  |                      ¦   «                              t          j        | j        ddd¦  «        |¦  «        ¦   «         S # t          j        $ r Y nw xY w| j        j        |v r&|| j        j                                      ||¦  «        S dS rJ   )	r   rG   r^   r   ÚUserr(   ÚSMTPBadRcptÚlocalrO   rL   s      r   rO   zAddressAlias.resolveÚ   sÉ   € ð  ˆ<ØˆDÝˆt‰9Œ9˜ÐÐØ�4Øˆ�S�‰YŒY‰ð	ØV�4—;’;‘=”=×'Ò'­¬	°$´*¸dÀDÈ$Ñ(OÔ(OÐQUÑVÔVÑXÔXÐXøÝÔð 	ð 	ð 	ØˆDð	øøøàŒ:Ô˜xÐ'Ð'Ø˜DœJÔ,Ô-×5Ò5°hÀÑEÔEÐEØˆts   «A	A5 Á5BÂBrP   )	rQ   rR   rS   rT   rE   r   r\   rK   rO   r   r   r   rV   rV   ±   sk   € € € € € ðð ð)ð )ð )ð)˜ð )ð )ð )ð )ð5ð 5ð 5ðð ð ð ð ð r   rV   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zdefd„Z	dS )	ÚFileWrappera  
    A message receiver which delivers a message to a file.

    @type fp: file-like object
    @ivar fp: A file used for temporary storage of the message.

    @type finalname: L{bytes}
    @ivar finalname: The name of the file in which the message should be
        stored.
    c                 óD   — t          j        ¦   «         | _        || _        dS )z‹
        @type filename: L{bytes}
        @param filename: The name of the file in which the message should be
            stored.
        N)ÚtempfileÚTemporaryFiler9   Ú	finalname)rD   r"   s     r   rE   zFileWrapper.__init__  s   € õ Ô(Ñ*Ô*ˆŒØ!ˆŒˆˆr   c                 ó@   — | j                              |dz   ¦  «         dS )z‘
        Write a received line to the temporary file.

        @type line: L{bytes}
        @param line: A received line of the message.
        ú
N)r9   Úwrite©rD   r!   s     r   ÚlineReceivedzFileWrapper.lineReceived  s"   € ð 	Œ�Š�d˜T‘kÑ"Ô"Ð"Ð"Ð"r   c                 óÀ  — | j                              dd¦  «         	 t          | j        d¦  «        }n5# t          $ r( t          j        t          j        ¦   «         ¦  «        cY S w xY w|5  | 	                    | j          
                    ¦   «         ¦  «         | j                              ¦   «          ddd¦  «         n# 1 swxY w Y   t          j        | j        ¦  «        S )ac  
        Handle end of message by writing the message to the file.

        @rtype: L{Deferred <defer.Deferred>} which successfully results in
            L{bytes}
        @return: A deferred which succeeds with the name of the file to which
            the message has been stored or fails if the message cannot be
            saved to the file.
        r   r=   N)r9   Úseekr0   rh   ÚBaseExceptionr   Úfailr	   ÚFailurerk   Úreadr5   Úsucceed)rD   Úfs     r   ÚeomReceivedzFileWrapper.eomReceived  s  € ð 	Œ�Š�Q˜ÑÔÐð	1Ý�T”^ SÑ)Ô)ˆAˆAøÝð 	1ð 	1ð 	1Ý”:�gœoÑ/Ô/Ñ0Ô0Ð0Ð0Ð0ð	1øøøð ð 	ð 	Ø�GŠG�D”G—L’L‘N”NÑ#Ô#Ð#ØŒG�MŠM‰OŒOˆOð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ Œ}˜Tœ^Ñ,Ô,Ð,s"   �3 ³/A%Á$A%Á*AB<Â<C ÃC c                 óF   — | j                              ¦   «          d| _         dS )zG
        Close the temporary file when the connection is lost.
        N)r9   r5   rH   s    r   ÚconnectionLostzFileWrapper.connectionLost-  s   € ð 	Œ�Š‰ŒˆØˆŒˆˆr   rY   c                 ó   — d| j         › d�S )z­
        Build a string representation of this L{FileWrapper} instance.

        @rtype: L{bytes}
        @return: A string containing the file name of the message.
        z<FileWrapper r[   )rh   rH   s    r   r\   zFileWrapper.__str__4  s   € ð 1˜tœ~Ð0Ð0Ð0Ð0r   N©
rQ   rR   rS   rT   rE   rm   rv   rx   r   r\   r   r   r   rd   rd   ø   su   € € € € € ð	ð 	ð"ð "ð "ð#ð #ð #ð-ð -ð -ð,ð ð ð1˜ð 1ð 1ð 1ð 1ð 1ð 1r   rd   c                   ó*   — e Zd ZdZd„ Zdefd„Zd„ ZdS )Ú	FileAliasz_
    An alias which translates an address to a file.

    @ivar filename: See L{__init__}.
    c                 ó8   — t          j        | g|¢R Ž  || _        dS )a"  
        @type filename: L{bytes}
        @param filename: The name of the file in which to store the message.

        @type args: 2-L{tuple} of (0) L{dict} mapping L{bytes} to L{IDomain}
            provider, (1) L{bytes}
        @param args: Arguments for L{AliasBase.__init__}.
        N)r@   rE   r"   )rD   r"   rX   s      r   rE   zFileAlias.__init__F  s(   € õ 	Ô˜4Ð' $Ð'Ð'Ð'Ð'Ø ˆŒˆˆr   rY   c                 ó   — d| j         › d�S )z£
        Build a string representation of this L{FileAlias} instance.

        @rtype: L{bytes}
        @return: A string containing the name of the file.
        z<File r[   )r"   rH   s    r   r\   zFileAlias.__str__R  s   € ð )˜œÐ(Ð(Ð(Ð(r   c                 ó*   — t          | j        ¦  «        S )z¹
        Create a message receiver which delivers a message to the file.

        @rtype: L{FileWrapper}
        @return: A message receiver which writes a message to the file.
        )rd   r"   rH   s    r   rK   zFileAlias.createMessageReceiver[  s   € õ ˜4œ=Ñ)Ô)Ð)r   N)rQ   rR   rS   rT   rE   r   r\   rK   r   r   r   r|   r|   >  sW   € € € € € ðð ð
!ð 
!ð 
!ð)˜ð )ð )ð )ð )ð*ð *ð *ð *ð *r   r|   c                   ó   — e Zd ZdZdS )ÚProcessAliasTimeoutzb
    An error indicating that a timeout occurred while waiting for a process
    to complete.
    N)rQ   rR   rS   rT   r   r   r   r�   r�   e  s   € € € € € ðð ð ð r   r�   c                   óT   — e Zd ZdZdZdZdZeZdd„Zd„ Z	d„ Z
d„ Zd	„ Zd
„ Zdefd„ZdS )ÚMessageWrapperaF  
    A message receiver which delivers a message to a child process.

    @type completionTimeout: L{int} or L{float}
    @ivar completionTimeout: The number of seconds to wait for the child
        process to exit before reporting the delivery as a failure.

    @type _timeoutCallID: L{None} or
        L{IDelayedCall <twisted.internet.interfaces.IDelayedCall>} provider
    @ivar _timeoutCallID: The call used to time out delivery, started when the
        connection to the child process is closed.

    @type done: L{bool}
    @ivar done: A flag indicating whether the child process has exited
        (C{True}) or not (C{False}).

    @type reactor: L{IReactorTime <twisted.internet.interfaces.IReactorTime>}
        provider
    @ivar reactor: A reactor which will be used to schedule timeouts.

    @ivar protocol: See L{__init__}.

    @type processName: L{bytes} or L{None}
    @ivar processName: The process name.

    @type completion: L{Deferred <defer.Deferred>}
    @ivar completion: The deferred which will be triggered by the protocol
        when the child process exits.
    Fé<   Nc                 óÈ   — || _         || _        t          j        ¦   «         | _        | j        | j        _        | j                             | j        ¦  «         |�	|| _        dS dS )a–  
        @type protocol: L{ProcessAliasProtocol}
        @param protocol: The protocol associated with the child process.

        @type process: L{bytes} or L{None}
        @param process: The process name.

        @type reactor: L{None} or L{IReactorTime
            <twisted.internet.interfaces.IReactorTime>} provider
        @param reactor: A reactor which will be used to schedule timeouts.
        N)	ÚprocessNamer   r   ÚDeferredÚ
completionÚonEndÚaddBothÚ_processEndedr   )rD   r   Úprocessr   s       r   rE   zMessageWrapper.__init__“  s`   € ð #ˆÔØ ˆŒÝœ.Ñ*Ô*ˆŒØ"œoˆŒÔØŒ×Ò Ô 2Ñ3Ô3Ð3àÐØ"ˆDŒLˆLˆLð Ðr   c                 óf   — d| _         | j        �"| j                             ¦   «          d| _        dS |S )a—  
        Record process termination and cancel the timeout call if it is active.

        @type result: L{Failure <failure.Failure>}
        @param result: The reason the child process terminated.

        @rtype: L{None} or L{Failure <failure.Failure>}
        @return: None, if the process end is expected, or the reason the child
            process terminated, if the process end is unexpected.
        TN)ÚdoneÚ_timeoutCallIDÚcancel)rD   r    s     r   r‹   zMessageWrapper._processEnded¨  s@   € ð ˆŒ	ØÔÐ*ð Ô×&Ò&Ñ(Ô(Ð(Ø"&ˆDÔÐÐð ˆMr   c                 ó\   — | j         rdS | j        j                             |dz   ¦  «         dS )z�
        Write a received line to the child process.

        @type line: L{bytes}
        @param line: A received line of the message.
        Nrj   )rŽ   r   Ú	transportrk   rl   s     r   rm   zMessageWrapper.lineReceived¾  s6   € ð Œ9ð 	ØˆFØŒÔ×%Ò% d¨T¡kÑ2Ô2Ð2Ð2Ð2r   c                 ó®   — | j         sH| j        j                             ¦   «          | j                             | j        | j        ¦  «        | _        | j	        S )zö
        Disconnect from the child process and set up a timeout to wait for it
        to exit.

        @rtype: L{Deferred <defer.Deferred>}
        @return: A deferred which will be called back when the child process
            exits.
        )
rŽ   r   r’   ÚloseConnectionr   Ú	callLaterÚcompletionTimeoutÚ_completionCancelr�   rˆ   rH   s    r   rv   zMessageWrapper.eomReceivedÉ  sT   € ð Œyð 	ØŒMÔ#×2Ò2Ñ4Ô4Ð4Ø"&¤,×"8Ò"8ØÔ&¨Ô(>ñ#ô #ˆDÔð ŒÐr   c                 óò   — d| _         | j        j                             d¦  «         t	          d| j        › d�¦  «        }d| j        _        | j                             t          j
        |¦  «        ¦  «         dS )zÅ
        Handle the expiration of the timeout for the child process to exit by
        terminating the child process forcefully and issuing a failure to the
        L{completion} deferred.
        NÚKILLzNo answer after z seconds)r�   r   r’   ÚsignalProcessr�   r–   r‰   rˆ   Úerrbackr	   rr   )rD   Úexcs     r   r—   z MessageWrapper._completionCancelÙ  sq   € ð #ˆÔØŒÔ×-Ò-¨fÑ5Ô5Ð5Ý!Ð"U°TÔ5KÐ"UÐ"UÐ"UÑVÔVˆØ"ˆŒÔØŒ×Ò¥¤°Ñ 4Ô 4Ñ5Ô5Ð5Ð5Ð5r   c                 ó   — dS )z9
        Ignore notification of lost connection.
        Nr   rH   s    r   rx   zMessageWrapper.connectionLostå  s   € € € r   rY   c                 ó   — d| j         › d�S )z«
        Build a string representation of this L{MessageWrapper} instance.

        @rtype: L{bytes}
        @return: A string containing the name of the process.
        z<ProcessWrapper r[   )r†   rH   s    r   r\   zMessageWrapper.__str__ê  s   € ð 6 $Ô"2Ð5Ð5Ð5Ð5r   ©NN)rQ   rR   rS   rT   rŽ   r–   r�   r   rE   r‹   rm   rv   r—   rx   r   r\   r   r   r   rƒ   rƒ   l  s¯   € € € € € ðð ð< €DàÐØ€Nà€Gð#ð #ð #ð #ð*ð ð ð,	3ð 	3ð 	3ðð ð ð 
6ð 
6ð 
6ðð ð ð
6˜ð 6ð 6ð 6ð 6ð 6ð 6r   rƒ   c                   ó   — e Zd ZdZdZd„ ZdS )ÚProcessAliasProtocolzå
    A process protocol which errbacks a deferred when the associated
    process ends.

    @type onEnd: L{None} or L{Deferred <defer.Deferred>}
    @ivar onEnd: If set, a deferred on which to errback when the process ends.
    Nc                 óL   — | j         �| j                              |¦  «         dS dS )z–
        Call an errback.

        @type reason: L{Failure <failure.Failure>}
        @param reason: The reason the child process terminated.
        N)r‰   r›   )rD   Úreasons     r   ÚprocessEndedz!ProcessAliasProtocol.processEndedÿ  s0   € ð Œ:Ð!ØŒJ×Ò˜vÑ&Ô&Ð&Ð&Ð&ð "Ð!r   )rQ   rR   rS   rT   r‰   r¤   r   r   r   r¡   r¡   ô  s4   € € € € € ðð ð €Eð'ð 'ð 'ð 'ð 'r   r¡   c                   ó4   — e Zd ZdZeZd„ Zdefd„Zd„ Zd„ Z	dS )ÚProcessAliasa6  
    An alias which is handled by the execution of a program.

    @type path: L{list} of L{bytes}
    @ivar path: The arguments to pass to the process. The first string is
        the executable's name.

    @type program: L{bytes}
    @ivar program: The path of the program to be executed.

    @type reactor: L{IReactorTime <twisted.internet.interfaces.IReactorTime>}
        and L{IReactorProcess <twisted.internet.interfaces.IReactorProcess>}
        provider
    @ivar reactor: A reactor which will be used to create and timeout the
        child process.
    c                 ó€   — t          j        | g|¢R Ž  |                     ¦   «         | _        | j        d         | _        dS )aX  
        @type path: L{bytes}
        @param path: The command to invoke the program consisting of the path
            to the executable followed by any arguments.

        @type args: 2-L{tuple} of (0) L{dict} mapping L{bytes} to L{IDomain}
            provider, (1) L{bytes}
        @param args: Arguments for L{AliasBase.__init__}.
        r   N)r@   rE   r   ÚpathÚprogram)rD   r¨   rX   s      r   rE   zProcessAlias.__init__  s=   € õ 	Ô˜4Ð' $Ð'Ð'Ð'Ð'Ø—J’J‘L”LˆŒ	Ø”y ”|ˆŒˆˆr   rY   c                 ó   — d| j         › d�S )z¸
        Build a string representation of this L{ProcessAlias} instance.

        @rtype: L{bytes}
        @return: A string containing the command used to invoke the process.
        z	<Process r[   )r¨   rH   s    r   r\   zProcessAlias.__str__.  s   € ð (˜4œ9Ð'Ð'Ð'Ð'r   c                 ó:   — | j                              |||¦  «        S )aP  
        Spawn a process.

        This wraps the L{spawnProcess
        <twisted.internet.interfaces.IReactorProcess.spawnProcess>} method on
        L{reactor} so that it can be customized for test purposes.

        @type proto: L{IProcessProtocol
            <twisted.internet.interfaces.IProcessProtocol>} provider
        @param proto: An object which will be notified of all events related to
            the created process.

        @type program: L{bytes}
        @param program: The full path name of the file to execute.

        @type path: L{list} of L{bytes}
        @param path: The arguments to pass to the process. The first string
            should be the executable's name.

        @rtype: L{IProcessTransport
            <twisted.internet.interfaces.IProcessTransport>} provider
        @return: A process transport.
        )r   ÚspawnProcess)rD   Úprotor©   r¨   s       r   r¬   zProcessAlias.spawnProcess7  s   € ð0 Œ|×(Ò(¨°¸Ñ>Ô>Ð>r   c                 óš   — t          ¦   «         }t          || j        | j        ¦  «        }|                      || j        | j        ¦  «         |S )zÚ
        Launch a process and create a message receiver to pass a message
        to the process.

        @rtype: L{MessageWrapper}
        @return: A message receiver which delivers a message to the process.
        )r¡   rƒ   r©   r   r¬   r¨   )rD   r   Úms      r   rK   z"ProcessAlias.createMessageReceiverQ  sE   € õ !Ñ"Ô"ˆÝ˜1˜dœl¨D¬LÑ9Ô9ˆØ×Ò˜!˜Tœ\¨4¬9Ñ5Ô5Ð5Øˆr   N)
rQ   rR   rS   rT   r   rE   r   r\   r¬   rK   r   r   r   r¦   r¦   
  sm   € € € € € ðð ð" €Gð$ð $ð $ð(˜ð (ð (ð (ð (ð?ð ?ð ?ð4ð ð ð ð r   r¦   c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zdefd„Z	dS )	ÚMultiWrapperz‡
    A message receiver which delivers a single message to multiple other
    message receivers.

    @ivar objs: See L{__init__}.
    c                 ó   — || _         dS )z²
        @type objs: L{list} of L{IMessage <smtp.IMessage>} provider
        @param objs: Message receivers to which the incoming message should be
            directed.
        N)Úobjs)rD   r³   s     r   rE   zMultiWrapper.__init__h  s   € ð ˆŒ	ˆ	ˆ	r   c                 óD   — | j         D ]}|                     |¦  «         ŒdS )zŠ
        Pass a received line to the message receivers.

        @type line: L{bytes}
        @param line: A line of the message.
        N)r³   rm   )rD   r!   Úos      r   rm   zMultiWrapper.lineReceivedp  s4   € ð ”ð 	!ð 	!ˆAØ�NŠN˜4Ñ Ô Ð Ð ð	!ð 	!r   c                 óH   — t          j        d„ | j        D ¦   «         ¦  «        S )aG  
        Pass the end of message along to the message receivers.

        @rtype: L{DeferredList <defer.DeferredList>} whose successful results
            are L{bytes} or L{None}
        @return: A deferred list which triggers when all of the message
            receivers have finished handling their end of message.
        c                 ó6   — g | ]}|                      ¦   «         ‘ŒS r   )rv   )r   rµ   s     r   r   z,MultiWrapper.eomReceived.<locals>.<listcomp>ƒ  s    € Ð"FÐ"FÐ"F°q 1§=¢=¡?¤?Ð"FÐ"FÐ"Fr   )r   ÚDeferredListr³   rH   s    r   rv   zMultiWrapper.eomReceivedz  s&   € õ Ô!Ð"FÐ"F¸D¼IÐ"FÑ"FÔ"FÑGÔGÐGr   c                 óB   — | j         D ]}|                     ¦   «          ŒdS )zQ
        Inform the message receivers that the connection has been lost.
        N)r³   rx   )rD   rµ   s     r   rx   zMultiWrapper.connectionLost…  s4   € ð ”ð 	ð 	ˆAØ×ÒÑÔÐÐð	ð 	r   rY   c                 ó>   — dt          t          | j        ¦  «        ›d�S )z±
        Build a string representation of this L{MultiWrapper} instance.

        @rtype: L{bytes}
        @return: A string containing a list of the message receivers.
        z<GroupWrapper r[   )r   r   r³   rH   s    r   r\   zMultiWrapper.__str__Œ  s!   € ð 9¥¥C¨¬Ñ 3Ô 3Ð8Ð8Ð8Ð8r   Nrz   r   r   r   r±   r±   _  sx   € € € € € ðð ðð ð ð!ð !ð !ð	Hð 	Hð 	Hðð ð ð9˜ð 9ð 9ð 9ð 9ð 9ð 9r   r±   c                   ó<   — e Zd ZdZeZd„ Zd„ Zdefd„Z	d„ Z
d	d„ZdS )
r7   aL  
    An alias which points to multiple destination aliases.

    @type processAliasFactory: no-argument callable which returns
        L{ProcessAlias}
    @ivar processAliasFactory: A factory for process aliases.

    @type aliases: L{list} of L{AliasBase} which implements L{IAlias}
    @ivar aliases: The destination aliases.
    c                 óÂ  — t          j        | g|¢R Ž  g | _        |�rÂ|                     ¦   «                              ¦   «         }|                     d¦  «        rª	 t          |dd…         ¦  «        }|5  d                     d„ |D ¦   «         ¦  «        }ddd¦  «         n# 1 swxY w Y   |                     | 	                    d¦  «        ¦  «         �n# t          $ r" t          j        d|dd…         ›�¦  «         Y nÜw xY w|                     d¦  «        r/| j                              | j        |dd…         g|¢R Ž ¦  «         n”|                     d	¦  «        rZt          j                             |¦  «        rt          j        d
¦  «         nK| j                             t%          |g|¢R Ž ¦  «         n%| j                             t'          |g|¢R Ž ¦  «         |�°ÀdS dS )a‚  
        Create a group of aliases.

        Parse a list of alias strings and, for each, create an appropriate
        alias object.

        @type items: L{list} of L{bytes}
        @param items: Aliases.

        @type args: n-L{tuple} of (0) L{dict} mapping L{bytes} to L{IDomain}
            provider, (1) L{bytes}
        @param args: Arguments for L{AliasBase.__init__}.
        r   r   Nr.   c                 ó6   — g | ]}|                      ¦   «         ‘ŒS r   r   )r   Úls     r   r   z'AliasGroup.__init__.<locals>.<listcomp>¿  s    € Ð(>Ð(>Ð(>°q¨¯ª©¬Ð(>Ð(>Ð(>r   r   zInvalid filename in alias file ú|ú/z Directory delivery not supported)r@   rE   ÚaliasesÚpopr   r4   r0   Újoinr   r   rp   r
   r   ÚappendÚprocessAliasFactoryÚosr¨   Úisdirr|   rV   )rD   r6   rX   Úaddrru   s        r   rE   zAliasGroup.__init__¥  s_  € õ 	Ô˜4Ð' $Ð'Ð'Ð'Ð'ØˆŒØñ 	?Ø—9’9‘;”;×$Ò$Ñ&Ô&ˆDØ�Š˜sÑ#Ô#ð ?ð2Ý˜T ! " "œX™œ�Að ð @ð @Ø"ŸxšxÐ(>Ð(>¸AÐ(>Ñ(>Ô(>Ñ?Ô?˜ð@ð @ð @ñ @ô @ð @ð @ð @ð @ð @ð @øøøð @ð @ð @ð @à—L’L §¢¨C¡¤Ñ1Ô1Ð1Ñ1øõ %ð Lð Lð LÝ”GÐJ¸dÀ1À2À2¼hÐJÐJÑKÔKÐKÐKÐKðLøøøð —’ Ñ%Ô%ð ?Ø”×#Ò#Ð$< DÔ$<¸TÀ!À"À"¼XÐ$MÈÐ$MÐ$MÐ$MÑNÔNÐNÐNØ—’ Ñ%Ô%ð ?Ý”7—=’= Ñ&Ô&ð @Ý”GÐ>Ñ?Ô?Ð?Ð?à”L×'Ò'­	°$Ð(>¸Ð(>Ð(>Ð(>Ñ?Ô?Ð?Ð?à”×#Ò#¥L°Ð$=¸Ð$=Ð$=Ð$=Ñ>Ô>Ð>ð' ñ 	?ð 	?ð 	?ð 	?ð 	?s$   ÁC Á2 BÂB"Â%B"Ã)C?Ã>C?c                 ó*   — t          | j        ¦  «        S )z‰
        Return the number of aliases in the group.

        @rtype: L{int}
        @return: The number of aliases in the group.
        )r   rÁ   rH   s    r   Ú__len__zAliasGroup.__len__Ë  s   € õ �4”<Ñ Ô Ð r   rY   c                 ób   — dd                      t          t          | j        ¦  «        ¦  «        z  S )z¨
        Build a string representation of this L{AliasGroup} instance.

        @rtype: L{bytes}
        @return: A string containing the aliases in the group.
        z<AliasGroup [%s]>z, )rÃ   r   r   rÁ   rH   s    r   r\   zAliasGroup.__str__Ô  s'   € ð # d§i¢iµµC¸¼Ñ0FÔ0FÑ&GÔ&GÑHÐHr   c                 ó>   — t          d„ | j        D ¦   «         ¦  «        S )a,  
        Create a message receiver for each alias and return a message receiver
        which will pass on a message to each of those.

        @rtype: L{MultiWrapper}
        @return: A message receiver which passes a message on to message
            receivers for each alias in the group.
        c                 ó6   — g | ]}|                      ¦   «         ‘ŒS r   )rK   )r   r=   s     r   r   z4AliasGroup.createMessageReceiver.<locals>.<listcomp>æ  s$   € ÐMÐMÐM¸1˜Q×4Ò4Ñ6Ô6ÐMÐMÐMr   )r±   rÁ   rH   s    r   rK   z AliasGroup.createMessageReceiverÝ  s#   € õ ÐMÐMÀÄÐMÑMÔMÑNÔNÐNr   Nc                 ó®   — |€i }g }| j         D ]+}|                     |                     ||¦  «        ¦  «         Œ,t          t	          d|¦  «        ¦  «        S )a�  
        Map each of the aliases in the group to its ultimate destination.

        @type aliasmap: L{dict} mapping L{bytes} to L{AliasBase}
        @param aliasmap: A mapping of username to alias or group of aliases.

        @type memo: L{None} or L{dict} of L{AliasBase}
        @param memo: A record of the aliases already considered in the
            resolution process.  If provided, C{memo} is modified to include
            this alias.

        @rtype: L{MultiWrapper}
        @return: A message receiver which passes the message on to message
            receivers for the ultimate destination of each alias in the group.
        N)rÁ   rÄ   rO   r±   Úfilter)rD   rM   rN   Úrr=   s        r   rO   zAliasGroup.resolveè  s]   € ð  ˆ<ØˆDØˆØ”ð 	0ð 	0ˆAØ�HŠH�Q—Y’Y˜x¨Ñ.Ô.Ñ/Ô/Ð/Ð/Ý�F 4¨™OœOÑ,Ô,Ð,r   rP   )rQ   rR   rS   rT   r¦   rÅ   rE   rÊ   r   r\   rK   rO   r   r   r   r7   r7   –  s‹   € € € € € ð	ð 	ð 'Ðð$?ð $?ð $?ðL!ð !ð !ðI˜ð Ið Ið Ið Ið	Oð 	Oð 	Oð-ð -ð -ð -ð -ð -r   r7   rŸ   )rT   rÆ   rf   Úzope.interfacer   Útwisted.internetr   r   r   Útwisted.mailr   Útwisted.mail.interfacesr   Útwisted.pythonr	   r
   r)   r>   r@   rV   ÚIMessagerd   r|   Ú	Exceptionr�   rƒ   ÚProcessProtocolr¡   r¦   r±   r7   r   r   r   ú<module>rÙ      s;  ððð ð 
€	€	€	Ø €€€à &Ð &Ð &Ð &Ð &Ð &à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø Ð Ð Ð Ð Ð Ø *Ð *Ð *Ð *Ð *Ð *Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'ðUð Uð Uð6Eð Eð Eð EðP3,ð 3,ð 3,ð 3,ð 3,ñ 3,ô 3,ð 3,ðl €ˆVÑÔðCð Cð Cð Cð C�9ñ Cô Cñ ÔðCðL €ˆTŒ]ÑÔðB1ð B1ð B1ð B1ð B1ñ B1ô B1ñ ÔðB1ðJ €ˆVÑÔð#*ð #*ð #*ð #*ð #*�	ñ #*ô #*ñ Ôð#*ðLð ð ð ð ˜)ñ ô ð ð €ˆTŒ]ÑÔðD6ð D6ð D6ð D6ð D6ñ D6ô D6ñ ÔðD6ðN'ð 'ð 'ð 'ð '˜8Ô3ñ 'ô 'ð 'ð, €ˆVÑÔðQð Qð Qð Qð Q�9ñ Qô Qñ ÔðQðh €ˆTŒ]ÑÔð39ð 39ð 39ð 39ð 39ñ 39ô 39ñ Ôð39ðl €ˆVÑÔðf-ð f-ð f-ð f-ð f-�ñ f-ô f-ñ Ôðf-ð f-ð f-r   