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
24 # This class defined basic Fdf object which is used by inheriting
26 # @param object: Inherited from object class
28 class FdfObject(object):
34 # This class defined the structure used in Fdf object
36 # @param FdfObject: Inherited from FdfObject class
37 # @param Filename: Input value for Ffilename of Fdf file, default is None
38 # @param WorkspaceDir: Input value for current workspace directory, default is None
41 def __init__(self
, Filename
= None, IsToDatabase
= False, WorkspaceDir
= None, Database
= None):
42 self
.WorkspaceDir
= WorkspaceDir
43 self
.IsToDatabase
= IsToDatabase
45 self
.Cur
= Database
.Cur
46 self
.TblFile
= Database
.TblFile
47 self
.TblFdf
= Database
.TblFdf
52 # Load Fdf file if filename is not None
55 self
.LoadFdfFile(Filename
)
58 # Insert a FDF file record into database
60 def InsertFile(self
, Filename
):
62 Filename
= NormPath(Filename
)
63 if Filename
not in self
.FileList
:
64 FileID
= self
.TblFile
.InsertFile(Filename
, MODEL_FILE_FDF
)
65 self
.FileList
[Filename
] = FileID
67 return self
.FileList
[Filename
]
72 # Load the file if it exists
74 # @param Filename: Input value for filename of Fdf file
76 def LoadFdfFile(self
, Filename
):
81 Filename
= NormPath(Filename
)
82 Fdf
= FdfParser(Filename
)
86 # Insert inf file and pcd information
89 (Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
) = \
90 (0, '', '', '', 'COMMON', -1, -1, -1, -1, -1, -1, 0)
91 for Index
in range(0, len(Fdf
.Profile
.PcdDict
)):
93 for Key
in Fdf
.Profile
.PcdDict
.keys():
96 Value2
= ".".join((Key
[1], Key
[0]))
97 FileName
= Fdf
.Profile
.PcdFileLineDict
[Key
][0]
98 StartLine
= Fdf
.Profile
.PcdFileLineDict
[Key
][1]
99 BelongsToFile
= self
.InsertFile(FileName
)
100 self
.TblFdf
.Insert(Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
101 for Index
in range(0, len(Fdf
.Profile
.InfList
)):
102 Model
= MODEL_META_DATA_COMPONENT
103 Value1
= Fdf
.Profile
.InfList
[Index
]
105 FileName
= Fdf
.Profile
.InfFileLineList
[Index
][0]
106 StartLine
= Fdf
.Profile
.InfFileLineList
[Index
][1]
107 BelongsToFile
= self
.InsertFile(FileName
)
108 self
.TblFdf
.Insert(Model
, Value1
, Value2
, Value3
, Arch
, BelongsToItem
, BelongsToFile
, StartLine
, StartColumn
, EndLine
, EndColumn
, Enabled
)
112 # This acts like the main() function for the script, unless it is 'import'ed into another
115 if __name__
== '__main__':