
    i                       U d Z ddlmZ ddlm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 dd	lmZ dd
lmZ 	 ddlmZ n# e$ r dZY nw xY werddlmZmZ  ej        d          Z eedd          Zded<   edn e
e          j        Z d(dZ!d)dZ"d*dZ# ee$          Z%ded<   d+dZ& e&ej'                   d,d"Z(d-d&Z)g d'Z*dS ).zThis module identifies timezones.

Normally, timezones have ids.
This is a way to access the ids if you have a
datetime.tzinfo object.
    )annotations)defaultdict)datetimetimezone)Path)TYPE_CHECKING)tz)equivalent_timezone_ids_result)WINDOWS_TO_OLSON)is_date)tzwinN)datetimetzinfoUTC	_filename
str | NoneDATEUTIL_UTC_PATHr   tzinfo | Nonereturn
tuple[str]c                   | dS t          | t                    rt           | j        d                    S t	          | d          rt          | j                  S t	          | d          rt          | j                  S t          | t          j                  rt          | j	                  S t          | t          j
                  rt          | j                  S t          St          | t                    r>t          j        | j                  }|t          |          S t          | j                  S t	          | d          rt           | j        }|                    t'          t                               rCt'          t)          |                              t                               }t          |          S t          |          S t          | t          j                  rt          d          S dS )ap  Get several timezone ids if we can identify the timezone.

    >>> import zoneinfo
    >>> from icalendar.timezone.tzid import tzids_from_tzinfo
    >>> tzids_from_tzinfo(zoneinfo.ZoneInfo("Arctic/Longyearbyen"))
    ('Arctic/Longyearbyen', 'Atlantic/Jan_Mayen', 'Europe/Berlin', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Oslo', 'Europe/Stockholm', 'Europe/Vienna')
    >>> from dateutil.tz import gettz
    >>> tzids_from_tzinfo(gettz("Europe/Berlin"))
    ('Europe/Berlin', 'Arctic/Longyearbyen', 'Atlantic/Jan_Mayen', 'Europe/Budapest', 'Europe/Copenhagen', 'Europe/Oslo', 'Europe/Stockholm', 'Europe/Vienna')

    N zonekeyr   r   )
isinstancer   get_equivalent_tzidstznamehasattrr   r   r
   
_tzicalvtz_tzidtzstr_s_tzwinr   get_nameDATEUTIL_ZONEINFO_PATHr   
startswithstrr   relative_totzutc)r   olsonpathtzids       R/root/projects/butler/venv/lib/python3.11/site-packages/icalendar/timezone/tzid.pytzids_from_tzinfor0   $   s    ~r&(## 9#MFM$$7$7888vv 1#FK000vu 0#FJ///&"-(( 2#FL111&"(## /#FI...j88 $V\22'...#FL111v{## .!-#Ds#9::;; 24::112HIIJJ+D111'---&"(## +#E***2    c                D    t          |           }d|v rdS |sdS |d         S )zRetrieve the timezone id from the tzinfo object.

    Some timezones are equivalent.
    Thus, we might return one ID that is equivalent to others.
    r   Nr   )r0   )r   tzidss     r/   tzid_from_tzinfor4   O   s5     f%%E~~u t8Or1   dtr   c                Z    t          | j                  }||                                 S |S )z2Retrieve the timezone id from the datetime object.)r4   r   r   )r5   r.   s     r/   tzid_from_dtr7   ]   s)    BI&&D|yy{{Kr1   zdict[str, set[str]]_EQUIVALENT_IDSvaluetuple | dict | setc                   t          | t                    r'| D ]"}t          |                             |            #dS t          | t                    rt          | d                    dS t          | t                    r(|                                 D ]}t          |           dS t          d| j	        j
         d|           )zThis adds equivalent ids/

    As soon as one timezone implementation used claims their equivalence,
    they are considered equivalent.
    Have a look at icalendar.timezone.equivalent_timezone_ids.
       z!Expected tuple, dict or set, not z: N)r   setr8   updatetuple_add_equivalent_idsdictvalues	TypeError	__class____name__)r9   r.   value2s      r/   r@   r@   h   s     % 
 	0 	0DD!((////	0 	0	E5	!	! 
E!H%%%%%	E4	 	  
llnn 	( 	(F''''	( 	( U0HUUEUU
 
 	
r1   r.   r)   c                    t                               | t                                }| ft          t	          || hz
                      z   S )z8This returns the tzids which are equivalent to this one.)r8   r%   r=   r?   sorted)r.   idss     r/   r   r      s>    


dCEE
*
*C7U6#,//0000r1   tdatetime | time | date | tzinfoboolc                    t          |           rdS t          | d          rt          |           nt          |           }|dk    S )zWhether this date is in UTC.Fr   r   )r   r   r7   r4   )rJ   r.   s     r/   is_utcrN      sF    qzz u%a22K<???8H8K8KD5=r1   )rN   r7   r4   r0   )r   r   r   r   )r   r   r   r   )r5   r   r   r   )r9   r:   )r.   r)   r   r   )rJ   rK   r   rL   )+__doc__
__future__r   collectionsr   r   r   r   r   pathlibr   typingr	   dateutil.tzr
   icalendar.timezoner   #icalendar.timezone.windows_to_olsonr   icalendar.toolsr   dateutil.tz.winr   r$   ImportErrorr   gettzDATEUTIL_UTCgetattrr   __annotations__parentr'   r0   r4   r7   r=   r8   r@   lookupr   rN   __all__r   r1   r/   <module>ra      s1     # " " " " " # # # # # # ) ) ) ) ) ) ) ) ) )                         = = = = = = @ @ @ @ @ @ # # # # # #///////   FFF  *))))))))rx 'k4 H H  H H H H%DD440A+B+B+I 
( ( ( (V       (3{3'7'7 7 7 7 7
 
 
 
*  29 : : :1 1 1 1    N
M
Ms   A AA