
    F2j                     l    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e          ZdgZd	S )
zINT values from :rfc:`5545`.    )AnyClassVar)Self)JCalParsingError)
Parameters)	ICAL_TYPEc                   2    e Zd ZU dZdZee         ed<   eed<   ddde	ee
f         dz  f fdZdefd	Zedefd
            Zedefd            Zedee         fd            ZddlmZ dedefdZededefd            Zede
defd            Z xZS )vInta  Integer

    Value Name:
        INTEGER

    Purpose:
        This value type is used to identify properties that contain a
        signed integer value.

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

        .. code-block:: text

            integer    = (["+"] / "-") 1*DIGIT

    Description:
        If the property permits, multiple "integer" values are
        specified by a COMMA-separated list of values.  The valid range
        for "integer" is -2147483648 to 2147483647.  If the sign is not
        specified, then the value is assumed to be positive.

    The ``__new__`` method creates a vInt instance:

    Parameters:
        value: Integer value to encode. Can be positive or negative within
            the range -2147483648 to 2147483647.
        params: Optional parameter dictionary for the property.

    Returns:
        vInt instance

    Examples:

        .. code-block:: text

            1234567890
            -1234567890
            +1234567890
            432109876

        .. code-block:: pycon

            >>> from icalendar.prop import vInt
            >>> integer = vInt.from_ical('1234567890')
            >>> integer
            1234567890
            >>> integer = vInt.from_ical('-1234567890')
            >>> integer
            -1234567890
            >>> integer = vInt.from_ical('+1234567890')
            >>> integer
            1234567890
            >>> integer = vInt.from_ical('432109876')
            >>> integer
            432109876

        Create a PRIORITY property (1 = highest priority):

        .. code-block:: pycon

            >>> priority = vInt(1)
            >>> priority
            1
            >>> priority.to_ical()
            b'1'

        Create SEQUENCE property (for versioning):

        .. code-block:: pycon

            >>> sequence = vInt(3)
            >>> sequence.to_ical()
            b'3'
    INTEGERdefault_valueparamsNr   c                j     t                      j        | g|R i |}t          |          |_        |S )N)super__new__r   r   )clsr   argskwargsself	__class__s        ^/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/icalendar/prop/integer.pyr   zvInt.__new__[   s<    uwws4T444V44 ((    returnc                 F    t          |                               d          S )Nzutf-8)strencoder   s    r   to_icalzvInt.to_ical`   s    4yy(((r   c                      t          |           S )z<INTEGER property type according to :rfc:`5545#section-3.3.8`)intr   s    r   
ical_valuezvInt.ical_valuec   s     4yyr   icalc                 d    	  | |          S # t           $ r}t          d|           |d }~ww xY w)NzExpected int, got: )	Exception
ValueError)r   r"   es      r   	from_icalzvInt.from_icalh   sR    	B3t99 	B 	B 	B9499::A	Bs   
 
/*/c                 >    t          d          t          d          gS )zExamples of vInt.i  i)r
   )r   s    r   exampleszvInt.exampleso   s     T

DII&&r   r   )VALUEnamec                     || j                                         | j                                        t	          |           gS )zBThe jCal representation of this property according to :rfc:`7265`.)r   to_jcalr*   lowerr    )r   r+   s     r   r-   zvInt.to_jcalv   s3    dk))++TZ-=-=-?-?TKKr   jcal_propertyc                     t          j        ||            t          j        |d         t          | d            | |d         t	          j        |                    S )zParse jCal from :rfc:`7265`.

        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/   s     r   	from_jcalzvInt.from_jcalz   sb     	*=#>>>,]1-=sCKKKs!0??
 
 
 	
r   valuec                 N    t          j        |t          |             | |          S )zwParse a jCal value for vInt.

        Raises:
            ~error.JCalParsingError: If the value is not an int.
        )r   r3   r    )r   r6   s     r   parse_jcal_valuezvInt.parse_jcal_value   s'     	,UC===s5zzr   )__name__
__module____qualname____doc__r   r   r   __annotations__r   dictr   r   bytesr   propertyr    r!   classmethodr   r'   listr   r)   icalendar.paramr*   r-   r5   r8   __classcell__)r   s   @r   r
   r
      s        J JX $-M8C=,,,<@   DcNT$9      
) ) ) ) ) C    X BY B B B [B 'd ' ' ' [' &%%%%%LC LD L L L L 
d 
t 
 
 
 [
  S S    [    r   r
   N)r<   typingr   r   icalendar.compatibilityr   icalendar.errorr   icalendar.parserr   icalendar.parser_toolsr   r    r
   __all__ r   r   <module>rL      s    " "                 ( ( ( ( ( ( , , , , , , ' ' ' ' ' ' , , , , , ,H H H H H3 H H HV (r   