
    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ADR property of :rfc:`6350`.    )AnyClassVar
NamedTuple)Self)JCalParsingError)
Parameters)DEFAULT_ENCODING
to_unicodec                   f    e Zd ZU dZeed<   	 eed<   	 eed<   	 eed<   	 eed<   	 eed<   	 eed<   d	S )
	AdrFieldszNamed fields for vCard ADR (Address) property per :rfc:`6350#section-6.3.1`.

    Provides named access to the seven address components.
    po_boxextendedstreetlocalityregionpostal_codecountryN)__name__
__module____qualname____doc__str__annotations__     M/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/prop/adr.pyr   r      sr          
 KKKMMM=KKKMMM KKK+LLL##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 )vAdra  vCard ADR (Address) structured property per :rfc:`6350#section-6.3.1`.

    The ADR property represents a delivery address as a single text value.
    The structured type value consists of a sequence of seven address components.
    The component values must be specified in their corresponding position.

    -   post office box
    -   extended address (e.g., apartment or suite number)
    -   street address
    -   locality (e.g., city)
    -   region (e.g., state or province)
    -   postal code
    -   country name (full name)

    When a component value is missing, the associated component separator
    MUST still be specified.

    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 vAdr
            >>> adr = vAdr(("", "", "123 Main St", "Springfield", "IL", "62701", "USA"))
            >>> adr.to_ical()
            b';;123 Main St;Springfield;IL;62701;USA'
            >>> vAdr.from_ical(";;123 Main St;Springfield;IL;62701;USA")
            AdrFields(po_box='', extended='', street='123 Main St', locality='Springfield', region='IL', postal_code='62701', country='USA')
    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 )a8  Initialize ADR with seven fields or parse from vCard format string.

        Parameters:
            fields: Either an AdrFields, tuple, or list of seven strings, one per field,
                    or a vCard format string with semicolon-separated fields
            params: Optional property parameters
           $ADR must have exactly 7 fields, got c              3   4   K   | ]}t          |          V  d S N)r   ).0fs     r   	<genexpr>z vAdr.__init__.<locals>.<genexpr>Y   s(      %=%=c!ff%=%=%=%=%=%=r   N)	
isinstancer   	from_icalr   r"   len
ValueErrorr   r!   )selfr"   r!   s      r   __init__zvAdr.__init__E   s     fc"" 	,^^F++Ffi(( 	? DKK6{{a !UF!U!UVVV#%=%=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)   r3   s     r   
<listcomp>z vAdr.to_ical.<locals>.<listcomp>b   s<    RRRq!!##**+;<<RRRr   ;)icalendar.prop.textr3   r"   joinencoder	   )r/   partsr3   s     @r   r5   zvAdr.to_ical\   sQ     	.-----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 ADR format into an AdrFields named tuple.

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

        Returns:
            AdrFields named tuple with seven field values.
        r   )split_on_unescaped_semicolonr$   r%   z: )icalendar.parserr?   r
   r-   r.   r   )r=   r?   r"   s      r   r,   zvAdr.from_icale   s}     	BAAAAA$--d33v;;!Ls6{{LLdLL   &!!r   otherc                 L    t          |t                    o| j        |j        k    S )zself == other)r+   r   r"   )r/   rA   s     r   __eq__zvAdr.__eq__y   s     %&&F4;%,+FFr   c                 @    | j         j         d| j         d| j         dS )zString representation.(z	, params=))	__class__r   r"   r!   r/   s    r   __repr__zvAdr.__repr__}   s*    .)PPDKPP$+PPPPr   c                     | j         S )z$The address fields as a named tuple.)r"   rH   s    r   
ical_valuezvAdr.ical_value   s     {r   r   )VALUEnamec                     || j                                         | j                                        g}|                    | j                   |S )zBThe jCal representation of this property according to :rfc:`7265`.)r!   to_jcalrL   lowerextendr"   )r/   rM   results      r   rO   zvAdr.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.
        
   zDADR must have 10 elements (name, params, value_type, 7 fields), got    N)start)	r   validate_propertyr-   	enumeratevalidate_value_typer   tupler   from_jcal_property)clsrS   ifields       r   	from_jcalzvAdr.from_jcal   s     	*=#>>>}##",=)), ,   "-"31=== 	E 	EHAu0S!DDDDs-#$$)-88
 
 	
r   c                      | d          gS )zExamples of vAdr.) rb   z123 Main StSpringfieldIL62701USAr   )r]   s    r   exampleszvAdr.examples   s     PQQRRr   r'   ) r   r   r   r   r    r   r   r   r   r   dictr   r[   listr0   bytesr5   staticmethodr,   objectboolrC   rI   propertyrK   icalendar.paramrL   rO   classmethodr   r`   rg   r   r   r   r   r   !   s         > $*M8C=))) )-	) ) S#X%	)c3h$s)+c1I=) ) ) ).8 8 8 8 8 "e "	 " " " \"&GF Gt G G G GQ# Q Q Q Q I    X &%%%%%C D     
d 
t 
 
 
 [
, Sd S S S [S S Sr   r   N)r   typingr   r   r   icalendar.compatibilityr   icalendar.errorr   r@   r   icalendar.parser_toolsr	   r
   r   r   __all__r   r   r   <module>rv      s    " " , , , , , , , , , , ( ( ( ( ( ( , , , , , , ' ' ' ' ' ' ? ? ? ? ? ? ? ?$ $ $ $ $
 $ $ $,GS GS GS GS GS GS GS GST 
r   