Ubuntu Pastebin

Paste from smoser at Tue, 10 Feb 2015 22:01:49 +0000

Download as text
1
2
3
4
5
6
7
8
9
def b64d(source):
    # Base64 decode some data, accepting bytes or unicode/str, and returning
    # str/unicode if the result is utf-8 compatible, otherwise returning bytes.
    decoded = b64decode(source)
    if isinstance(decoded, bytes):
        try:
            return decoded.decode('utf-8')
        except UnicodeDecodeError:
            return decoded
Download as text