import email


def _get_feedback_monthly_text(file):
    """Return feedback text from open binary file.

    Required text is assumed to be either in 'text/html' parts of an email,
    but not an 'application/ms-tnef' attachment, or in a text file containing
    the saved response from a submission to the ECF ratings website.

    """
    m = email.message_from_binary_file(file)

    # Assume feedback is a saved response file if no message keys are found.
    if not m.keys():
        file.seek(0)
        return file.read().decode()

    # Assume feedback is in body of email, with no attachments.
    return m.get_payload()