-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRule.py
More file actions
32 lines (25 loc) · 1009 Bytes
/
Rule.py
File metadata and controls
32 lines (25 loc) · 1009 Bytes
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
import logging
class Rule:
def __init__(self, num, txt):
self.msg = txt
self.number = num
self.log = logging.getLogger('output.txt')
self.log.setLevel(logging.DEBUG)
def check(self, xml):
self.log.error("implemented by derived classes....")
def raiseError(self, file, line, offender):
self.log.error(f"[R{self.number}] {file}:{line}: {offender}\t|{self.msg}")
def show(self):
self.log.error(f"Rule {self.number}: {self.msg}\n\tSome explanation about this rule.")
def getVar(self, id, xml):
for v in xml.findall("./dump/variables/var"):
if id == v.attrib.get('id'):
return v
self.log.error(f"Possible bug: var {id} not found!")
return None
def getToken(self, id, xml):
for t in xml.findall("./dump/tokenlist/token"):
if id == t.attrib.get('id'):
return t
self.log.error(f"Possible bug: var {id} not found!")
return None