You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright (C) 2016 Adrien Vergé
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
class LintProblem(object):
|
|
def __init__(self, line, column, desc='<no description>', rule=None):
|
|
self.line = line
|
|
self.column = column
|
|
self.desc = desc
|
|
self.rule = rule
|
|
self.level = None
|
|
|
|
@property
|
|
def message(self):
|
|
if self.rule is not None:
|
|
return '%s (%s)' % (self.desc, self.rule)
|
|
return self.desc
|
|
|
|
def __eq__(self, other):
|
|
return (self.line == other.line and
|
|
self.column == other.column and
|
|
self.rule == other.rule)
|
|
|
|
def __lt__(self, other):
|
|
return (self.line < other.line or
|
|
(self.line == other.line and self.column < other.column))
|
|
|
|
def __repr__(self):
|
|
return '%d:%d: %s' % (self.line, self.column, self.message)
|
|
|
|
|
|
class YamlLintError(Exception):
|
|
pass
|
|
|
|
|
|
class YamlLintConfigError(YamlLintError):
|
|
pass
|