
    fg                        	 d dl mZ n# e$ r d dlZY nw xY wd dlZd dlZ	 d dlZn# e$ r dZY nw xY wd dlmZ d dlm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Zd dlZeduZerej         ej        d	          gZd
 gZdgZng Zg Zg Z G d d          Z ee          j        Zedz  Zedz  Zedz  Z  ej!        d          d             Z" ej!        d          d             Z# ej!        d          d             Z$ ej!        e ej%        d	          ej&         ej'        d	          gz             d             Z ej!        ed d gz             d             Z(dZ)d  ej*        e+                                e+                                e +                                          D             Z, ej!        e,          d             Z-d e+                                D             Z. ej!        e.          d             Z/ ej!                    d              Z0 ej!                    d!             Z1 ej!                    d"             Z2 ej!                    d#             Z3 ej!                    d$             Z4e4Z5 ej!                    d%             Z6 ej!                    d&             Z7 ej!                    d'             Z8 ej!        d          d(             Z ej!        ed)gz             d*             Z9 ej!                    d+             Z: ej!                    d,             Z;d- Z< G d. d/ej%                  Z=d0 Z>d1 Z? ej!                    d2             Z@dS )3    )zoneinfoN)datetime)tz)	ComponentCalendartzp)TZP)PathUTCc                 P    t          j        |                              |           S N)pytztimezonelocalizedttznames     \/var/www/dev/btcams2024/python_venv/lib/python3.11/site-packages/icalendar/tests/conftest.py<lambda>r      s    4=0099"==     r   c                   R    e Zd ZdZdefdZd Zd Zd Zd Z	d Z
ed	             Zd
S )
DataSourcezFA collection of parsed ICS elements (e.g calendars, timezones, events)data_source_folderc                 "    || _         || _        d S r   )_parser_data_source_folder)selfr   parsers      r   __init__zDataSource.__init__&   s    #5   r   c                 H    d | j                                         D             S )z(Return all the files that could be used.c                 V    g | ]&}|j                                         d k    |j        'S ).ics)suffixlowerstem).0ps     r   
<listcomp>z#DataSource.keys.<locals>.<listcomp>,   s1    aaa1ahnnFVFVZ`F`F`F`F`F`r   )r   iterdirr   s    r   keyszDataSource.keys*   s%    aa 8 @ @ B Baaaar   c                    |                     d          r|}|dd         }n|dz   }| j        |z  }|                                st          | d          |                    d          5 }|                                }ddd           n# 1 swxY w Y   |                     |          }t          |t                    s||_	        || j
        |<   |S )z;Parse a file and return the result stored in the attribute.r#   Nz does not exist.rb)endswithr   is_fileAttributeErroropenreadr   
isinstancelistraw_ics__dict__)r   	attributesource_filesource_pathfr7   sources          r   __getitem__zDataSource.__getitem__.   s   f%% 	-#K!#2#II#f,K.<""$$ 	C K!A!A!ABBBd## 	qffhhG	 	 	 	 	 	 	 	 	 	 	 	 	 	 	g&&&$'' 	%$FN#)i s   -BBBc                 l    |                     d          r
|dd         }||                                 v S )zkey in self.keys()r#   Nr.   )r0   r,   r   keys     r   __contains__zDataSource.__contains__@   s6    << 	crc(Cdiikk!!r   c                     | |         S r    r@   s     r   __getattr__zDataSource.__getattr__F   s    Cyr   c                 *    t          | j                  S r   )reprr8   r+   s    r   __repr__zDataSource.__repr__I   s    DM"""r   c                 @                            j         fd          S )z'Return a list of all components parsed.c                 2                         | d          S )NT)multiple)r   )datar   s    r   r   z%DataSource.multiple.<locals>.<lambda>O   s    T\\RVae\EfEf r   )	__class__r   r+   s   `r   rK   zDataSource.multipleL   s&     ~~d68f8f8f8fgggr   N)__name__
__module____qualname____doc__r   r    r,   r>   rB   rE   rH   propertyrK   rD   r   r   r   r   $   s        PP6$ 6 6 6 6b b b  $" " "  # # # h h Xh h hr   r   	calendars	timezoneseventsmodulescopec                 J    t          t          t          j        j                  S r   )r   CALENDARS_FOLDER	icalendarr   	from_icalr   s    r   rS   rS   V       &	(:(DEEEr   c                 J    t          t          t          j        j                  S r   )r   TIMEZONES_FOLDERr[   Timezoner\   r   s    r   rT   rT   Z   r]   r   c                 J    t          t          t          j        j                  S r   )r   EVENTS_FOLDERr[   Eventr\   r   s    r   rU   rU   ^   s    mY_%>???r   )paramsc                     | j         S r   paramrequestr	   s     r   utcrj   b       
 =r   c                 R    |                      t          j        |                    S N)tzinfo)replacer   gettzr   s     r   r   r   j   s    rzz&)9)9z:: r   c                 R    |                      t          j        |                    S rm   )ro   r   ZoneInfor   s     r   r   r   k   s    rzz):6)B)BzCC r   c                     | j         S r   rf   rh   s     r   in_timezonert   i   rk   r   )zbig_bad_calendar.icszissue_104_broken_calendar.icszsmall_bad_calendar.icsz multiple_calendar_components.icszpr_480_summary_with_colon.icszparsing_error_in_UTC_offset.icszparsing_error.icsc                 8    g | ]}|j         t          v|j         S rD   )nameICS_FILES_EXCLUDE)r'   files     r   r)   r)   w   s2       y))) 	I)))r   c                     |j         }t          d|           |||fD ]}||v r
||         c S t          d| d          )zAn example ICS file.zexample file:zCould not find file .)rg   print
ValueError)r	   rS   rT   rU   ri   ics_filerL   s          r   r}   r}   |   sk     }H	/8$$$9f, " "t>!!! 
7H777
8
88r   c                 4    g | ]}d t          |          v |S )zfuzz-testcase)str)r'   rA   s     r   r)   r)      s(    
T
T
T33s888S8S38S8S8Sr   c                     | j         S )zClusterfuzz calendars.rf   )ri   s    r   fuzz_v1_calendarr      s     =r   c               #      K   dt           j        j        j        d<   dV  t           j        j        j                            d           dS )zMap x_sometime to timetimez
X-SOMETIMEN)r[   caltypes_factory	types_mappoprD   r   r   
x_sometimer      sF       ;AIM),7	EEEM)--l;;;;;r   c                  (    t          j                    S )zReturn a new component factory.)r[   ComponentFactoryrD   r   r   factoryr      s     %'''r   c               #   V   K   dt           j        _        d V  dt           j        _        d S )NTF)r[   
vUTCOffsetignore_exceptionsrD   r   r   vUTCOffset_ignore_exceptionsr      s+      -1I*	EEE-2I***r   c                 0    t                      }d|_        |S )zReturn an event component.VEVENTr   rv   r	   cs     r   event_componentr      s     	AAFHr   c                 "    t                      }|S )Return an empty component.)r   r   s     r   r   r      s     	AHr   c                 0    t                      }d|_        |S )r   	VCALENDARr   r   s     r   calendar_componentr      s     	AAFHr   c                     t          d          }d|_        |                    ddd           |                    dd	d           |                    |           |S )
zBReturn an event with some values and add it to calendar_component.zA brief history of time)summaryr   dtend20000102T000000r   )encodedtstart20000101T000000)r   rv   addadd_component)r   r   es      r   filled_event_componentr      sg     	3444AAFEE'$QE///EE)&qE111$$Q'''Hr   c                 ,    t                      }d|d<   |S )NzChair, Table, "Room: 42"	resources)r   r   s     r   calendar_with_resourcesr      s    

A/AkNHr   c              #   j   K   t          j        |            t           V  t          j                     dS )zThe timezone provider.N)_tzpuseuse_default)tzp_names    r   r	   r	      s6       	HX
JJJr   r   c                 .    t          | j                  }|S )zThis is annother timezone provider.

    The purpose here is to cross test: pytz <-> zoneinfo.
    tzp as parameter makes sure we test the cross product.
    )r
   rg   rh   s     r   	other_tzpr      s     gm

CJr   c                 2    |                                  sJ dS )z+Skip tests that are not running under pytz.N)	uses_pytzr   s    r   	pytz_onlyr      s     ==??r   c                 2    |                                  sJ dS )z/Skip tests that are not running under zoneinfo.N)uses_zoneinfo)r	   ri   r   s      r   zoneinfo_onlyr      s"     r   c                     d| j         v r]t          dgz   }d| j         v rdg}d| j         v rt          }d| j         v rd| j         v r
J d            |                     d|d           dS dS )	zParametrize without skipping:

    tzp_name will be parametrized according to the use of
    - pytz_only
    - zoneinfo_only

    See https://docs.pytest.org/en/6.2.x/example/parametrize.html#deferring-the-setup-of-parametrized-resources
    r   r   r   r   z,Use pytz_only or zoneinfo_only but not both!rV   rW   N)fixturenamesPYTZ_TZPparametrize)metafunc	tzp_namess     r   pytest_generate_testsr      s     X***
|+	h333#I(/// I#x'<<<PXPeAeAeAe  iWAeAeAeZ(CCCCC +*r   c                       e Zd ZdZd ZdS )DoctestZoneInfoz+Constent ZoneInfo representation for tests.c                 2    dt          | j                   dS )NzZoneInfo(key=))rG   rA   r+   s    r   rH   zDoctestZoneInfo.__repr__   s    0tDH~~0000r   N)rN   rO   rP   rQ   rH   rD   r   r   r   r      s)        551 1 1 1 1r   r   c                    t          | t                    r|                     d          } t          t	          |                                                               dd                              dd                     dS )zdoctest printzUTF-8z

N)r5   bytesdecoder{   r   stripro   )objs    r   doctest_printr     si    #u "jj!!	#c((..


"
"64
0
0
8
8t
D
DEEEEEr   c                 <    | dk    rt           S t          | g|R i |S )zIReplace the import mechanism to skip the whole doctest if we import pytz.r   )r   
__import__)rv   argskws      r   doctest_importr     s.    v~~d(T(((R(((r   c                     |                      t          j        dt                     |                     t          dt
                     ddlm} |                     |dt          j        d                     dt          iS )z,Modify the environment to make doctests run.r   rr   r   )ZONEINFOrj   r   r{   )
setitemsysmodulesr   setattrr   icalendar.timezone.zoneinfor   rr   r   )monkeypatchr   s     r   env_for_doctestr     sz     Z:::*o>>>444444%):5)A)ABBB r   )A	backportsr   ImportErrorpytestr[   r   r   dateutilr   icalendar.calr   r   icalendar.timezoner	   r   r
   pathlibr   	itertoolsr   HAS_PYTZrj   r   PYTZ_UTCPYTZ_IN_TIMEZONEr   r   __file__parentHERErZ   r_   rb   fixturerS   rT   rU   rr   r   rp   rt   rw   chainr*   	ICS_FILESr}   FUZZ_V1r   r   r   r   r   r   compr   r   r   r   r   r   r   r   r   r   r   rD   r   r   <module>r      sC  """""""   OOOOO     KKKK   DDD             - - - - - - - - * * * * * * " " " " " "           



t eH
 	>= xHHHH+h +h +h +h +h +h +h +hZ tH~~+% +% xhF F  F hF F  F h@ @  @ xHeFBHUOO#     	  '::CC+     	 
 
 IO$,,..0@0H0H0J0JMLaLaLcLcdd  	
 y!!!9 9 "!9 U
T*2244
T
T
Tw   
 < < < ( ( (
 3 3 3       	         h    x:,.///  0/   
   
D D D&1 1 1 1 1h' 1 1 1F F F) ) )     s   	 	& 00