o
    .j                     @  sL  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 zddlmZ W n eyP   dZY nw er[ddlmZmZ edZeeddZded< edu rpdne
ejZ d.ddZ!d/ddZ"d0ddZ#ee$Z%ded< d1d"d#Z&e&ej' d2d&d'Z(d3d+d,Z)g d-Z*dS )4zThis 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                 C  s  | du rdS t | trt| dS t| drt| jS t| dr&t| jS t | tjr1t| j	S t | tj
r<t| jS tdurXt | trXt| j}|durSt|S t| jS t| dr|tdur|| j}|ttrxtt|t}t|S t|S t | tjrt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tzidr   r   L/home/thesage/.local/lib/python3.10/site-packages/icalendar/timezone/tzid.pytzids_from_tzinfo$   s6   








r.   c                 C  s$   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   )r.   )r   tzidsr   r   r-   tzid_from_tzinfoO   s   r0   dtr   c                 C  s   t | j}|du r|  S |S )z2Retrieve the timezone id from the datetime object.N)r0   r   r   )r1   r,   r   r   r-   tzid_from_dt]   s   
r2   zdict[str, set[str]]_EQUIVALENT_IDSvaluetuple | dict | setc                 C  s|   t | tr| D ]	}t| |  qdS t | tr t| d  dS t | tr2|  D ]}t| q)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   setr3   updatetuple_add_equivalent_idsdictvalues	TypeError	__class____name__)r4   r,   value2r   r   r-   r:   h   s   



r:   r,   r'   c                 C  s&   t | t }| ftt|| h  S )z8This returns the tzids which are equivalent to this one.)r3   r#   r7   r9   sorted)r,   idsr   r   r-   r      s   r   tdatetime | time | date | tzinfoboolc                 C  s.   t | rdS t| drt| nt| }|dkS )zWhether this date is in UTC.Fr   r   )r   r   r2   r0   )rC   r,   r   r   r-   is_utc   s   rF   )rF   r2   r0   r.   )r   r   r   r   )r   r   r   r   )r1   r   r   r   )r4   r5   )r,   r'   r   r   )rC   rD   r   rE   )+__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%   r.   r0   r2   r7   r3   r:   lookupr   rF   __all__r   r   r   r-   <module>   s<    


+




