
    iK                     :   d Z ddlZddlmZ ddlZddlmZ ddlmZm	Z	m
Z
 erddlmZmZ ej                            dd d	 g          Zed
             Zed             Zed             Zej                            dg d          ej                            dd d d g          d                         Zej                            ddddej        g          d             Zej                            dg d          Zed             Zed             Zd ZdS )zNThis implemensts RFC 6868.

There are only some changes to parameters needed.
    N)TYPE_CHECKING)Calendar)dquoterfc_6868_escaperfc_6868_unescape)vCalAddressvText	duplicatec                     | S N xs    X/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/tests/test_rfc_6868.py<lambda>r      s    A     c                 N    t          j        |                                           S r   )r   	from_icalto_ical)cals    r   r   r      s    8+=ckkmm+L+L r   c                 f     || j                   }|j        d         d         }|j        dk    sJ dS )zCheck the example from the RFC.r   attendeezGeorge Herman "Babe" RuthN)rfc_6868eventsname)	calendarsr
   r   r   s       r   test_rfc_6868_exampler      s@     Ii011CJqM*5H=7777777r   c                 \     || j                   }|d         j        d         }|dk    sJ dS )z.Check that all examples get decoded correctly.X-PARAMALLz^"
Nr   paramsr   r
   r   params       r   test_all_parametersr%      s8     Ii011C	N!%(EF??????r   c                 \     || j                   }|d         j        d         }|dk    sJ dS )zif a ^ (U+005E) character is followed by any character other than
    the ones above, parsers MUST leave both the ^ and the following
    character in placer   UNKNOWNz^a^ ^asdNr!   r#   s       r   test_unknown_characterr(   '   s>    
 Ii011C	N!),EJr   )textexpected))^ar+   )^^^)z^'")z^^a^bz^a^bmodifyc                     | S r   r   r   s    r   r   r   <   s     r   c                     | dz  S )N
   r   r   s    r   r   r   <   s
    a"f r   c                     d|  dS )NasdzaaA^AAr   r   s    r   r   r   <   s    a r   c                 X    t           ||                     }| ||          k    sJ dS )zCheck unescaping.N)r   )r)   r*   r/   results       r   test_unescaper7   1   s:     vvd||,,FVVH%%%%%%%%r   newline
z
c                 h    |                     t          d|            t          d          | k    sJ dS )zUnescape the newline.linesep^nN)setattrosr   )r8   monkeypatchs     r   test_unescape_newlinerA   D   s;     Iw///T""g------r   )) rB   )r-   r,   )r=   z^^n)zThis text
 has several
 linesz!This text^n has^n several^n lines)zCall me "Harry".zCall me ^'Harry^'.c                     t          |           }||k    sJ |d|            t          t          |                    |k    sJ dS )z=Check that we can escape the content with special characters.z == N)r   r   )r)   r*   escapeds      r   test_escape_rfc_6868rE   W   s`     d##Gh7 > >( > >,W5566(BBBBBBr   c                    t                      }|                    dd           |d         }| |j        d<   |                                                                }t          |           dt          |          z   |v sJ d S )NzX-Paramr4   r   RFC6868zX-PARAM;RFC6868=)r   addr"   r   decodeprintr   )r)   r*   r   r$   icals        r   test_escaping_parametersrL   _   s|    
**CGGIuy>E"EL;;==!!D	$KKKx 0 00D888888r   c                     | j         }t          j        |                                          }||k    sJ |                                |                                k    sJ dS )z0The example file should yield its content again.N)r   r   r   r   )r   r   agains      r   test_encode_example_againrO   j   sV    &Cs{{}}--E%<<<<;;==EMMOO++++++r   )__doc__r?   typingr   pytesticalendar.cal.calendarr   icalendar.parserr   r   r   	icalendarr   r	   markparametrizeparam_duplicater   r%   r(   r7   r<   rA   param_valuesrE   rL   rO   r   r   r   <module>rZ      s/   
 
			              + + + + + + G G G G G G G G G G -,,,,,,,, +))++LLM 
 8 8 8         	 	 {{,,.G.GH & & 	 	& T64$DEE. . FE. {&&  	 	 C C C 9 9 9, , , , ,r   