
    2i                     <    d dl mZ ddlmZ ddlmZ  G d d      Zy)    )Optional   )Node)quote_stringc                   b    e Zd ZdZ	 	 ddedededee   dee   f
dZd	efd
Z	d	efdZ
d	efdZy)Edgez'
    An edge connecting two nodes.
    Nsrc_noderelation	dest_nodeedge_idaliasc                 ~    ||t        d      || _        || _        || _        || _        || _        |xs i | _        y)a  
        Create a new edge.

        Args:
            src_node: The source node of the edge.
            relation: The relationship type of the edge.
            dest_node: The destination node of the edge.
            edge_id: The ID of the edge.
            alias: An alias for the edge (default is empty string).
            properties: The properties of the edge.

        Raises:
            AssertionError: If either src_node or dest_node is not provided.

        Returns:
            None
        Nz*Both src_node & dest_node must be provided)AssertionErroridr   r	   r   r
   
properties)selfr	   r
   r   r   r   r   s          W/mnt/e/genesis-system/.venvs/voice-bridge/lib/python3.12/site-packages/falkordb/edge.py__init__zEdge.__init__
   sJ    ( y0 !MNN!
"#"$*    returnc                     d}| j                   rDdj                  d t        | j                   j                               D              }|d|z   dz   z  }|S )z
        Get a string representation of the edge's properties.

        Returns:
            str: A string representation of the edge's properties.
         ,c              3   V   K   | ]!  \  }}|d z   t        t        |            z    # yw:Nstrr   .0keyvals      r   	<genexpr>z!Edge.to_string.<locals>.<genexpr>1   /      C c	CS 122   '){})r   joinsorteditemsr   respropss      r   	to_stringzEdge.to_string(   sW     ??HH  &t'<'<'> ? E 3;$$C
r   c                    t        | j                  t              rd| j                  j                   d}nd}|d| j                   z  }| j                  r|d| j                  z   z  }| j
                  rBdj                  d t        | j
                  j                               D              }|d| d	z  }|d
z  }t        | j                  t              r|d| j                  j                   dz  }|S |dz  }|S )z
        Get a string representation of the edge.

        Returns:
            str: A string representation of the edge.
        ()z()z-[r   r   c              3   V   K   | ]!  \  }}|d z   t        t        |            z    # ywr   r   r   s      r   r#   zEdge.__str__.<locals>.<genexpr>K   r$   r%   r&   r'   z]->)

isinstancer	   r   r   r
   r   r(   r)   r*   r   r+   s      r   __str__zEdge.__str__9   s     dmmT*dmm))*!,CC 	DJJ<  ==3&&C??HH  &t'<'<'> ? E Rwb>!Cu dnnd+Qt~~++,A..C 
 4KC
r   c                    t        |t              sy| j                  &|j                  | j                  |j                  k(  ry| j                  |j                  k7  ry| j                  |j                  k7  ry| j
                  |j
                  k7  ryt        | j                        t        |j                        k7  ry| j                  |j                  k7  ryy)z
        Check if two edges are equal.

        Args:
            rhs: The edge to compare.

        Returns:
            bool: True if the edges are equal, False otherwise.
        FT)r3   r   r   r	   r   r
   lenr   )r   rhss     r   __eq__zEdge.__eq__Z   s     #t$ 77366#5$''SVV:K ==CLL(>>S]]* ==CLL( t3s~~#66 ??cnn,r   )Nr   N)__name__
__module____qualname____doc__r   r   r   intr   r.   r4   boolr8    r   r   r   r      sh    
 HJ + + + +"3-+7?}+<3 " B%T %r   r   N)typingr   noder   helpersr   r   r?   r   r   <module>rC      s      !z zr   