Debian Codegraph @

Lib/zoneinfo/__init__.py

raw
1 __all__ = [
2 "ZoneInfo",
3 "reset_tzpath",
4 "available_timezones",
5 "TZPATH",
6 "ZoneInfoNotFoundError",
7 "InvalidTZPathWarning",
8 ]
9
10 from . import _tzpath
11 from ._common import ZoneInfoNotFoundError
12
13 try:
14 from _zoneinfo import ZoneInfo
15 except (ImportError, AttributeError): # pragma: nocover
16 # AttributeError: module 'datetime' has no attribute 'datetime_CAPI'.
17 # This happens when the '_datetime' module is not available and the
18 # pure Python implementation is used instead.
19 from ._zoneinfo import ZoneInfo
20
21 reset_tzpath = _tzpath.reset_tzpath
22 available_timezones = _tzpath.available_timezones
23 InvalidTZPathWarning = _tzpath.InvalidTZPathWarning
24
25
26 def __getattr__(name):
27 if name == "TZPATH":
28 return _tzpath.TZPATH
29 else:
30 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
31
32
33 def __dir__():
34 return sorted(list(globals()) + ["TZPATH"])