]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableEotReport.py
BaseTools: Use absolute import in Table
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableEotReport.py
1 ## @file
2 # This file is used to create/update/query/erase table for ECC reports
3 #
4 # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13
14 ##
15 # Import Modules
16 #
17 from __future__ import absolute_import
18 import Common.EdkLogger as EdkLogger
19 import Common.LongFilePathOs as os, time
20 from .Table import Table
21 from Common.StringUtils import ConvertToSqlString2
22 import Eot.EotToolError as EotToolError
23 import Eot.EotGlobalData as EotGlobalData
24
25 ## TableReport
26 #
27 # This class defined a table used for data model
28 #
29 # @param object: Inherited from object class
30 #
31 #
32 class TableEotReport(Table):
33 def __init__(self, Cursor):
34 Table.__init__(self, Cursor)
35 self.Table = 'Report'
36
37 ## Create table
38 #
39 # Create table report
40 #
41 #
42 def Create(self):
43 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
44 ModuleID INTEGER DEFAULT -1,
45 ModuleName TEXT DEFAULT '',
46 ModuleGuid TEXT DEFAULT '',
47 SourceFileID INTEGER DEFAULT -1,
48 SourceFileFullPath TEXT DEFAULT '',
49 ItemName TEXT DEFAULT '',
50 ItemType TEXT DEFAULT '',
51 ItemMode TEXT DEFAULT '',
52 GuidName TEXT DEFAULT '',
53 GuidMacro TEXT DEFAULT '',
54 GuidValue TEXT DEFAULT '',
55 BelongsToFunction TEXT DEFAULT '',
56 Enabled INTEGER DEFAULT 0
57 )""" % self.Table
58 Table.Create(self, SqlCommand)
59
60 ## Insert table
61 #
62 # Insert a record into table report
63 #
64 #
65 def Insert(self, ModuleID = -1, ModuleName = '', ModuleGuid = '', SourceFileID = -1, SourceFileFullPath = '', \
66 ItemName = '', ItemType = '', ItemMode = '', GuidName = '', GuidMacro = '', GuidValue = '', BelongsToFunction = '', Enabled = 0):
67 self.ID = self.ID + 1
68 SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s)""" \
69 % (self.Table, self.ID, ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, \
70 ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled)
71 Table.Insert(self, SqlCommand)
72
73 def GetMaxID(self):
74 SqlCommand = """select max(ID) from %s""" % self.Table
75 self.Cur.execute(SqlCommand)
76 for Item in self.Cur:
77 return Item[0]