'Converts a single CheckResult.
Args:
metadata: ExportedMetadata to be used for conversion.
checkresult: CheckResult to be converted.
token: Security token.
Yields:
Resulting ExportedCheckResult. Empty list is a valid result and means that
conversion wasn\'t possible.'

def Convert(self, metadata, checkresult, token=None):

    if checkresult.HasField('anomaly'):
        for anomaly in checkresult.anomaly:
            exported_anomaly = ExportedAnomaly(type=anomaly.type, severity=anomaly.severity, confidence=anomaly.confidence)
            if anomaly.symptom:
                exported_anomaly.symptom = anomaly.symptom
            if anomaly.explanation:
                exported_anomaly.explanation = anomaly.explanation
            if anomaly.generated_by:
                exported_anomaly.generated_by = anomaly.generated_by
            if anomaly.anomaly_reference_id:
                exported_anomaly.anomaly_reference_id = '\n'.join(anomaly.anomaly_reference_id)
            if anomaly.finding:
                exported_anomaly.finding = '\n'.join(anomaly.finding)
            (yield ExportedCheckResult(metadata=metadata, check_id=checkresult.check_id, anomaly=exported_anomaly))
    else:
        (yield ExportedCheckResult(metadata=metadata, check_id=checkresult.check_id))
