a
    €˜ëj$  ã                   @   s¨   d Z ddlZddlZddlZddlmZ ddlZddlmZ ddl	m
Z g d¢ZdZdZdd	„ Zejd
eeƒ d� eZ
G dd„ deƒZg Zddd„Zdd„ Zdd„ ZdS )aÁ  
The ``dateutil.zoneinfo`` module was originally designed to work with a tarball
shipped with ``dateutil``. Since ``dateutil`` now uses data from the same
sources as :py:mod:`zoneinfo`, this module is no longer necessary.

.. caution::
    This module is deprecated, and its functionality has been dramatically
    curtailed. It is recommended that you adopt the standard library module
    :py:mod:`zoneinfo` or :func:`dateutil.tz.gettz` instead.

é    N)ÚTarFile)Ú_tzdata_impl)Útzfile)Úget_zonefile_instanceÚgettzÚgettz_db_metadataÚMETADATAc                  C   sl   d} t  d¡}|jdurh|j}|jj}d|v rJd|v rJt jdk r| d7 } q| d7 } |j d¡dvr| S qdS )	aO  The ``stacklevel`` that attributes a warning to the importing code.

    This module can be imported through ``dateutil.__getattr__`` (e.g. by
    ``from dateutil import zoneinfo``), which calls
    ``importlib.import_module``; the warnings machinery skips the import
    system's own frames, but not those two, so skip them here.
    é   NÚ	importlibÚ
_bootstrap)é   é   Ú__name__)r
   Údateutilé   )ÚsysÚ	_getframeÚf_backÚf_codeÚco_filenameÚversion_infoÚ	f_globalsÚget)ÚlevelÚframeÚfilename© r   úY/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/dateutil/zoneinfo/__init__.pyÚ_importer_stacklevel   s    


r   zÝThe `dateutil.zoneinfo` module has been replaced with a wrapper around the tzdata package, and its use is deprecated, to be removed in a future version. Use the standard library module `zoneinfo` or `dateutil.tz` instead.)Ú
stacklevelc                   @   s0   e Zd Zd
dd„Zdd„ Zdd„ Zddd	„ZdS )ÚZoneInfoFileNc                 C   s    |d ur|   |¡ n|  ¡  d S )N)Ú_load_legacy_zonefile_streamÚ_eager_load_tzdata)ÚselfÚzonefile_streamr   r   r   Ú__init__F   s    zZoneInfoFile.__init__c              
   C   s¦   zdd l }W n4 ty@ } zt tdƒ|¡ W Y d }~n
d }~0 0 i }t ¡ D ]>}t |¡� }t||d�||< W d   ƒ qN1 s‚0    Y  qN|| _d|j	dœ| _
d S )Nr   z|The tzdata module is required to use ZoneInfoFile; either add a dependency on tzdata or migrate away from dateutil.zoneinfo.)Úkeyz3.0)Úmetadata_versionZ	tzversion)ÚtzdataÚImportErrorÚsixÚ
raise_fromr   Z_load_tzdata_keysZ_load_tzdatar   ÚzonesZIANA_VERSIONÚmetadata)r#   r(   ÚeZ	zone_dictr&   Úfr   r   r   r"   L   s"    ÿû0þzZoneInfoFile._eager_load_tzdatac              	      s²   t j|d��’‰‡fdd„ˆ ¡ D ƒˆ _‡ fdd„ˆ ¡ D ƒ}ˆ j |¡ z.ˆ ˆ t¡¡}| ¡  	d¡}t
 |¡ˆ _W n tyŽ   d ˆ _Y n0 W d   ƒ n1 s¤0    Y  d S )N)Úfileobjc                    s6   i | ].}|  ¡ r|jtkr|jtˆ  |¡|jd �“qS ))r   )ÚisfileÚnameÚMETADATA_FNr   Úextractfile)Ú.0Úzf)Útfr   r   Ú
<dictcomp>f   s   þz=ZoneInfoFile._load_legacy_zonefile_stream.<locals>.<dictcomp>c                    s,   i | ]$}|  ¡ s| ¡ r|jˆ j|j “qS r   )ÚislnkÚissymr2   r,   Úlinkname)r5   Zzl)r#   r   r   r8   m   s   þzUTF-8)r   ÚopenÚ
getmembersr,   Úupdater4   Ú	getmemberr3   ÚreadÚdecodeÚjsonÚloadsr-   ÚKeyError)r#   r$   ÚlinksZmetadata_jsonZmetadata_strr   )r#   r7   r   r!   d   s    
þ
þz)ZoneInfoFile._load_legacy_zonefile_streamc                 C   s   | j  ||¡S )ak  
        Wrapper for :func:`ZoneInfoFile.zones.get`. This is a convenience method
        for retrieving zones from the zone dictionary.

        :param name:
            The name of the zone to retrieve. (Generally IANA zone names)

        :param default:
            The value to return in the event of a missing key.

        .. versionadded:: 2.6.0

        )r,   r   )r#   r2   Údefaultr   r   r   r   {   s    zZoneInfoFile.get)N)N)r   Ú
__module__Ú__qualname__r%   r"   r!   r   r   r   r   r   r    E   s   
r    Fc                 C   s.   | r
d}nt tddƒ}|du r*tƒ }|t_|S )a%  
    This is a convenience function which provides a :class:`ZoneInfoFile`
    instance using the data provided by the ``dateutil`` package. By default, it
    caches a single instance of the ZoneInfoFile object and returns that.

    :param new_instance:
        If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
        used as the cached instance for the next call. Otherwise, new instances
        are created only as necessary.

    :return:
        Returns a :class:`ZoneInfoFile` object.

    .. versionadded:: 2.6
    NÚ_cached_instance)Úgetattrr   r    rI   )Znew_instanceZzifr   r   r   r   •   s    r   c                 C   s4   t  dt¡ ttƒdkr$t tƒ ¡ td j | ¡S )a  
    This retrieves a time zone from the ``tzdata`` package.

    :param name:
        An IANA-style time zone name, as found in the zoneinfo file.

    :return:
        Returns a :class:`dateutil.tz.tzfile` time zone object.

    .. warning::
        It is generally inadvisable to use this function, and it is only
        provided for API compatibility with earlier versions. This is *not*
        equivalent to ``dateutil.tz.gettz()``, which selects an appropriate
        time zone based on the inputs, favoring system zoneinfo. This is ONLY
        for accessing the dateutil-specific zoneinfo (which may be out of
        date compared to the system zoneinfo).

    .. deprecated:: 2.6
        If you need to use a specific zoneinfofile over the system zoneinfo,
        instantiate a :class:`dateutil.zoneinfo.ZoneInfoFile` object and call
        :func:`dateutil.zoneinfo.ZoneInfoFile.get(name)` instead.

        Use :func:`get_zonefile_instance` to retrieve an instance of the
        dateutil-provided zoneinfo.
    zÐzoneinfo.gettz() will be removed in future versions, to use the dateutil-provided zoneinfo files, instantiate a ZoneInfoFile object and use ZoneInfoFile.zones.get() instead. See the documentation for details.r   )	ÚwarningsÚwarnÚDeprecationWarningÚlenÚ_CLASS_ZONE_INSTANCEÚappendr    r,   r   )r2   r   r   r   r   ²   s    ür   c                   C   s.   t  dt¡ ttƒdkr$t tƒ ¡ td jS )a  Get the zonefile metadata

    :returns:
        A dictionary with the database metadata

    .. deprecated:: 2.6
        See deprecation warning in :func:`zoneinfo.gettz`. To get metadata,
        query the attribute ``zoneinfo.ZoneInfoFile.metadata``.
    zÐzoneinfo.gettz_db_metadata() will be removed in future versions, to use the dateutil-provided zoneinfo files, ZoneInfoFile object and query the 'metadata' attribute instead. See the documentation for details.r   )rK   rL   rM   rN   rO   rP   r    r-   r   r   r   r   r   ×   s    
ür   )F)Ú__doc__rB   r   rK   Útarfiler   r*   r   r   Zdateutil.tzr   Z_tzfileÚ__all__ZZONEFILENAMEr3   r   rL   rM   Úobjectr    rO   r   r   r   r   r   r   r   Ú<module>   s,   ú
M
%