[Tools] Add Code Checker (#472)
[platform/core/csapi/tizenfx.git] / tools / scripts / CodeChecker / BuildLog.py
1 class BuildLog:
2     FILE = 0
3     LINE_NUMBER = 1
4     WARNING_CODE = 2
5     MESSAGE = 3
6
7     def __init__(self, filePath):
8         self._file = open(filePath, 'r')
9         self._parseLog()
10
11     def _parseLog(self):
12         self._lines = self._file.readlines()
13         self._lines[:] = [line for line in self._lines if ": warning" in line]
14         self.warnings = [[0 for i in range(4)] for y in range(len(self._lines))]
15
16         for index, line in enumerate(self._lines):
17             self._lines[index] = line.split(":")
18             self._lines[index][0] = self._lines[index][0][:-1].split("(")
19
20             self.warnings[index][self.FILE] = self._lines[index][0][0]
21             self.warnings[index][self.LINE_NUMBER] = int(self._lines[index][0][1].split(",")[0])
22             self.warnings[index][self.WARNING_CODE] = self._lines[index][1]
23             self.warnings[index][self.MESSAGE] = self._lines[index][2].split("[/")[0]
24
25     def __del__(self):
26         self._file.close()
27
28 if __name__ == "__main__":
29     logPath = "../../build.log"
30     logs = BuildLog(logPath)
31     print(logs.warnings)