2 # This file is used to define each component of FDF file
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 from FdfParserLite
import FdfParser
18 from Table
.TableFdf
import TableFdf
19 from CommonDataClass
.DataClass
import MODEL_FILE_FDF
, MODEL_PCD
, MODEL_META_DATA_COMPONENT
20 from String
import NormPath
25 # This class defined the structure used in Fdf object
27 # @param Filename: Input value for Ffilename of Fdf file, default is None
28 # @param WorkspaceDir: Input value for current workspace directory, default is None
31 def __init__(self
, Filename
= None, IsToDatabase
= False, WorkspaceDir
= None, Database
= None):
32 self
.WorkspaceDir
= WorkspaceDir
33 self
.IsToDatabase
= IsToDatabase
35 self
.Cur
= Database
.Cur
36 self
.TblFile
= Database
.TblFile
37 self
.TblFdf
= Database
.TblFdf
42 # Load Fdf file if filename is not None
44 if Filename
is not None:
45 self
.LoadFdfFile(Filename
)
48 # Insert a FDF file record into database
50 def InsertFile(self
, Filename
):
52 Filename
= NormPath(Filename
)
53 if Filename
not in self
.FileList
:
54 FileID
= self
.TblFile
.InsertFile(Filename
, MODEL_FILE_FDF
)
55 self
.FileList
[Filename
] = FileID
57 return self
.FileList
[Filename
]
62 # Load the file if it exists
64 # @param Filename: Input value for filename of Fdf file
66 def LoadFdfFile(self
, Filename
):
71 Filename
= NormPath(Filename
)
72 Fdf
= FdfParser(Filename
)
76 # Insert inf file and pcd information
79 (Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
) = \
80 (0, '', '', '', 'COMMON', -1, -1, -1, -1, -1, -1, 0)
81 for Index
in range(0, len(Fdf
.Profile
.PcdDict
)):
83 for Key
in Fdf
.Profile
.PcdDict
.keys():
86 Value2
= ".".join((Key
[1], Key
[0]))
87 FileName
= Fdf
.Profile
.PcdFileLineDict
[Key
][0]
88 StartLine
= Fdf
.Profile
.PcdFileLineDict
[Key
][1]
89 BelongsToFile
= self
.InsertFile(FileName
)
90 self
.TblFdf
.Insert(Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
91 for Index
in range(0, len(Fdf
.Profile
.InfList
)):
92 Model
= MODEL_META_DATA_COMPONENT
93 Value1
= Fdf
.Profile
.InfList
[Index
]
95 FileName
= Fdf
.Profile
.InfFileLineList
[Index
][0]
96 StartLine
= Fdf
.Profile
.InfFileLineList
[Index
][1]
97 BelongsToFile
= self
.InsertFile(FileName
)
98 self
.TblFdf
.Insert(Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
102 # This acts like the main() function for the script, unless it is 'import'ed into another
105 if __name__
== '__main__':