forked from Pyomo/pyomo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.py
53 lines (41 loc) · 2.04 KB
/
checker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
# rights in this software.
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
from pyomo.common.plugin import Interface
class IModelChecker(Interface):
def check(self, runner, script, info):
"""
Check a particular piece of Python information for errors.
Provides the primary interface for checking some code for problems,
according to the particular subclass's definition.
@param runner the ModelCheckRunner instance that has dispatched
this call to check().
@param script the ModelScript instance being checked.
@param info the data to check. Depending on the subclass, info
can be the raw text of a Python script, the entire AST
of the script, or a particular node in that AST.
"""
def beginChecking(self, runner, script):
"""
Start checking the given script from the given runner.
"""
def endChecking(self, runner, script):
"""
Finish checking the given script from the given runner.
"""
def problem(self, script = None, message = "Error", lineno = None):
"""
Write a problem to the console. The format varies and can be
changed in subclasses; by default, this method prints the following:
[CheckerName] script.py:line: Error
@param script the ModelScript instance being checked. Must be passed
to have the file name and line number printed.
@param message the error to display.
@param lineno the line number on which the error occurred.
"""