def extract_eliot_from_twisted_log(twisted_log_line):
    """
    Given a line from a Twisted log message, return the text of the Eliot log
    message that is on that line.

    If there is no Eliot message on that line, return ``None``.

    :param str twisted_log_line: A line from a Twisted test.log.
    :return: A logged eliot message without Twisted logging preamble, or
        ``None``.
    :rtype: unicode or ``NoneType``.
    """
    open_brace = twisted_log_line.find('{')
    close_brace = twisted_log_line.rfind('}')
    if open_brace == -1 or close_brace == -1:
        return None
    candidate = twisted_log_line[open_brace:close_brace + 1]
    try:
        fields = json.loads(candidate)
    except (ValueError, __HOLE__):
        return None
    # Eliot lines always have these two keys.
    if {"task_uuid", "timestamp"}.difference(fields):
        return None
    return candidate
dataset/ETHPy150Open ClusterHQ/flocker/flocker/testtools/_base.py/extract_eliot_from_twisted_log