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

All Samples(7)  |  Call(7)  |  Derive(0)  |  Import(0)
Validation function.  Converts a config value to a size in octets.
Raises ConfigError on failure.

        def _parseSize(size):
    """Validation function.  Converts a config value to a size in octets.
       Raises ConfigError on failure."""
    s = size.strip().lower()
    m = _size_re.match(s)
    if not m: raise ConfigError("Invalid size %r"%size)
    val = m.group(1)
    unit = _size_name_map[m.group(2)]
    if '.' in val:
        return long(float(val)*unit)
    else:
        return long(val)*unit
        


src/m/i/mixminion-HEAD/lib/mixminion/test.py   mixminion(Download)
        self.assertEquals(str(m120), "2 hours")
        # size
        self.assertEquals(C._parseSize(" 30 bytes"), 30L)
        self.assertEquals(C._parseSize(" 3000 b"), 3000L)
        self.assertEquals(C._parseSize("50k"), 50*1024L)
        self.assertEquals(C._parseSize("50k "), 50*1024L)
        self.assertEquals(C._parseSize("50 "), 50L)