summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/FfsFileStatement.py
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools/Source/Python/GenFds/FfsFileStatement.py')
-rw-r--r--BaseTools/Source/Python/GenFds/FfsFileStatement.py37
1 files changed, 15 insertions, 22 deletions
diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
index 4c35aac76a..7479efff04 100644
--- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py
@@ -16,26 +16,22 @@
# Import Modules
#
from __future__ import absolute_import
-from . import Ffs
-from . import Rule
-import Common.LongFilePathOs as os
from io import BytesIO
-import subprocess
-
-from .GenFdsGlobalVariable import GenFdsGlobalVariable
+from struct import pack
from CommonDataClass.FdfClass import FileStatementClassObject
from Common import EdkLogger
-from Common.BuildToolError import *
-from Common.Misc import GuidStructureByteArrayToGuidString
+from Common.BuildToolError import GENFDS_ERROR
+from Common.Misc import GuidStructureByteArrayToGuidString, SaveFileOnChange
+import Common.LongFilePathOs as os
from .GuidSection import GuidSection
from .FvImageSection import FvImageSection
-from Common.Misc import SaveFileOnChange
-from struct import *
+from .Ffs import FdfFvFileTypeToFileType
+from .GenFdsGlobalVariable import GenFdsGlobalVariable
## generate FFS from FILE
#
#
-class FileStatement (FileStatementClassObject) :
+class FileStatement (FileStatementClassObject):
## The constructor
#
# @param self The object pointer
@@ -60,7 +56,7 @@ class FileStatement (FileStatementClassObject) :
#
def GenFfs(self, Dict = {}, FvChildAddr=[], FvParentAddr=None, IsMakefile=False, FvName=None):
- if self.NameGuid is not None and self.NameGuid.startswith('PCD('):
+ if self.NameGuid and self.NameGuid.startswith('PCD('):
PcdValue = GenFdsGlobalVariable.GetPcdValue(self.NameGuid)
if len(PcdValue) == 0:
EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \
@@ -82,7 +78,7 @@ class FileStatement (FileStatementClassObject) :
Dict.update(self.DefineVarDict)
SectionAlignments = None
- if self.FvName is not None :
+ if self.FvName:
Buffer = BytesIO('')
if self.FvName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FvDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FV (%s) is NOT described in FDF file!" % (self.FvName))
@@ -90,14 +86,14 @@ class FileStatement (FileStatementClassObject) :
FileName = Fv.AddToBuffer(Buffer)
SectionFiles = [FileName]
- elif self.FdName is not None:
+ elif self.FdName:
if self.FdName.upper() not in GenFdsGlobalVariable.FdfParser.Profile.FdDict:
EdkLogger.error("GenFds", GENFDS_ERROR, "FD (%s) is NOT described in FDF file!" % (self.FdName))
Fd = GenFdsGlobalVariable.FdfParser.Profile.FdDict.get(self.FdName.upper())
FileName = Fd.GenFd()
SectionFiles = [FileName]
- elif self.FileName is not None:
+ elif self.FileName:
if hasattr(self, 'FvFileType') and self.FvFileType == 'RAW':
if isinstance(self.FileName, list) and isinstance(self.SubAlignment, list) and len(self.FileName) == len(self.SubAlignment):
FileContent = ''
@@ -111,7 +107,7 @@ class FileStatement (FileStatementClassObject) :
Content = f.read()
f.close()
AlignValue = 1
- if self.SubAlignment[Index] is not None:
+ if self.SubAlignment[Index]:
AlignValue = GenFdsGlobalVariable.GetAlignment(self.SubAlignment[Index])
if AlignValue > MaxAlignValue:
MaxAlignIndex = Index
@@ -143,7 +139,7 @@ class FileStatement (FileStatementClassObject) :
SectionFiles = []
Index = 0
SectionAlignments = []
- for section in self.SectionList :
+ for section in self.SectionList:
Index = Index + 1
SecIndex = '%d' %Index
# process the inside FvImage from FvSection or GuidSection
@@ -152,7 +148,7 @@ class FileStatement (FileStatementClassObject) :
section.FvAddr = FvChildAddr.pop(0)
elif isinstance(section, GuidSection):
section.FvAddr = FvChildAddr
- if FvParentAddr is not None and isinstance(section, GuidSection):
+ if FvParentAddr and isinstance(section, GuidSection):
section.FvParentAddr = FvParentAddr
if self.KeepReloc == False:
@@ -168,7 +164,7 @@ class FileStatement (FileStatementClassObject) :
#
FfsFileOutput = os.path.join(OutputDir, self.NameGuid + '.ffs')
GenFdsGlobalVariable.GenerateFfs(FfsFileOutput, SectionFiles,
- Ffs.Ffs.FdfFvFileTypeToFileType.get(self.FvFileType),
+ FdfFvFileTypeToFileType.get(self.FvFileType),
self.NameGuid,
Fixed=self.Fixed,
CheckSum=self.CheckSum,
@@ -177,6 +173,3 @@ class FileStatement (FileStatementClassObject) :
)
return FfsFileOutput
-
-
-