o
    .j=                     @   s^   d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ G dd deZdgZd	S )
z BOOLEAN values from :rfc:`5545`.    )AnyClassVar)CaselessDict)Self)JCalParsingError)
Parametersc                	       s   e Zd ZU dZdZee ed< eed< e	dddZ
dd	d
edeeef dB dedef fddZdefddZedefddZededefddZedee fddZddlmZ dedefddZededefddZ  ZS ) vBooleana  Boolean

    Value Name:  BOOLEAN

    Purpose:  This value type is used to identify properties that contain
      either a "TRUE" or "FALSE" Boolean value.

    Format Definition:  This value type is defined by the following
      notation:

    .. code-block:: text

        boolean    = "TRUE" / "FALSE"

    Description:  These values are case-insensitive text.  No additional
      content value encoding is defined for this value type.

    Example:  The following is an example of a hypothetical property that
      has a BOOLEAN value type:

    .. code-block:: python

        TRUE

    .. code-block:: pycon

        >>> from icalendar.prop import vBoolean
        >>> boolean = vBoolean.from_ical('TRUE')
        >>> boolean
        True
        >>> boolean = vBoolean.from_ical('FALSE')
        >>> boolean
        False
        >>> boolean = vBoolean.from_ical('True')
        >>> boolean
        True
    BOOLEANdefault_valueparamsTF)truefalseNr   argskwargsreturnc                   s(   t  j| g|R i |}t||_|S )N)super__new__r   r   )clsr   r   r   self	__class__ K/home/thesage/.local/lib/python3.10/site-packages/icalendar/prop/boolean.pyr   7   s   
zvBoolean.__new__c                 C   s   | rdS dS )uv  Converts a :class:`~icalendar.prop.boolean.vBoolean` to a BOOLEAN property type.

        This class method takes a ``vBoolean``—a Python boolean value—and converts it to an iCalendar BOOLEAN property type, in compliance with :rfc:`5545#section-3.3.2`.

        Returns:
            Either "TRUE" or "FALSE" as bytes, depending on the value of the ``vBoolean``.
        s   TRUEs   FALSEr   r   r   r   r   to_ical>   s   zvBoolean.to_icalc                 C   s   t | S )z<BOOLEAN property type according to :rfc:`5545#section-3.3.2`)boolr   r   r   r   
ical_valueH   s   zvBoolean.ical_valueicalc              
   C   s6   z| j | W S  ty } ztd| |d }~ww )Nz Expected 'TRUE' or 'FALSE'. Got )BOOL_MAP	Exception
ValueError)r   r   er   r   r   	from_icalM   s   zvBoolean.from_icalc                 C   s   | d| dgS )zExamples of vBoolean.TFr   )r   r   r   r   examplesT   s   zvBoolean.examplesr   )VALUEnamec                 C   s   || j  | j t| gS )zBThe jCal representation of this property according to :rfc:`7265`.)r   to_jcalr%   lowerr   )r   r&   r   r   r   r'   ^   s   zvBoolean.to_jcaljcal_propertyc                 C   s6   t ||  t |d t| d | |d t|dS )zParse jCal from :rfc:`7265` to a vBoolean.

        Parameters:
            jcal_property: The jCal property to parse.

        Raises:
            ~error.JCalParsingError: If the provided jCal is invalid.
           r   )r   validate_propertyvalidate_value_typer   r   from_jcal_property)r   r)   r   r   r   	from_jcalb   s   
zvBoolean.from_jcal)__name__
__module____qualname____doc__r
   r   str__annotations__r   r   r   r   dictr   r   bytesr   propertyr   r   classmethodr#   listr$   icalendar.paramr%   r'   r.   __classcell__r   r   r   r   r      s4   
 &
r   N)r2   typingr   r   icalendar.caselessdictr   icalendar.compatibilityr   icalendar.errorr   icalendar.parserr   intr   __all__r   r   r   r   <module>   s    
i