Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/backports/zoneinfo/__init__.py: 59%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

22 statements  

1__all__ = [ 

2 "ZoneInfo", 

3 "reset_tzpath", 

4 "available_timezones", 

5 "TZPATH", 

6 "ZoneInfoNotFoundError", 

7 "InvalidTZPathWarning", 

8] 

9import sys 

10 

11from . import _tzpath 

12from ._common import ZoneInfoNotFoundError 

13from ._version import __version__ 

14 

15try: 

16 from ._czoneinfo import ZoneInfo 

17except ImportError: # pragma: nocover 

18 from ._zoneinfo import ZoneInfo 

19 

20reset_tzpath = _tzpath.reset_tzpath 

21available_timezones = _tzpath.available_timezones 

22InvalidTZPathWarning = _tzpath.InvalidTZPathWarning 

23 

24if sys.version_info < (3, 7): 

25 # Module-level __getattr__ was added in Python 3.7, so instead of lazily 

26 # populating TZPATH on every access, we will register a callback with 

27 # reset_tzpath to update the top-level tuple. 

28 TZPATH = _tzpath.TZPATH 

29 

30 def _tzpath_callback(new_tzpath): 

31 global TZPATH 

32 TZPATH = new_tzpath 

33 

34 _tzpath.TZPATH_CALLBACKS.append(_tzpath_callback) 

35 del _tzpath_callback 

36 

37else: 

38 

39 def __getattr__(name): 

40 if name == "TZPATH": 

41 return _tzpath.TZPATH 

42 else: 

43 raise AttributeError( 

44 f"module {__name__!r} has no attribute {name!r}" 

45 ) 

46 

47 

48def __dir__(): 

49 return sorted(list(globals()) + ["TZPATH"])