a
&i @ s d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z
g dZdZdZ
G d d
d
e
Z dd ZG d
d deZg ZdddZdd Zdd ZdS ) N)TarFile)get_data)BytesIO)tzfile)get_zonefile_instancegettzgettz_db_metadatazdateutil-zoneinfo.tar.gzZMETADATAc @ s e Zd Zdd ZdS )r c C s t | jffS )N)r Z _filenameself r >/usr/lib/python3.9/site-packages/dateutil/zoneinfo/__init__.py
__reduce__ s ztzfile.__reduce__N)__name__
__module____qualname__r
r r r r r s r c
C sR zt tttW S tyL } z$td| j| j W Y d } ~ d S d } ~ 0 0 d S )NzI/O error({0}): {1})
r r r ZONEFILENAMEIOErrorwarningswarnformaterrnostrerror)er r r getzoneinfofile_stream s
r c @ s e Zd ZdddZdddZdS )ZoneInfoFileNc s |d urt j|dfdd D _ fdd D } j| z.t}| d}t
| _W n t
y d _Y n0 W d q1 s0 Y ni _d _d S )N)Zfileobjc s6 i | ].}| r|jtkr|jt ||jd qS ))filename)isfilenameMETADATA_FNr extractfile).0zf)tfr r
" s z)ZoneInfoFile.__init__..c s, i | ]$}| s| r|j j|j qS r )ZislnkZissymr zonesZlinkname)r Zzlr r r r# ' s zUTF-8)r openZ
getmembersr$ updater Z getmemberr readdecodejsonloadsmetadataKeyError)r
Zzonefile_streamZlinksZ
metadata_jsonZmetadata_strr )r
r" r __init__ s"
,zZoneInfoFile.__init__c 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$ get)r
r defaultr r r r. 6 s zZoneInfoFile.get)N)N)r r r r- r. r r r r r s
r Fc C s2 | r
d}nt tdd}|du r.tt }|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 r r0 )Znew_instanceZzifr r r r P s
r c C s8 t dt ttdkr(ttt td j | S )a+
This retrieves a time zone from the local zoneinfo tarball that is packaged
with dateutil.
: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.
zzoneinfo.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 )
r r DeprecationWarninglen_CLASS_ZONE_INSTANCEappendr r r$ r. )r r r r r m s r c C s2 t dt ttdkr(ttt td jS )a! Get the zonefile metadata
See `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``.
zzoneinfo.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 ) r r r2 r3 r4 r5 r r r+ r r r r r s r )F)r r) tarfiler pkgutilr ior Zdateutil.tzr Z_tzfile__all__r r r objectr r4 r r r r r r r s /
&