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)
| 138 | |
| 139 | |
| 140 | def 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 | |
| 169 | def gettz(name): |
nothing calls this directly
no test coverage detected