
    mh                     .    d dl mZ  G d de          ZdS )   )basec                      e Zd ZdZdZdZdZi ZdZdZ	dZ
dZdZdZg Zd Zedd            Zed             Zed             Zed	             Zed
             Zed             Zed             Zedd            Zed             ZdS )Behaviora  
    Behavior (validation, encoding, and transformations) for vobjects.

    Abstract class to describe vobject options, requirements and encodings.

    Behaviors are used for root components like VCALENDAR, for subcomponents
    like VEVENT, and for individual lines in components.

    Behavior subclasses are not meant to be instantiated, all methods should
    be classmethods.

    @cvar name:
        The uppercase name of the object described by the class, or a generic
        name if the class defines behavior for many objects.
    @cvar description:
        A brief excerpt from the RFC explaining the function of the component or
        line.
    @cvar versionString:
        The string associated with the component, for instance, 2.0 if there's a
        line like VERSION:2.0, an empty string otherwise.
    @cvar knownChildren:
        A dictionary with uppercased component/property names as keys and a
        tuple (min, max, id) as value, where id is the id used by
        L{registerBehavior}, min and max are the limits on how many of this child
        must occur.  None is used to denote no max or no id.
    @cvar quotedPrintable:
        A boolean describing whether the object should be encoded and decoded
        using quoted printable line folding and character escaping.
    @cvar defaultBehavior:
        Behavior to apply to ContentLine children when no behavior is found.
    @cvar hasNative:
        A boolean describing whether the object can be transformed into a more
        Pythonic object.
    @cvar isComponent:
        A boolean, True if the object should be a Component.
    @cvar sortFirst:
        The lower-case list of children which should come first when sorting.
    @cvar allowGroup:
        Whether or not vCard style group prefixes are allowed.
     FNc                 .    d}t          j        |          )Nz4Behavior subclasses are not meant to be instantiated)r   VObjectError)selferrs     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/vobject/behavior.py__init__zBehavior.__init__:   s    D$$$    c                    | j         s0|j        )d                    |          }t          j        |          t          |t          j                  r|                     |||          S t          |t          j                  rFi }|	                                D ]P}|
                    ||          s dS |j                                        }|                    |d          dz   ||<   Q| j                                        D ]\  }}	|                    |d          |	d         k     r;|r6d}
t          j        |
                    | j        |	d         |                     dS |	d         r[|                    |d          |	d         k    r;|r6d}
t          j        |
                    | j        |	d         |                     dS dS d	                    |          }t          j        |          )
a	  Check if the object satisfies this behavior's requirements.

        @param obj:
            The L{ContentLine<base.ContentLine>} or
            L{Component<base.Component>} to be validated.
        @param raiseException:
            If True, raise a L{base.ValidateError} on validation failure.
            Otherwise return a boolean.
        @param complainUnrecognized:
            If True, fail to validate if an uncrecognized parameter or child is
            found.  Otherwise log the lack of recognition.

        Nz7{0} has a group, but this object doesn't support groupsF    r   z,{0} components must contain at least {1} {2}z/{0} components cannot contain more than {1} {2}Tz%{0} is not a Component or Contentline)
allowGroupgroupformatr   r   
isinstanceContentLinelineValidate	ComponentgetChildrenvalidatenameuppergetknownChildrenitemsValidateError)clsobjraiseExceptioncomplainUnrecognizedr
   countchildr   keyvalms              r   r   zBehavior.validate>   s    ~ 	)#)"7KRRSVWWC#C(((c4+,, 	)##C9MNNNT^,, 	)E** 5 5~~n6JKK ! 55z''))#iia0014d-3355 
! 
!S99S!$$s1v--% SJ"038SVS1Q1QRRR 55q6 !eiiQ//#a&88% RM"0#(CFC1P1PQQQ 5549@@EEC#C(((r   c                     dS )z=Examine a line's parameters and values, return True if valid.T )r   liner!   r"   s       r   r   zBehavior.lineValidatei   s	     tr   c                 &    |j         r	d|_         d S d S )Nr   encodedr   r*   s     r   decodezBehavior.decoden   s!    < 	DLLL	 	r   c                 &    |j         s	d|_         d S d S )Nr   r,   r.   s     r   encodezBehavior.encodes   s!    | 	DLLL	 	r   c                     |S )z
        Turn a ContentLine or Component into a Python-native representation.

        If appropriate, turn dates or datetime strings into Python objects.
        Components containing VTIMEZONEs turn into VtimezoneComponents.

        r)   r   r    s     r   transformToNativezBehavior.transformToNativex   s	     
r   c                 *    t          j        d          )z/
        Inverse of transformToNative.
        zNo transformFromNative defined)r   NativeErrorr3   s     r   transformFromNativezBehavior.transformFromNative   s    
 ?@@@r   c                     dS )z7Generate any required information that don't yet exist.Nr)   r3   s     r   generateImplicitParametersz#Behavior.generateImplicitParameters   s	     	r   Tc                     |                      |           |r|                     |d           |j        r|                                }d}n|}d}t	          j        |||          }	|r|                                 |	S )a  
        Set implicit parameters, do encoding, return unicode string.

        If validate is True, raise VObjectError if the line doesn't validate
        after implicit parameters are generated.

        Default is to call base.defaultSerialize.

        T)r!   F)r9   r   isNativer7   r   defaultSerializer4   )
r   r    buf
lineLengthr   argskwargstransformedundoTransformouts
             r   	serializezBehavior.serialize   s     	&&s+++ 	3LLTL222< 	"1133K MMK!M#KjAA 	$!!###
r   c                     |j         S )z9return the representation of the given content line value)valuer.   s     r   	valueReprzBehavior.valueRepr   s     zr   )FF)T)__name__
__module____qualname____doc__r   descriptionversionStringr   quotedPrintabledefaultBehavior	hasNativeisComponentr   forceUTC	sortFirstr   classmethodr   r   r/   r1   r4   r7   r9   rD   rG   r)   r   r   r   r      sh       ' 'P DKMMOOIKJHI% % % () () () [()T   [   [   [   [ A A [A   [    [6   [  r   r   N)r   r   objectr   r)   r   r   <module>rV      sU         i i i i iv i i i i ir   