Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Validation function.  Converts a config value to an interval of time,
returning a Duration object. Raises ConfigError on failure.

        def _parseInterval(interval):
    """Validation function.  Converts a config value to an interval of time,
       returning a Duration object. Raises ConfigError on failure."""
    inter = interval.strip().lower()
    m = _interval_re.match(inter)
    if not m:
        raise ConfigError("Unrecognized interval %r" % inter)
    num, unit = m.group(1), m.group(2)
    if '.' in num:
        num = float(num)
    else:
        num = int(num)
    nsec = int(num * _seconds_per_unit[unit])
    return mixminion.Common.Duration(nsec,
                    _canonical_unit_names.get(unit,unit), num)
        


src/m/i/mixminion-HEAD/lib/mixminion/test.py   mixminion(Download)
        self.assertEquals(C._parseServerMode("Local"), "local")
        # interval
        self.assertEquals(str(C._parseInterval(" 1 sec ")),"1 second")
        self.assertEquals(str(C._parseInterval(" 99 sec ")),"99 seconds")
        self.assertFloatEq(float(C._parseInterval("1.5 minutes")), 90)
        h2 = C._parseInterval("2 houRS")
        m120 = C._parseInterval("120 minutes")