Returns ({zone: [(stdoff, until), ...]}, {link: target}).
(path)
| 259 | |
| 260 | |
| 261 | def _parse_tzdata_zi(path): |
| 262 | """Returns ({zone: [(stdoff, until), ...]}, {link: target}).""" |
| 263 | zones = {} |
| 264 | links = {} |
| 265 | periods = None |
| 266 | with open(path) as f: |
| 267 | for line in f: |
| 268 | fields = line.split("#", 1)[0].split() |
| 269 | if not fields: |
| 270 | continue |
| 271 | |
| 272 | if fields[0] == "Z": |
| 273 | periods = zones.setdefault(fields[1], []) |
| 274 | fields = fields[2:] |
| 275 | elif fields[0] in ("R", "L"): |
| 276 | if fields[0] == "L": |
| 277 | links[fields[2]] = fields[1] |
| 278 | periods = None |
| 279 | continue |
| 280 | |
| 281 | # A zone line (without "Z <name>") or a continuation line: |
| 282 | # STDOFF RULES FORMAT [UNTIL] |
| 283 | until = _zi_until(fields[3:]) if len(fields) > 3 else None |
| 284 | periods.append((_zi_seconds(fields[0]), until)) |
| 285 | |
| 286 | return zones, links |
| 287 | |
| 288 | |
| 289 | def _find_tzdata_zi(tz_source): |
no test coverage detected