U
    Z+d                     @   sb   d Z ddlZddlmZ ddlmZ dZdZeeddZdeejfd	d
Z	dd Z
efddZdS )z/Creating events, and event exchange definition.    N)copy)Exchange)Eventevent_exchangeget_exchange
group_fromZceleryevZtopictypec                 K   s:   |r||f|n|}d|kr.|j | | d n| |d< |S )zCreate an event.

    Notes:
        An event is simply a dictionary: the only required field is ``type``.
        A ``timestamp`` field will be set to the current time if not provided.
    	timestamp)r
   r	   r	   )update)r	   _fields__dict__Z__now__fieldsevent r   7/tmp/pip-unpacked-wheel-ucduq0nd/celery/events/event.pyr      s
    r   c                 C   s   |  ddd S )zGet the group part of an event type name.

    Example:
        >>> group_from('task-sent')
        'task'

        >>> group_from('custom-my-event')
        'custom'
    -   r   )splitr   r   r   r   r   !   s    
r   c                 C   s.   t t}| jjdkrd|_||jkr*||_|S )a8  Get exchange used for sending events.

    Arguments:
        conn (kombu.Connection): Connection used for sending/receiving events.
        name (str): Name of the exchange. Default is ``celeryev``.

    Note:
        The event type changes if Redis is used as the transport
        (from topic -> fanout).
    ZredisZfanout)r   r   	transportZdriver_typer	   name)connr   exr   r   r   r   .   s    
r   )__doc__timer   Zkombur   __all__ZEVENT_EXCHANGE_NAMEr   dictr   r   r   r   r   r   r   <module>   s   