MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / load_tzdata

Function load_tzdata

tools/python-3.11.9-amd64/Lib/zoneinfo/_common.py:4–24  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

2
3
4def load_tzdata(key):
5 from importlib import resources
6
7 components = key.split("/")
8 package_name = ".".join(["tzdata.zoneinfo"] + components[:-1])
9 resource_name = components[-1]
10
11 try:
12 return resources.files(package_name).joinpath(resource_name).open("rb")
13 except (ImportError, FileNotFoundError, UnicodeEncodeError):
14 # There are three types of exception that can be raised that all amount
15 # to "we cannot find this key":
16 #
17 # ImportError: If package_name doesn't exist (e.g. if tzdata is not
18 # installed, or if there's an error in the folder name like
19 # Amrica/New_York)
20 # FileNotFoundError: If resource_name doesn't exist in the package
21 # (e.g. Europe/Krasnoy)
22 # UnicodeEncodeError: If package_name or resource_name are not UTF-8,
23 # such as keys containing a surrogate character.
24 raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
25
26
27def load_data(fobj):

Callers

nothing calls this directly

Calls 6

splitMethod · 0.45
joinMethod · 0.45
openMethod · 0.45
joinpathMethod · 0.45
filesMethod · 0.45

Tested by

no test coverage detected