MCPcopy Create free account
hub / github.com/RustPython/RustPython / _check_duration

Function _check_duration

Lib/test/test_optparse.py:456–464  ·  view source on GitHub ↗
(option, opt, value)

Source from the content-addressed store, hash-verified

454_time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 }
455
456def _check_duration(option, opt, value):
457 try:
458 if value[-1].isdigit():
459 return int(value)
460 else:
461 return int(value[:-1]) * _time_units[value[-1]]
462 except (ValueError, IndexError):
463 raise OptionValueError(
464 'option %s: invalid duration: %r' % (opt, value))
465
466class DurationOption(Option):
467 TYPES = Option.TYPES + ('duration',)

Callers

nothing calls this directly

Calls 2

OptionValueErrorClass · 0.90
isdigitMethod · 0.45

Tested by

no test coverage detected