]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Table/TableIdentifier.py
BaseTools: Use absolute import in Table
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableIdentifier.py
1 ## @file
2 # This file is used to create/update/query/erase table for Identifiers
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 from Common.StringUtils import ConvertToSqlString
20 from .Table import Table
21
22 ## TableIdentifier
23 #
24 # This class defined a table used for Identifier
25 #
26 # @param object: Inherited from object class
27 #
28 #
29 class TableIdentifier(Table):
30 def __init__(self, Cursor):
31 Table.__init__(self, Cursor)
32 self.Table = 'Identifier'
33
34 ## Create table
35 #
36 # Create table Identifier
37 #
38 # @param ID: ID of a Identifier
39 # @param Modifier: Modifier of a Identifier
40 # @param Type: Type of a Identifier
41 # @param Name: Name of a Identifier
42 # @param Value: Value of a Identifier
43 # @param Model: Model of a Identifier
44 # @param BelongsToFile: The Identifier belongs to which file
45 # @param BelongsToFunction: The Identifier belongs to which function
46 # @param StartLine: StartLine of a Identifier
47 # @param StartColumn: StartColumn of a Identifier
48 # @param EndLine: EndLine of a Identifier
49 # @param EndColumn: EndColumn of a Identifier
50 #
51 def Create(self):
52 SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
53 Modifier VARCHAR,
54 Type VARCHAR,
55 Name VARCHAR NOT NULL,
56 Value VARCHAR NOT NULL,
57 Model INTEGER NOT NULL,
58 BelongsToFile SINGLE NOT NULL,
59 BelongsToFunction SINGLE DEFAULT -1,
60 StartLine INTEGER NOT NULL,
61 StartColumn INTEGER NOT NULL,
62 EndLine INTEGER NOT NULL,
63 EndColumn INTEGER NOT NULL
64 )""" % self.Table
65 Table.Create(self, SqlCommand)
66
67 ## Insert table
68 #
69 # Insert a record into table Identifier
70 #
71 # @param ID: ID of a Identifier
72 # @param Modifier: Modifier of a Identifier
73 # @param Type: Type of a Identifier
74 # @param Name: Name of a Identifier
75 # @param Value: Value of a Identifier
76 # @param Model: Model of a Identifier
77 # @param BelongsToFile: The Identifier belongs to which file
78 # @param BelongsToFunction: The Identifier belongs to which function
79 # @param StartLine: StartLine of a Identifier
80 # @param StartColumn: StartColumn of a Identifier
81 # @param EndLine: EndLine of a Identifier
82 # @param EndColumn: EndColumn of a Identifier
83 #
84 def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
85 self.ID = self.ID + 1
86 (Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))
87 SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
88 % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
89 Table.Insert(self, SqlCommand)
90
91 return self.ID