]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Table/TableIdentifier.py
BaseTools: Use absolute import in Table
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableIdentifier.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to create/update/query/erase table for Identifiers\r
3#\r
f7496d71 4# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
30fdf114
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
14##\r
15# Import Modules\r
16#\r
3d872904 17from __future__ import absolute_import\r
30fdf114 18import Common.EdkLogger as EdkLogger\r
5a57246e 19from Common.StringUtils import ConvertToSqlString\r
3d872904 20from .Table import Table\r
30fdf114
LG
21\r
22## TableIdentifier\r
23#\r
24# This class defined a table used for Identifier\r
f7496d71 25#\r
30fdf114
LG
26# @param object: Inherited from object class\r
27#\r
28#\r
29class TableIdentifier(Table):\r
30 def __init__(self, Cursor):\r
31 Table.__init__(self, Cursor)\r
32 self.Table = 'Identifier'\r
f7496d71 33\r
30fdf114
LG
34 ## Create table\r
35 #\r
36 # Create table Identifier\r
37 #\r
38 # @param ID: ID of a Identifier\r
39 # @param Modifier: Modifier of a Identifier\r
40 # @param Type: Type of a Identifier\r
41 # @param Name: Name of a Identifier\r
42 # @param Value: Value of a Identifier\r
43 # @param Model: Model of a Identifier\r
44 # @param BelongsToFile: The Identifier belongs to which file\r
45 # @param BelongsToFunction: The Identifier belongs to which function\r
46 # @param StartLine: StartLine of a Identifier\r
47 # @param StartColumn: StartColumn of a Identifier\r
48 # @param EndLine: EndLine of a Identifier\r
49 # @param EndColumn: EndColumn of a Identifier\r
50 #\r
51 def Create(self):\r
52 SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,\r
53 Modifier VARCHAR,\r
54 Type VARCHAR,\r
55 Name VARCHAR NOT NULL,\r
56 Value VARCHAR NOT NULL,\r
57 Model INTEGER NOT NULL,\r
58 BelongsToFile SINGLE NOT NULL,\r
59 BelongsToFunction SINGLE DEFAULT -1,\r
60 StartLine INTEGER NOT NULL,\r
61 StartColumn INTEGER NOT NULL,\r
62 EndLine INTEGER NOT NULL,\r
63 EndColumn INTEGER NOT NULL\r
64 )""" % self.Table\r
65 Table.Create(self, SqlCommand)\r
66\r
67 ## Insert table\r
68 #\r
69 # Insert a record into table Identifier\r
70 #\r
71 # @param ID: ID of a Identifier\r
72 # @param Modifier: Modifier of a Identifier\r
73 # @param Type: Type of a Identifier\r
74 # @param Name: Name of a Identifier\r
75 # @param Value: Value of a Identifier\r
76 # @param Model: Model of a Identifier\r
77 # @param BelongsToFile: The Identifier belongs to which file\r
78 # @param BelongsToFunction: The Identifier belongs to which function\r
79 # @param StartLine: StartLine of a Identifier\r
80 # @param StartColumn: StartColumn of a Identifier\r
81 # @param EndLine: EndLine of a Identifier\r
82 # @param EndColumn: EndColumn of a Identifier\r
83 #\r
84 def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):\r
85 self.ID = self.ID + 1\r
86 (Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))\r
87 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \\r
88 % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)\r
89 Table.Insert(self, SqlCommand)\r
90\r
f7496d71 91 return self.ID\r