()
| 50 | |
| 51 | |
| 52 | def 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 | |
| 79 | def get_zoneinfo(key: str) -> bytes: |
no test coverage detected
searching dependent graphs…