GenFds Tool: Add FdfClassObject.
[people/mcb30/basetools.git] / Source / Python / GenFds / UiSection.py
1 import Section\r
2 from Ffs import Ffs\r
3 import subprocess\r
4 import os\r
5 from GenFdsGlobalVariable import GenFdsGlobalVariable\r
6 from CommonDataClass.FdfClassObject import UiSectionClassObject\r
7 \r
8 class UiSection (UiSectionClassObject):\r
9     def __init__(self):\r
10 ##        self.Alignment = None\r
11 ##        self.StringData = None\r
12 ##        self.FileName = None\r
13         UiSectionClassObject.__init__(self)\r
14 \r
15     def GenSection(self, OutputPath, ModuleName, KeyStringList, FfsInf = None):\r
16         #\r
17         # Prepare the parameter of GenSection\r
18         #\r
19         if FfsInf != None:\r
20             self.Alignment = FfsInf.__ExtendMarco__(self.Alignment)\r
21             self.StringData = FfsInf.__ExtendMarco__(self.StringData)\r
22             self.FileName = FfsInf.__ExtendMarco__(self.FileName)\r
23             \r
24         OutputFile = os.path.join(OutputPath, ModuleName + Ffs.SectionSuffix.get('UI'))\r
25                      \r
26         if self.StringData != None :\r
27             NameString = self.StringData\r
28         elif self.FileName != None:\r
29             f = open(self.FileName, 'r')\r
30             NameString = f.read()\r
31             f.close()\r
32         else:\r
33             NameString = ''\r
34             \r
35             \r
36         GenSectionCmd = 'GenSec -o '                       + \\r
37                          OutputFile                        + \\r
38                          ' -s EFI_SECTION_USER_INTERFACE ' + \\r
39                          '-n '                             + \\r
40                           '\"'                             + \\r
41                           NameString                       + \\r
42                           '\"'\r
43         #\r
44         # Call GenSection\r
45         #\r
46         print GenSectionCmd\r
47         GenFdsGlobalVariable.CallExternalTool(GenSectionCmd,"GenSection Failed!")\r
48         return OutputFile, self.Alignment\r