o
    ÌÄ.j¸  ã                   @   sr   e efZd ZeeB Zddedefdd„Zddedefdd„Zefdee	B e B dee e B e	B fd	d
„Z
g d¢ZdS )úutf-8ÚvalueÚreturnc                 C   óH   t | tƒr| S t | tƒr"z|  |¡W S  ty!   |  dd¡ Y S w | S )zèConverts 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   Úencoding© r   úK/home/thesage/.local/lib/python3.10/site-packages/icalendar/parser_tools.pyÚfrom_unicode   s   


ÿr   ú	utf-8-sigc                 C   r   )z¸Converts 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   r   r   r   Ú
to_unicode   s   

ÿr   Údatac                 C   sT   t | tƒr
|  |¡S t | tƒrtttt|  ¡ ƒƒƒS t | tt	fƒr(ttt| ƒƒS | S )z±Encode 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   r   r   r   r   -   s   


r   )Ú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   r   r   Ú<module>   s    ÿ
ÿ
þ