MCPcopy Create free account
hub / github.com/EasyIME/PIME / _parse_timedelta

Method _parse_timedelta

python/python3/tornado/options.py:654–671  ·  view source on GitHub ↗
(self, value: str)

Source from the content-addressed store, hash-verified

652 )
653
654 def _parse_timedelta(self, value: str) -> datetime.timedelta:
655 try:
656 sum = datetime.timedelta()
657 start = 0
658 while start < len(value):
659 m = self._TIMEDELTA_PATTERN.match(value, start)
660 if not m:
661 raise Exception()
662 num = float(m.group(1))
663 units = m.group(2) or "seconds"
664 units = self._TIMEDELTA_ABBREV_DICT.get(units, units)
665 # This line confuses mypy when setup.py sets python_version=3.6
666 # https://github.com/python/mypy/issues/9676
667 sum += datetime.timedelta(**{units: num}) # type: ignore
668 start = m.end()
669 return sum
670 except Exception:
671 raise
672
673 def _parse_bool(self, value: str) -> bool:
674 return value.lower() not in ("false", "0", "f")

Callers

nothing calls this directly

Calls 3

matchMethod · 0.45
getMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected