
    in                     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                       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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        Q/root/projects/butler/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   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_icalc   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.examplesj   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&   lowerint)r   r'   s     r   r)   zvInt.to_jcalq   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_jcalu   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   r0   r+   )r   r3   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   classmethodr   r#   listr   r%   icalendar.paramr&   r)   r2   r+   r5   __classcell__)r   s   @r   r
   r
      s        J JX $-M8C=,,,<@   DcNT$9      
) ) ) ) ) BY B B B [B 'd ' ' ' [' &%%%%%LC LD L L L L 
d 
t 
 
 
 [
  S S    [    r   r
   N)r9   typingr   r   icalendar.compatibilityr   icalendar.errorr   icalendar.parserr   icalendar.parser_toolsr   r+   r
   __all__ r   r   <module>rH      s    " "                 ( ( ( ( ( ( , , , , , , ' ' ' ' ' ' , , , , , ,C C C C C3 C C CL (r   