MCPcopy Index your code
hub / github.com/python/cpython / get_zoneinfo_metadata

Function get_zoneinfo_metadata

Lib/test/test_zoneinfo/data/update_test_data.py:52–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51
52def get_zoneinfo_metadata() -> typing.Dict[str, str]:
53 path = get_zoneinfo_path()
54
55 tzdata_zi = path / "tzdata.zi"
56 if not tzdata_zi.exists():
57 # tzdata.zi is necessary to get the version information
58 raise OSError("Time zone data does not include tzdata.zi.")
59
60 with open(tzdata_zi, "r") as f:
61 version_line = next(f)
62
63 _, version = version_line.strip().rsplit(" ", 1)
64
65 if (
66 not version[0:4].isdigit()
67 or len(version) < 5
68 or not version[4:].isalpha()
69 ):
70 raise ValueError(
71 "Version string should be YYYYx, "
72 + "where YYYY is the year and x is a letter; "
73 + f"found: {version}"
74 )
75
76 return {"version": version}
77
78
79def get_zoneinfo(key: str) -> bytes:

Callers 1

update_test_dataFunction · 0.85

Calls 7

get_zoneinfo_pathFunction · 0.85
isdigitMethod · 0.80
isalphaMethod · 0.80
openFunction · 0.50
existsMethod · 0.45
rsplitMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…