Provides a _random_ UUID with no input, or a UUID4-format MD5 checksum of any input data provided

def generate_uuid(basedata=None):
    """ Provides a _random_ UUID with no input, or a UUID4-format MD5 checksum of any input data provided """
    if basedata is None:
        return str(uuid.uuid4())
    elif isinstance(basedata, str):
        checksum = hashlib.md5(basedata).hexdigest()
        return '%8s-%4s-%4s-%4s-%12s' % (
            checksum[0:8], checksum[8:12], checksum[12:16], checksum[16:20], checksum[20:32])