MCPcopy Create free account
hub / github.com/dateutil/dateutil / _parse_tzdata_zi

Function _parse_tzdata_zi

tests/test_tzpath_data.py:261–286  ·  view source on GitHub ↗

Returns ({zone: [(stdoff, until), ...]}, {link: target}).

(path)

Source from the content-addressed store, hash-verified

259
260
261def _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
289def _find_tzdata_zi(tz_source):

Callers 1

Calls 4

_zi_untilFunction · 0.85
_zi_secondsFunction · 0.85
splitMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected