(option, opt, value)
| 454 | _time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 } |
| 455 | |
| 456 | def _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 | |
| 466 | class DurationOption(Option): |
| 467 | TYPES = Option.TYPES + ('duration',) |
nothing calls this directly
no test coverage detected