
    i                         d Z ddlmZmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZ  G d de          Z G d	 d
          Zdd
gZdS )zN property from :rfc:`6350`.    )AnyClassVar
NamedTuple)Self)JCalParsingError)
Parameters)DEFAULT_ENCODING
to_unicodec                   N    e Zd ZU dZeed<   	 eed<   	 eed<   	 eed<   	 eed<   dS )NFieldszNamed fields for vCard N (Name) property per :rfc:`6350#section-6.2.2`.

    Provides named access to the five name components.
    familygiven
additionalprefixsuffixN)__name__
__module____qualname____doc__str__annotations__     K/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/prop/n.pyr   r      sW          
 KKK0JJJOOOKKKKKKr   r   c                   h   e Zd ZU dZdZee         ed<   eed<   e	ed<   	 dde
eef         dz  deedf         ee         z  ez  e	z  fdZd	efd
Zedeez  d	e	fd            Zded	efdZd	efdZed	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e         fd            ZdS )vNa
  vCard N (Name) structured property per :rfc:`6350#section-6.2.2`.

    The N property represents a person's name.
    It consists of a single structured text value.
    Each component in the structure may have multiple values, separated by commas.

    The structured property value corresponds, in sequence, to the following fields:

    -   family names (also known as surnames)
    -   given names
    -   additional names
    -   honorific prefixes
    -   honorific suffixes

    Semicolons are field separators and are NOT escaped.
    Commas and backslashes within field values ARE escaped per :rfc:`6350`.

    Examples:

        .. code-block:: pycon

            >>> from icalendar.prop import vN
            >>> n = vN(("Doe", "John", "M.", "Dr.", "Jr.,M.D.,A.C.P."))
            >>> n.to_ical()
            b'Doe;John;M.;Dr.;Jr.\\,M.D.\\,A.C.P.'
            >>> vN.from_ical(r"Doe;John;M.;Dr.;Jr.\,M.D.\,A.C.P.")
            NFields(family='Doe', given='John', additional='M.', prefix='Dr.', suffix='Jr.,M.D.,A.C.P.')
    TEXTdefault_valueparamsfieldsN.c                P   t          |t                    r|                     |          }t          |t                    r|| _        nJt          |          dk    rt          dt          |                     t          d |D              | _        t          |          | _        dS )a2  Initialize N with five fields or parse from vCard format string.

        Parameters:
            fields: Either an NFields, tuple, or list of five strings, one per field,
                    or a vCard format string with semicolon-separated fields
            params: Optional property parameters
           "N must have exactly 5 fields, got c              3   4   K   | ]}t          |          V  d S N)r   ).0fs     r   	<genexpr>zvN.__init__.<locals>.<genexpr>S   s(      #;#;qCFF#;#;#;#;#;#;r   N)	
isinstancer   	from_icalr   r    len
ValueErrorr   r   )selfr    r   s      r   __init__zvN.__init__?   s     fc"" 	,^^F++Ffg&& 	= DKK6{{a !Sc&kk!S!STTT!#;#;F#;#;#;<DK ((r   returnc                     ddl m fd| j        D             }d                    |                              t
                    S )z6Generate vCard format with semicolon-separated fields.r   )vTextc                 z    g | ]7} |                                                               t                    8S r   )to_icaldecoder	   )r&   r'   r1   s     r   
<listcomp>zvN.to_ical.<locals>.<listcomp>Z   s<    RRRq!!##**+;<<RRRr   ;)icalendar.prop.textr1   r    joinencoder	   )r-   partsr1   s     @r   r3   z
vN.to_icalV   sO    ------RRRRdkRRRxx%%&6777r   icalc                     ddl m} t          |           }  ||           }t          |          dk    r"t	          dt          |           d|            t          | S )zParse vCard N format into an NFields named tuple.

        Parameters:
            ical: vCard format string with semicolon-separated fields

        Returns:
            NFields named tuple with five field values.
        r   )split_on_unescaped_semicolonr"   r#   z: )icalendar.parserr=   r
   r+   r,   r   )r;   r=   r    s      r   r*   zvN.from_ical]   sv     	BAAAAA$--d33v;;!W#f++WWQUWWXXXr   otherc                 L    t          |t                    o| j        |j        k    S )zself == other)r)   r   r    )r-   r?   s     r   __eq__z	vN.__eq__o   s     %$$D)DDr   c                 @    | j         j         d| j         d| j         dS )zString representation.(z	, params=))	__class__r   r    r   r-   s    r   __repr__zvN.__repr__s   s*    .)PPDKPP$+PPPPr   c                     | j         S )z!The name fields as a named tuple.)r    rF   s    r   
ical_valuezvN.ical_valuew   s     {r   r   )VALUEnamec                     || j                                         | j                                        g}|                    | j                   |S )zBThe jCal representation of this property according to :rfc:`7265`.)r   to_jcalrJ   lowerextendr    )r-   rK   results      r   rM   z
vN.to_jcal~   sC    ++--tz/?/?/A/ABdk"""r   jcal_propertyc                 l   t          j        ||            t          |          dk    rt          dt          |                     t          |dd         d          D ]!\  }}t          j        |t
          | |           " | 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.
           zAN must have 8 elements (name, params, value_type, 5 fields), got    N)start)	r   validate_propertyr+   	enumeratevalidate_value_typer   tupler   from_jcal_property)clsrQ   ifields       r   	from_jcalzvN.from_jcal   s     	*=#>>>}""",=)), ,   "-"31=== 	E 	EHAu0S!DDDDs-#$$)-88
 
 	
r   c                      | d          gS )zExamples of vN.)DoeJohnzM.zDr.zJr.r   )r[   s    r   exampleszvN.examples   s     78899r   r%   ) r   r   r   r   r   r   r   r   r   r   dictr   rY   listr.   bytesr3   staticmethodr*   objectboolrA   rG   propertyrI   icalendar.paramrJ   rM   classmethodr   r^   rb   r   r   r   r   r      s         : $*M8C=)))OOO )-	) ) S#X%	)c3h$s)+c1G;) ) ) ).8 8 8 8 8  e         \ "EF Et E E E EQ# Q Q Q Q G    X &%%%%%C D     
d 
t 
 
 
 [
, :d : : : [: : :r   r   N)r   typingr   r   r   icalendar.compatibilityr   icalendar.errorr   r>   r   icalendar.parser_toolsr	   r
   r   r   __all__r   r   r   <module>rq      s    " " , , , , , , , , , , ( ( ( ( ( ( , , , , , , ' ' ' ' ' ' ? ? ? ? ? ? ? ?    j   $A: A: A: A: A: A: A: A:H d
r   