
    i                         e efZd Zeez  Zd
dedefdZddedefdZefdee	z  e z  dee e         z  e	z  fdZ
g dZd	S )utf-8valuereturnc                     t          | t                    r| S t          | t                    r<	 |                     |          S # t          $ r |                     dd          cY S w xY w| S )zConverts a value to bytes, even if it is already bytes.

    Parameters:
        value: The value to convert.
        encoding: The encoding to use in the conversion.

    Returns:
        The bytes representation of the value.
    r   replace)
isinstancebytesstrencodeUnicodeEncodeErrorr   encodings     Q/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/parser_tools.pyfrom_unicoder      s     % % 	4<<)))! 	4 	4 	4<<33333	4    A  A&%A&	utf-8-sigc                     t          | t                    r| S t          | t                    r<	 |                     |          S # t          $ r |                     dd          cY S w xY w| S )zConverts a value to Unicode, even if it is already a Unicode string.

    Parameters:
        value: The value to convert.
        encoding: The encoding to use in the conversion.
    r   r   )r   r	   r   decodeUnicodeDecodeErrorr   s     r   
to_unicoder      s     % % 	8<<)))! 	8 	8 	8<<Y77777	8 r   datac           	         t          | t                    r|                     |          S t          | t                    rAt          t	          t
          t          |                                                               S t          | t          t          f          r"t          t	          t
          |                     S | S )zEncode all datastructures to the given encoding.

    Currently Unicode strings, dicts, and lists are supported.

    Parameters:
        data: The datastructure to encode.
    )
r   r	   r
   dictmapdata_encodeiteritemslisttuple)r   r   s     r   r   r   -   s     $ %{{8$$$$ :CT$**,,%7%788999$u&& ,CT**+++K    )DEFAULT_ENCODING	ICAL_TYPESEQUENCE_TYPESr   r   r   N)r   )r   )r   r   r"   r    r	   r   r!   r   r   r   r   __all__ r   r   <module>r%      s    %K	 	     * i #    & -= 
d
T
!
T%[4   (  r   