MCPcopy Create free account
hub / github.com/dateutil/dateutil / get_zonefile_instance

Function get_zonefile_instance

src/dateutil/zoneinfo/__init__.py:140–166  ·  view source on GitHub ↗

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 :clas

(new_instance=False)

Source from the content-addressed store, hash-verified

138
139
140def get_zonefile_instance(new_instance=False):
141 """
142 This is a convenience function which provides a :class:`ZoneInfoFile`
143 instance using the data provided by the ``dateutil`` package. By default, it
144 caches a single instance of the ZoneInfoFile object and returns that.
145
146 :param new_instance:
147 If ``True``, a new instance of :class:`ZoneInfoFile` is instantiated and
148 used as the cached instance for the next call. Otherwise, new instances
149 are created only as necessary.
150
151 :return:
152 Returns a :class:`ZoneInfoFile` object.
153
154 .. versionadded:: 2.6
155 """
156 if new_instance:
157 zif = None
158 else:
159 zif = getattr(get_zonefile_instance, '_cached_instance', None)
160
161 if zif is None:
162 zif = ZoneInfoFile()
163
164 get_zonefile_instance._cached_instance = zif
165
166 return zif
167
168
169def gettz(name):

Callers

nothing calls this directly

Calls 1

ZoneInfoFileClass · 0.85

Tested by

no test coverage detected