# Import Modules\r
#\r
from __future__ import absolute_import\r
-from . import Ffs\r
-from . import Rule\r
-import Common.LongFilePathOs as os\r
from io import BytesIO\r
-import subprocess\r
-\r
-from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
+from struct import pack\r
from CommonDataClass.FdfClass import FileStatementClassObject\r
from Common import EdkLogger\r
-from Common.BuildToolError import *\r
-from Common.Misc import GuidStructureByteArrayToGuidString\r
+from Common.BuildToolError import GENFDS_ERROR\r
+from Common.Misc import GuidStructureByteArrayToGuidString, SaveFileOnChange\r
+import Common.LongFilePathOs as os\r
from .GuidSection import GuidSection\r
from .FvImageSection import FvImageSection\r
-from Common.Misc import SaveFileOnChange\r
-from struct import *\r
+from .Ffs import FdfFvFileTypeToFileType\r
+from .GenFdsGlobalVariable import GenFdsGlobalVariable\r
\r
## generate FFS from FILE\r
#\r
#\r
-class FileStatement (FileStatementClassObject) :\r
+class FileStatement (FileStatementClassObject):\r
## The constructor\r
#\r
# @param self The object pointer\r
#\r
def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):\r
\r
- if self.NameGuid is not None and self.NameGuid.startswith('PCD('):\r
+ if self.NameGuid and self.NameGuid.startswith('PCD('):\r
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)\r
if len(PcdValue) == 0:\r
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \\r
\r
Dict.update(self.DefineVarDict)\r
SectionAlignments = None\r
- if self.FvName is not None :\r
+ if self.FvName:\r
Buffer = BytesIO('')\r
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:\r
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))\r
FileName = Fv.AddToBuffer(Buffer)\r
SectionFiles = [FileName]\r
\r
- elif self.FdName is not None:\r
+ elif self.FdName:\r
if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:\r
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))\r
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())\r
FileName = Fd.GenFd()\r
SectionFiles = [FileName]\r
\r
- elif self.FileName is not None:\r
+ elif self.FileName:\r
if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':\r
if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):\r
FileContent = ''\r
Content = f.read()\r
f.close()\r
AlignValue = 1\r
- if self.SubAlignment[Index] is not None:\r
+ if self.SubAlignment[Index]:\r
AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])\r
if AlignValue > MaxAlignValue:\r
MaxAlignIndex = Index\r
SectionFiles = []\r
Index = 0\r
SectionAlignments = []\r
- for section in self.SectionList :\r
+ for section in self.SectionList:\r
Index = Index + 1\r
SecIndex = '%d' %Index\r
# process the inside FvImage from FvSection or GuidSection\r
section.FvAddr = FvChildAddr.pop(0)\r
elif isinstance(section, GuidSection):\r
section.FvAddr = FvChildAddr\r
- if FvParentAddr is not None and isinstance(section, GuidSection):\r
+ if FvParentAddr and isinstance(section, GuidSection):\r
section.FvParentAddr = FvParentAddr\r
\r
if self.KeepReloc == False:\r
#\r
FfsFileOutput = os.path.join(OutputDir, self.NameGuid + '.ffs')\r
GenFdsGlobalVariable.GenerateFfs(FfsFileOutput, SectionFiles,\r
- Ffs.Ffs.FdfFvFileTypeToFileType.get(self.FvFileType),\r
+ FdfFvFileTypeToFileType.get(self.FvFileType),\r
self.NameGuid,\r
Fixed=self.Fixed,\r
CheckSum=self.CheckSum,\r
)\r
\r
return FfsFileOutput\r
-\r
-\r
-\r