yamllint provides both a script and a Python module. The latter can be used to write your own linting tools:
LintProblem(line, column, desc='<no description>', rule=None)¶
Represents a linting problem found by yamllint.
Column on which the problem was found (starting at 1)
Human-readable description of the problem
Line on which the problem was found (starting at 1)
Identifier of the rule that detected the problem
Lints a YAML source.
Returns a generator of LintProblem objects.
- input – buffer, string or stream to read from
- conf – yamllint configuration object