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

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Validation function.  Converts a base-64 encoded config value into
its original. Raises ConfigError on failure.

        def _parseBase64(s,_hexmode=0):
    """Validation function.  Converts a base-64 encoded config value into
       its original. Raises ConfigError on failure."""
    try:
        if _hexmode:
            s = stripSpace(s)
            return binascii.a2b_hex(s)
        else:
            return binascii.a2b_base64(s)
    except (TypeError, binascii.Error, binascii.Incomplete):
        if _hexmode:
            raise ConfigError("Invalid hexadecimal data")
        else:
            raise ConfigError("Invalid Base64 data")
        


src/m/i/mixminion-HEAD/lib/mixminion/test.py   mixminion(Download)
 
        # Base64
        self.assertEquals(C._parseBase64(" YW\nJj"), "abc")
        self.assertEquals(C._parseBase64(" Y W\nJ j"), "abc")
        # Hex