import uuid
import hashlib


def generate_uuid(basedata=None):
    """Provides a random UUID with no input, or a UUID4-format MD5 checksum of
    any input data provided.

    :param str basedata: provided data to calculate a uuid

    """
    if basedata is None:
        return str(uuid.uuid4())
    elif isinstance(basedata, str):
        checksum = hashlib.md5(basedata.encode()).hexdigest()
        return str(uuid.UUID(checksum))
    else:
        raise TypeError("The 'basedata' must be string or None")