def detect(stream):
    try:
        _yaml = yaml.safe_load(stream)
        if isinstance(_yaml, (list, tuple, dict)):
            return True
        else:
            return False
    except (yaml.parser.ParserError, yaml.reader.ReaderError,
            yaml.scanner.ScannerError):
        return False
Returns True if given stream is valid YAML.
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/tablib-0.10.0/tablib/formats/_yaml.py/detect