From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Yonghong Zhu <yonghong.zhu@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v1 1/1] BaseTools: Eot - fix variable names
Date: Tue, 7 Aug 2018 15:37:14 -0700 [thread overview]
Message-ID: <2909e69e0a6e75b3db5a5abf87b256803e0016fa.1533681419.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1533681419.git.jaben.carsey@intel.com>
1) currently a couple classes use m instead of self (including some mixed
functions that should have previously failed).
2) deleted some blank lines.
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/Eot/Eot.py | 298 ++++++++++----------
1 file changed, 144 insertions(+), 154 deletions(-)
diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py
index 6fb882642bff..ce83da14957b 100644
--- a/BaseTools/Source/Python/Eot/Eot.py
+++ b/BaseTools/Source/Python/Eot/Eot.py
@@ -123,49 +123,49 @@ class CompressedImage(Image):
_ORIG_SIZE_ = struct.Struct("1I")
_CMPRS_TYPE_ = struct.Struct("4x 1B")
- def __init__(m, CompressedData=None, CompressionType=None, UncompressedLength=None):
- Image.__init__(m)
+ def __init__(self, CompressedData=None, CompressionType=None, UncompressedLength=None):
+ Image.__init__(self)
if UncompressedLength is not None:
- m.UncompressedLength = UncompressedLength
+ self.UncompressedLength = UncompressedLength
if CompressionType is not None:
- m.CompressionType = CompressionType
+ self.CompressionType = CompressionType
if CompressedData is not None:
- m.Data = CompressedData
+ self.Data = CompressedData
- def __str__(m):
+ def __str__(self):
global gIndention
- S = "algorithm=%s uncompressed=%x" % (m.CompressionType, m.UncompressedLength)
- for Sec in m.Sections:
+ S = "algorithm=%s uncompressed=%x" % (self.CompressionType, self.UncompressedLength)
+ for Sec in self.Sections:
S += '\n' + str(Sec)
return S
- def _SetOriginalSize(m, Size):
- m.SetField(m._ORIG_SIZE_, 0, Size)
+ def _SetOriginalSize(self, Size):
+ self.SetField(self._ORIG_SIZE_, 0, Size)
- def _GetOriginalSize(m):
- return m.GetField(m._ORIG_SIZE_)[0]
+ def _GetOriginalSize(self):
+ return self.GetField(self._ORIG_SIZE_)[0]
- def _SetCompressionType(m, Type):
- m.SetField(m._CMPRS_TYPE_, 0, Type)
+ def _SetCompressionType(self, Type):
+ self.SetField(self._CMPRS_TYPE_, 0, Type)
- def _GetCompressionType(m):
- return m.GetField(m._CMPRS_TYPE_)[0]
+ def _GetCompressionType(self):
+ return self.GetField(self._CMPRS_TYPE_)[0]
- def _GetSections(m):
+ def _GetSections(self):
try:
from . import EfiCompressor
TmpData = EfiCompressor.FrameworkDecompress(
- m[m._HEADER_SIZE_:],
- len(m) - m._HEADER_SIZE_
+ self[self._HEADER_SIZE_:],
+ len(self) - self._HEADER_SIZE_
)
DecData = array('B')
DecData.fromstring(TmpData)
except:
from . import EfiCompressor
TmpData = EfiCompressor.UefiDecompress(
- m[m._HEADER_SIZE_:],
- len(m) - m._HEADER_SIZE_
+ self[self._HEADER_SIZE_:],
+ len(self) - self._HEADER_SIZE_
)
DecData = array('B')
DecData.fromstring(TmpData)
@@ -195,20 +195,20 @@ class Ui(Image):
_HEADER_ = struct.Struct("")
_HEADER_SIZE_ = 0
- def __init__(m):
- Image.__init__(m)
+ def __init__(self):
+ Image.__init__(self)
- def __str__(m):
- return m.String
+ def __str__(self):
+ return self.String
- def _Unpack(m):
+ def _Unpack(self):
# keep header in this Image object
- m.empty()
- m.extend(m._BUF_[m._OFF_ : m._OFF_ + m._LEN_])
- return len(m)
+ self.empty()
+ self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_])
+ return len(self)
- def _GetUiString(m):
- return codecs.utf_16_decode(m[0:-2].tostring())[0]
+ def _GetUiString(self):
+ return codecs.utf_16_decode(self[0:-2].tostring())[0]
String = property(_GetUiString)
@@ -250,18 +250,18 @@ class Depex(Image):
0x09 : _OPCODE_, #"SOR"
}
- def __init__(m):
- Image.__init__(m)
- m._ExprList = []
+ def __init__(self):
+ Image.__init__(self)
+ self._ExprList = []
- def __str__(m):
+ def __str__(self):
global gIndention
gIndention += 4
Indention = ' ' * gIndention
S = '\n'
- for T in m.Expression:
- if T in m._OPCODE_STRING_:
- S += Indention + m._OPCODE_STRING_[T]
+ for T in self.Expression:
+ if T in self._OPCODE_STRING_:
+ S += Indention + self._OPCODE_STRING_[T]
if T not in [0x00, 0x01, 0x02]:
S += '\n'
else:
@@ -269,31 +269,31 @@ class Depex(Image):
gIndention -= 4
return S
- def _Unpack(m):
+ def _Unpack(self):
# keep header in this Image object
- m.empty()
- m.extend(m._BUF_[m._OFF_ : m._OFF_ + m._LEN_])
- return len(m)
+ self.empty()
+ self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_])
+ return len(self)
- def _GetExpression(m):
- if m._ExprList == []:
+ def _GetExpression(self):
+ if self._ExprList == []:
Offset = 0
- CurrentData = m._OPCODE_
- while Offset < len(m):
- Token = CurrentData.unpack_from(m, Offset)
+ CurrentData = self._OPCODE_
+ while Offset < len(self):
+ Token = CurrentData.unpack_from(self, Offset)
Offset += CurrentData.size
if len(Token) == 1:
Token = Token[0]
- if Token in m._NEXT_:
- CurrentData = m._NEXT_[Token]
+ if Token in self._NEXT_:
+ CurrentData = self._NEXT_[Token]
else:
- CurrentData = m._GUID_
+ CurrentData = self._GUID_
else:
- CurrentData = m._OPCODE_
- m._ExprList.append(Token)
+ CurrentData = self._OPCODE_
+ self._ExprList.append(Token)
if CurrentData is None:
break
- return m._ExprList
+ return self._ExprList
Expression = property(_GetExpression)
@@ -326,9 +326,7 @@ class FirmwareVolume(Image):
def CheckArchProtocol(self):
for Item in EotGlobalData.gArchProtocolGuids:
if Item.lower() not in EotGlobalData.gProtocolList:
-
return False
-
return True
def ParseDepex(self, Depex, Type):
@@ -441,7 +439,6 @@ class FirmwareVolume(Image):
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadPpi(Db, GuidString)
-
self.DisPatchPei(Db)
# Parse DXE then
@@ -463,7 +460,6 @@ class FirmwareVolume(Image):
if GuidString in self.UnDispatchedFfsDict:
self.OrderedFfsDict[GuidString] = self.UnDispatchedFfsDict.pop(GuidString)
self.LoadProtocol(Db, GuidString)
-
self.DisPatchDxe(Db)
def LoadProtocol(self, Db, ModuleGuid):
@@ -564,7 +560,6 @@ class FirmwareVolume(Image):
RecordSet = Db.TblReport.Exec(SqlCommand)
if RecordSet != []:
FfsName = RecordSet[0][0]
-
if IsInstalled:
self.DisPatchDxe(Db)
@@ -608,7 +603,6 @@ class FirmwareVolume(Image):
if IsInstalled:
self.DisPatchPei(Db)
-
def __str__(self):
global gIndention
gIndention += 4
@@ -690,69 +684,69 @@ class GuidDefinedImage(Image):
TIANO_COMPRESS_GUID = 'A31280AD-481E-41B6-95E8-127F4C984779'
LZMA_COMPRESS_GUID = 'EE4E5898-3914-4259-9D6E-DC7BD79403CF'
- def __init__(m, SectionDefinitionGuid=None, DataOffset=None, Attributes=None, Data=None):
- Image.__init__(m)
+ def __init__(self, SectionDefinitionGuid=None, DataOffset=None, Attributes=None, Data=None):
+ Image.__init__(self)
if SectionDefinitionGuid is not None:
- m.SectionDefinitionGuid = SectionDefinitionGuid
+ self.SectionDefinitionGuid = SectionDefinitionGuid
if DataOffset is not None:
- m.DataOffset = DataOffset
+ self.DataOffset = DataOffset
if Attributes is not None:
- m.Attributes = Attributes
+ self.Attributes = Attributes
if Data is not None:
- m.Data = Data
+ self.Data = Data
- def __str__(m):
- S = "guid=%s" % (gGuidStringFormat % m.SectionDefinitionGuid)
- for Sec in m.Sections:
+ def __str__(self):
+ S = "guid=%s" % (gGuidStringFormat % self.SectionDefinitionGuid)
+ for Sec in self.Sections:
S += "\n" + str(Sec)
return S
- def _Unpack(m):
+ def _Unpack(self):
# keep header in this Image object
- m.empty()
- m.extend(m._BUF_[m._OFF_ : m._OFF_ + m._LEN_])
- return len(m)
+ self.empty()
+ self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._LEN_])
+ return len(self)
- def _SetAttribute(m, Attribute):
- m.SetField(m._ATTR_, 0, Attribute)
+ def _SetAttribute(self, Attribute):
+ self.SetField(self._ATTR_, 0, Attribute)
- def _GetAttribute(m):
- return m.GetField(m._ATTR_)[0]
+ def _GetAttribute(self):
+ return self.GetField(self._ATTR_)[0]
- def _SetGuid(m, Guid):
- m.SetField(m._GUID_, 0, Guid)
+ def _SetGuid(self, Guid):
+ self.SetField(self._GUID_, 0, Guid)
- def _GetGuid(m):
- return m.GetField(m._GUID_)
+ def _GetGuid(self):
+ return self.GetField(self._GUID_)
- def _SetDataOffset(m, Offset):
- m.SetField(m._DATA_OFFSET_, 0, Offset)
+ def _SetDataOffset(self, Offset):
+ self.SetField(self._DATA_OFFSET_, 0, Offset)
- def _GetDataOffset(m):
- return m.GetField(m._DATA_OFFSET_)[0]
+ def _GetDataOffset(self):
+ return self.GetField(self._DATA_OFFSET_)[0]
- def _GetSections(m):
+ def _GetSections(self):
SectionList = []
- Guid = gGuidStringFormat % m.SectionDefinitionGuid
- if Guid == m.CRC32_GUID:
+ Guid = gGuidStringFormat % self.SectionDefinitionGuid
+ if Guid == self.CRC32_GUID:
# skip the CRC32 value, we don't do CRC32 verification here
- Offset = m.DataOffset - 4
- while Offset < len(m):
+ Offset = self.DataOffset - 4
+ while Offset < len(self):
Sec = Section()
try:
- Sec.frombuffer(m, Offset)
+ Sec.frombuffer(self, Offset)
Offset += Sec.Size
# the section is aligned to 4-byte boundary
Offset = (Offset + 3) & (~3)
except:
break
SectionList.append(Sec)
- elif Guid == m.TIANO_COMPRESS_GUID:
+ elif Guid == self.TIANO_COMPRESS_GUID:
try:
from . import EfiCompressor
# skip the header
- Offset = m.DataOffset - 4
- TmpData = EfiCompressor.FrameworkDecompress(m[Offset:], len(m)-Offset)
+ Offset = self.DataOffset - 4
+ TmpData = EfiCompressor.FrameworkDecompress(self[Offset:], len(self)-Offset)
DecData = array('B')
DecData.fromstring(TmpData)
Offset = 0
@@ -768,12 +762,12 @@ class GuidDefinedImage(Image):
SectionList.append(Sec)
except:
pass
- elif Guid == m.LZMA_COMPRESS_GUID:
+ elif Guid == self.LZMA_COMPRESS_GUID:
try:
from . import LzmaCompressor
# skip the header
- Offset = m.DataOffset - 4
- TmpData = LzmaCompressor.LzmaDecompress(m[Offset:], len(m)-Offset)
+ Offset = self.DataOffset - 4
+ TmpData = LzmaCompressor.LzmaDecompress(self[Offset:], len(self)-Offset)
DecData = array('B')
DecData.fromstring(TmpData)
Offset = 0
@@ -835,90 +829,89 @@ class Section(Image):
# SubTypeGuid
# _FREE_FORM_SUBTYPE_GUID_HEADER_ = struct.Struct("1I2H8B")
-
_SIZE_ = struct.Struct("3B")
_TYPE_ = struct.Struct("3x 1B")
- def __init__(m, Type=None, Size=None):
- Image.__init__(m)
- m._Alignment = 1
+ def __init__(self, Type=None, Size=None):
+ Image.__init__(self)
+ self._Alignment = 1
if Type is not None:
- m.Type = Type
+ self.Type = Type
if Size is not None:
- m.Size = Size
+ self.Size = Size
- def __str__(m):
+ def __str__(self):
global gIndention
gIndention += 4
SectionInfo = ' ' * gIndention
- if m.Type in m._TypeName:
- SectionInfo += "[SECTION:%s] offset=%x size=%x" % (m._TypeName[m.Type], m._OFF_, m.Size)
+ if self.Type in self._TypeName:
+ SectionInfo += "[SECTION:%s] offset=%x size=%x" % (self._TypeName[self.Type], self._OFF_, self.Size)
else:
- SectionInfo += "[SECTION:%x<unknown>] offset=%x size=%x " % (m.Type, m._OFF_, m.Size)
- for Offset in m._SubImages:
- SectionInfo += ", " + str(m._SubImages[Offset])
+ SectionInfo += "[SECTION:%x<unknown>] offset=%x size=%x " % (self.Type, self._OFF_, self.Size)
+ for Offset in self._SubImages:
+ SectionInfo += ", " + str(self._SubImages[Offset])
gIndention -= 4
return SectionInfo
- def _Unpack(m):
- m.empty()
- Type, = m._TYPE_.unpack_from(m._BUF_, m._OFF_)
- Size1, Size2, Size3 = m._SIZE_.unpack_from(m._BUF_, m._OFF_)
+ def _Unpack(self):
+ self.empty()
+ Type, = self._TYPE_.unpack_from(self._BUF_, self._OFF_)
+ Size1, Size2, Size3 = self._SIZE_.unpack_from(self._BUF_, self._OFF_)
Size = Size1 + (Size2 << 8) + (Size3 << 16)
- if Type not in m._SectionSubImages:
+ if Type not in self._SectionSubImages:
# no need to extract sub-image, keep all in this Image object
- m.extend(m._BUF_[m._OFF_ : m._OFF_ + Size])
+ self.extend(self._BUF_[self._OFF_ : self._OFF_ + Size])
else:
# keep header in this Image object
- m.extend(m._BUF_[m._OFF_ : m._OFF_ + m._HEADER_SIZE_])
+ self.extend(self._BUF_[self._OFF_ : self._OFF_ + self._HEADER_SIZE_])
#
# use new Image object to represent payload, which may be another kind
# of image such as PE32
#
- PayloadOffset = m._HEADER_SIZE_
- PayloadLen = m.Size - m._HEADER_SIZE_
- Payload = m._SectionSubImages[m.Type]()
- Payload.frombuffer(m._BUF_, m._OFF_ + m._HEADER_SIZE_, PayloadLen)
- m._SubImages[PayloadOffset] = Payload
+ PayloadOffset = self._HEADER_SIZE_
+ PayloadLen = self.Size - self._HEADER_SIZE_
+ Payload = self._SectionSubImages[self.Type]()
+ Payload.frombuffer(self._BUF_, self._OFF_ + self._HEADER_SIZE_, PayloadLen)
+ self._SubImages[PayloadOffset] = Payload
return Size
- def _SetSize(m, Size):
+ def _SetSize(self, Size):
Size1 = Size & 0xFF
Size2 = (Size & 0xFF00) >> 8
Size3 = (Size & 0xFF0000) >> 16
- m.SetField(m._SIZE_, 0, Size1, Size2, Size3)
+ self.SetField(self._SIZE_, 0, Size1, Size2, Size3)
- def _GetSize(m):
- Size1, Size2, Size3 = m.GetField(m._SIZE_)
+ def _GetSize(self):
+ Size1, Size2, Size3 = self.GetField(self._SIZE_)
return Size1 + (Size2 << 8) + (Size3 << 16)
- def _SetType(m, Type):
- m.SetField(m._TYPE_, 0, Type)
+ def _SetType(self, Type):
+ self.SetField(self._TYPE_, 0, Type)
- def _GetType(m):
- return m.GetField(m._TYPE_)[0]
+ def _GetType(self):
+ return self.GetField(self._TYPE_)[0]
- def _GetAlignment(m):
- return m._Alignment
+ def _GetAlignment(self):
+ return self._Alignment
- def _SetAlignment(m, Alignment):
- m._Alignment = Alignment
+ def _SetAlignment(self, Alignment):
+ self._Alignment = Alignment
AlignmentMask = Alignment - 1
# section alignment is actually for payload, so we need to add header size
- PayloadOffset = m._OFF_ + m._HEADER_SIZE_
+ PayloadOffset = self._OFF_ + self._HEADER_SIZE_
if (PayloadOffset & (~AlignmentMask)) == 0:
return
NewOffset = (PayloadOffset + AlignmentMask) & (~AlignmentMask)
- while (NewOffset - PayloadOffset) < m._HEADER_SIZE_:
- NewOffset += m._Alignment
+ while (NewOffset - PayloadOffset) < self._HEADER_SIZE_:
+ NewOffset += self._Alignment
- def tofile(m, f):
- m.Size = len(m)
- Image.tofile(m, f)
- for Offset in m._SubImages:
- m._SubImages[Offset].tofile(f)
+ def tofile(self, f):
+ self.Size = len(self)
+ Image.tofile(self, f)
+ for Offset in self._SubImages:
+ self._SubImages[Offset].tofile(f)
Type = property(_GetType, _SetType)
Size = property(_GetSize, _SetSize)
@@ -1043,24 +1036,24 @@ class Ffs(Image):
# Guid1, Guid2, Guid3, Guid4, Guid5, Guid6, Guid7, Guid8, Guid9, Guid10, Guid11
return self.GetField(self._NAME_)
- def _SetSize(m, Size):
+ def _SetSize(self, Size):
Size1 = Size & 0xFF
Size2 = (Size & 0xFF00) >> 8
Size3 = (Size & 0xFF0000) >> 16
- m.SetField(m._SIZE_, 0, Size1, Size2, Size3)
+ self.SetField(self._SIZE_, 0, Size1, Size2, Size3)
- def _GetSize(m):
- Size1, Size2, Size3 = m.GetField(m._SIZE_)
+ def _GetSize(self):
+ Size1, Size2, Size3 = self.GetField(self._SIZE_)
return Size1 + (Size2 << 8) + (Size3 << 16)
- def _SetType(m, Type):
- m.SetField(m._TYPE_, 0, Type)
+ def _SetType(self, Type):
+ self.SetField(self._TYPE_, 0, Type)
- def _GetType(m):
- return m.GetField(m._TYPE_)[0]
+ def _GetType(self):
+ return self.GetField(self._TYPE_)[0]
def _SetAttributes(self, Value):
- self.SetField(m._ATTR_, 0, Value)
+ self.SetField(self._ATTR_, 0, Value)
def _GetAttributes(self):
return self.GetField(self._ATTR_)[0]
@@ -1079,10 +1072,10 @@ class Ffs(Image):
return (self.Attributes & self.FFS_ATTRIB_DATA_ALIGNMENT) >> 3
def _SetState(self, Value):
- self.SetField(m._STATE_, 0, Value)
+ self.SetField(self._STATE_, 0, Value)
def _GetState(self):
- return self.GetField(m._STATE_)[0]
+ return self.GetField(self._STATE_)[0]
Name = property(_GetName, _SetName)
Guid = property(_GetGuid)
@@ -1123,9 +1116,7 @@ class FirmwareVolume(Image):
def CheckArchProtocol(self):
for Item in EotGlobalData.gArchProtocolGuids:
if Item.lower() not in EotGlobalData.gProtocolList:
-
return False
-
return True
def ParseDepex(self, Depex, Type):
@@ -1378,7 +1369,6 @@ class FirmwareVolume(Image):
if Section.Type == 0x1B:
CouldBeLoaded, DepexString, FileDepex = self.ParseDepex(Section._SubImages[4], 'Ppi')
break
-
if Section.Type == 0x01:
CompressSections = Section._SubImages[4]
for CompressSection in CompressSections.Sections:
--
2.16.2.windows.1
next parent reply other threads:[~2018-08-07 22:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1533681419.git.jaben.carsey@intel.com>
2018-08-07 22:37 ` Jaben Carsey [this message]
2018-08-13 8:01 ` [PATCH v1 1/1] BaseTools: Eot - fix variable names Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2909e69e0a6e75b3db5a5abf87b256803e0016fa.1533681419.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox