summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/GenFds/Capsule.py
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2018-10-24 01:29:19 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-10-25 20:14:49 +0800
commit9e47e6f90880e090cd81f585abd7a6c553fbce10 (patch)
treec280e390d282db4c41d64718b366c1c3e64dc9ba /BaseTools/Source/Python/GenFds/Capsule.py
parent0019375fbc89e4d7cfebe29e288b74731bd9f456 (diff)
downloadedk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.tar.gz
edk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.tar.bz2
edk2-9e47e6f90880e090cd81f585abd7a6c553fbce10.zip
BaseTools/GenFds: cleanup GenFds
1) remove wildcard imports and use explicit imports 2) refactor to use shared variables from Common/DataType 3) rename to not shadow imports 4) don't assign a variable in a loop (just do final assignment) 5) remove spaces, parens, unused or commented out code, etc. 6) merge unnecessary parent classes into child 7) refactor to share DXE and PEI apriori GUIDs from one place this includes changes to Build and EOT files 8) for PEP8, dont use __ for custom methods. Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Bob C Feng <bob.c.feng@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/GenFds/Capsule.py')
-rw-r--r--BaseTools/Source/Python/GenFds/Capsule.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py
index baa6e1dfa2..df29c40dbd 100644
--- a/BaseTools/Source/Python/GenFds/Capsule.py
+++ b/BaseTools/Source/Python/GenFds/Capsule.py
@@ -16,22 +16,18 @@
# Import Modules
#
from __future__ import absolute_import
-from .GenFdsGlobalVariable import GenFdsGlobalVariable
-from .GenFdsGlobalVariable import FindExtendTool
+from .GenFdsGlobalVariable import GenFdsGlobalVariable, FindExtendTool
from CommonDataClass.FdfClass import CapsuleClassObject
import Common.LongFilePathOs as os
-import subprocess
from io import BytesIO
-from Common.Misc import SaveFileOnChange
-from Common.Misc import PackRegistryFormatGuid
+from Common.Misc import SaveFileOnChange, PackRegistryFormatGuid
import uuid
from struct import pack
from Common import EdkLogger
-from Common.BuildToolError import *
+from Common.BuildToolError import GENFDS_ERROR
+from Common.DataType import TAB_LINE_BREAK
-
-T_CHAR_LF = '\n'
-WIN_CERT_REVISION = 0x0200
+WIN_CERT_REVISION = 0x0200
WIN_CERT_TYPE_EFI_GUID = 0x0EF1
EFI_CERT_TYPE_PKCS7_GUID = uuid.UUID('{4aafd29d-68df-49ee-8aa9-347d375665a7}')
EFI_CERT_TYPE_RSA2048_SHA256_GUID = uuid.UUID('{a7717414-c616-4977-9420-844712a735bf}')
@@ -39,7 +35,7 @@ EFI_CERT_TYPE_RSA2048_SHA256_GUID = uuid.UUID('{a7717414-c616-4977-9420-844712a7
## create inf file describes what goes into capsule and call GenFv to generate capsule
#
#
-class Capsule (CapsuleClassObject) :
+class Capsule (CapsuleClassObject):
## The constructor
#
# @param self The object pointer
@@ -210,16 +206,16 @@ class Capsule (CapsuleClassObject) :
return self.GenFmpCapsule()
CapInfFile = self.GenCapInf()
- CapInfFile.writelines("[files]" + T_CHAR_LF)
+ CapInfFile.writelines("[files]" + TAB_LINE_BREAK)
CapFileList = []
- for CapsuleDataObj in self.CapsuleDataList :
+ for CapsuleDataObj in self.CapsuleDataList:
CapsuleDataObj.CapsuleName = self.CapsuleName
FileName = CapsuleDataObj.GenCapsuleSubItem()
CapsuleDataObj.CapsuleName = None
CapFileList.append(FileName)
CapInfFile.writelines("EFI_FILE_NAME = " + \
FileName + \
- T_CHAR_LF)
+ TAB_LINE_BREAK)
SaveFileOnChange(self.CapInfFileName, CapInfFile.getvalue(), False)
CapInfFile.close()
#
@@ -249,13 +245,13 @@ class Capsule (CapsuleClassObject) :
self.UiCapsuleName + "_Cap" + '.inf')
CapInfFile = BytesIO() #open (self.CapInfFileName , 'w+')
- CapInfFile.writelines("[options]" + T_CHAR_LF)
+ CapInfFile.writelines("[options]" + TAB_LINE_BREAK)
for Item in self.TokensDict:
CapInfFile.writelines("EFI_" + \
Item + \
' = ' + \
self.TokensDict[Item] + \
- T_CHAR_LF)
+ TAB_LINE_BREAK)
return CapInfFile