]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Workspace/MetaFileTable.py
2 # This file is used to create/update/query/erase a meta file table
4 # Copyright (c) 2008, 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
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.
17 import Common
.EdkLogger
as EdkLogger
18 from MetaDataTable
import Table
19 from MetaDataTable
import ConvertToSqlString
21 ## Python class representation of table storing module data
22 class ModuleTable(Table
):
23 # TRICK: use file ID as the part before '.'
24 _ID_STEP_
= 0.00000001
28 Model INTEGER NOT NULL,
34 BelongsToItem REAL NOT NULL,
35 StartLine INTEGER NOT NULL,
36 StartColumn INTEGER NOT NULL,
37 EndLine INTEGER NOT NULL,
38 EndColumn INTEGER NOT NULL,
39 Enabled INTEGER DEFAULT 0
41 # used as table end flag, in case the changes to database is not committed to db file
42 _DUMMY_
= "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1"
45 def __init__(self
, Cursor
, Name
='Inf', IdBase
=0, Temporary
=False):
46 Table
.__init
__(self
, Cursor
, Name
, IdBase
, Temporary
)
48 ## Insert a record into table Inf
50 # @param Model: Model of a Inf item
51 # @param Value1: Value1 of a Inf item
52 # @param Value2: Value2 of a Inf item
53 # @param Value3: Value3 of a Inf item
54 # @param Scope1: Arch of a Inf item
55 # @param Scope2 Platform os a Inf item
56 # @param BelongsToItem: The item belongs to which another item
57 # @param StartLine: StartLine of a Inf item
58 # @param StartColumn: StartColumn of a Inf item
59 # @param EndLine: EndLine of a Inf item
60 # @param EndColumn: EndColumn of a Inf item
61 # @param Enabled: If this item enabled
63 def Insert(self
, Model
, Value1
, Value2
, Value3
, Scope1
='COMMON', Scope2
='COMMON',
64 BelongsToItem
=-1, StartLine
=-1, StartColumn
=-1, EndLine
=-1, EndColumn
=-1, Enabled
=0):
65 (Value1
, Value2
, Value3
, Scope1
, Scope2
) = ConvertToSqlString((Value1
, Value2
, Value3
, Scope1
, Scope2
))
84 # @param Model: The Model of Record
85 # @param Arch: The Arch attribute of Record
86 # @param Platform The Platform attribute of Record
88 # @retval: A recordSet of all found records
90 def Query(self
, Model
, Arch
=None, Platform
=None):
91 ConditionString
= "Model=%s AND Enabled>=0" % Model
92 ValueString
= "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
94 if Arch
!= None and Arch
!= 'COMMON':
95 ConditionString
+= " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
96 if Platform
!= None and Platform
!= 'COMMON':
97 ConditionString
+= " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Platform
99 SqlCommand
= "SELECT %s FROM %s WHERE %s" % (ValueString
, self
.Table
, ConditionString
)
100 return self
.Exec(SqlCommand
)
102 ## Python class representation of table storing package data
103 class PackageTable(Table
):
104 _ID_STEP_
= 0.00000001
105 _ID_MAX_
= 0.99999999
108 Model INTEGER NOT NULL,
109 Value1 TEXT NOT NULL,
114 BelongsToItem REAL NOT NULL,
115 StartLine INTEGER NOT NULL,
116 StartColumn INTEGER NOT NULL,
117 EndLine INTEGER NOT NULL,
118 EndColumn INTEGER NOT NULL,
119 Enabled INTEGER DEFAULT 0
121 # used as table end flag, in case the changes to database is not committed to db file
122 _DUMMY_
= "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1"
125 def __init__(self
, Cursor
, Name
='Dec', IdBase
=0, Temporary
=False):
126 Table
.__init
__(self
, Cursor
, Name
, IdBase
, Temporary
)
130 # Insert a record into table Dec
132 # @param Model: Model of a Dec item
133 # @param Value1: Value1 of a Dec item
134 # @param Value2: Value2 of a Dec item
135 # @param Value3: Value3 of a Dec item
136 # @param Scope1: Arch of a Dec item
137 # @param Scope2: Module type of a Dec item
138 # @param BelongsToItem: The item belongs to which another item
139 # @param StartLine: StartLine of a Dec item
140 # @param StartColumn: StartColumn of a Dec item
141 # @param EndLine: EndLine of a Dec item
142 # @param EndColumn: EndColumn of a Dec item
143 # @param Enabled: If this item enabled
145 def Insert(self
, Model
, Value1
, Value2
, Value3
, Scope1
='COMMON', Scope2
='COMMON',
146 BelongsToItem
=-1, StartLine
=-1, StartColumn
=-1, EndLine
=-1, EndColumn
=-1, Enabled
=0):
147 (Value1
, Value2
, Value3
, Scope1
, Scope2
) = ConvertToSqlString((Value1
, Value2
, Value3
, Scope1
, Scope2
))
166 # @param Model: The Model of Record
167 # @param Arch: The Arch attribute of Record
169 # @retval: A recordSet of all found records
171 def Query(self
, Model
, Arch
=None):
172 ConditionString
= "Model=%s AND Enabled>=0" % Model
173 ValueString
= "Value1,Value2,Value3,Scope1,ID,StartLine"
175 if Arch
!= None and Arch
!= 'COMMON':
176 ConditionString
+= " AND (Scope1='%s' OR Scope1='COMMON')" % Arch
178 SqlCommand
= "SELECT %s FROM %s WHERE %s" % (ValueString
, self
.Table
, ConditionString
)
179 return self
.Exec(SqlCommand
)
181 ## Python class representation of table storing platform data
182 class PlatformTable(Table
):
183 _ID_STEP_
= 0.00000001
184 _ID_MAX_
= 0.99999999
187 Model INTEGER NOT NULL,
188 Value1 TEXT NOT NULL,
193 BelongsToItem REAL NOT NULL,
194 FromItem REAL NOT NULL,
195 StartLine INTEGER NOT NULL,
196 StartColumn INTEGER NOT NULL,
197 EndLine INTEGER NOT NULL,
198 EndColumn INTEGER NOT NULL,
199 Enabled INTEGER DEFAULT 0
201 # used as table end flag, in case the changes to database is not committed to db file
202 _DUMMY_
= "-1, -1, '====', '====', '====', '====', '====', -1, -1, -1, -1, -1, -1, -1"
205 def __init__(self
, Cursor
, Name
='Dsc', IdBase
=0, Temporary
=False):
206 Table
.__init
__(self
, Cursor
, Name
, IdBase
, Temporary
)
210 # Insert a record into table Dsc
212 # @param Model: Model of a Dsc item
213 # @param Value1: Value1 of a Dsc item
214 # @param Value2: Value2 of a Dsc item
215 # @param Value3: Value3 of a Dsc item
216 # @param Scope1: Arch of a Dsc item
217 # @param Scope2: Module type of a Dsc item
218 # @param BelongsToItem: The item belongs to which another item
219 # @param FromItem: The item belongs to which dsc file
220 # @param StartLine: StartLine of a Dsc item
221 # @param StartColumn: StartColumn of a Dsc item
222 # @param EndLine: EndLine of a Dsc item
223 # @param EndColumn: EndColumn of a Dsc item
224 # @param Enabled: If this item enabled
226 def Insert(self
, Model
, Value1
, Value2
, Value3
, Scope1
='COMMON', Scope2
='COMMON', BelongsToItem
=-1,
227 FromItem
=-1, StartLine
=-1, StartColumn
=-1, EndLine
=-1, EndColumn
=-1, Enabled
=1):
228 (Value1
, Value2
, Value3
, Scope1
, Scope2
) = ConvertToSqlString((Value1
, Value2
, Value3
, Scope1
, Scope2
))
248 # @param Model: The Model of Record
249 # @param Scope1: Arch of a Dsc item
250 # @param Scope2: Module type of a Dsc item
251 # @param BelongsToItem: The item belongs to which another item
252 # @param FromItem: The item belongs to which dsc file
254 # @retval: A recordSet of all found records
256 def Query(self
, Model
, Scope1
=None, Scope2
=None, BelongsToItem
=None, FromItem
=None):
257 ConditionString
= "Model=%s AND Enabled>=0" % Model
258 ValueString
= "Value1,Value2,Value3,Scope1,Scope2,ID,StartLine"
260 if Scope1
!= None and Scope1
!= 'COMMON':
261 ConditionString
+= " AND (Scope1='%s' OR Scope1='COMMON')" % Scope1
262 if Scope2
!= None and Scope2
!= 'COMMON':
263 ConditionString
+= " AND (Scope2='%s' OR Scope2='COMMON' OR Scope2='DEFAULT')" % Scope2
265 if BelongsToItem
!= None:
266 ConditionString
+= " AND BelongsToItem=%s" % BelongsToItem
268 ConditionString
+= " AND BelongsToItem<0"
271 ConditionString
+= " AND FromItem=%s" % FromItem
273 SqlCommand
= "SELECT %s FROM %s WHERE %s" % (ValueString
, self
.Table
, ConditionString
)
274 return self
.Exec(SqlCommand
)