mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-15 01:30:40 +00:00
38 lines
912 B
Python
38 lines
912 B
Python
|
"""Review candidates."""
|
||
|
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
|
||
|
class Error(object):
|
||
|
"""Default error object created if a rule failed."""
|
||
|
|
||
|
def __init__(self, lineno, message):
|
||
|
"""
|
||
|
Initialize a new error object and returns None.
|
||
|
|
||
|
:param lineno: Line number where the error from de rule occures
|
||
|
:param message: Detailed error description provided by the rule
|
||
|
|
||
|
"""
|
||
|
self.lineno = lineno
|
||
|
self.message = message
|
||
|
|
||
|
def __repr__(self): # noqa
|
||
|
if self.lineno:
|
||
|
return "%s: %s" % (self.lineno, self.message)
|
||
|
else:
|
||
|
return " %s" % (self.message)
|
||
|
|
||
|
|
||
|
class Result(object):
|
||
|
def __init__(self, candidate, errors=None):
|
||
|
self.candidate = candidate
|
||
|
self.errors = errors or []
|
||
|
|
||
|
def message(self):
|
||
|
return "\n".join(["{0}:{1}".format(self.candidate, error)
|
||
|
for error in self.errors])
|
||
|
|
||
|
|