o
    wvXj  ã                   @   sr   d Z ddlmZm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.é    )Úabsolute_importÚunicode_literalsN)Úcopy)ÚExchange)ÚEventÚevent_exchangeÚget_exchangeÚ
group_fromÚceleryevÚtopic©Útypec                 K   s@   |r
||fi |¤Žn|}d|vr|j |ƒ | d� |S | |d< |S )z¾Create 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__Ú__now__ÚfieldsÚevent© r   úP/var/www/html/myproject/venv/lib/python3.10/site-packages/celery/events/event.pyr      s   ÿr   c                 C   s   |   dd¡d S )z«Get 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).
    ÚredisÚfanout)r   r   Ú	transportÚdriver_typer   Úname)Úconnr   Úexr   r   r   r   0   s   
r   )Ú__doc__Ú
__future__r   r   Útimer   Úkombur   Ú__all__ÚEVENT_EXCHANGE_NAMEr   Údictr   r	   r   r   r   r   r   Ú<module>   s    