From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3C0CF2194D3B8 for ; Wed, 29 Aug 2018 08:50:31 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2018 08:50:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,303,1531810800"; d="scan'208";a="85959638" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 29 Aug 2018 08:50:30 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Wed, 29 Aug 2018 08:45:41 -0700 Message-Id: <3362efb9f464f87ca64bd3ceb215d7fb3e3a3b1b.1535557474.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [PATCH v1 6/9] BaseTools: refactor Build Database objects X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2018 15:50:31 -0000 1) use namedtuple instead of custom class when apropriate 2) rename collections.OrderedDict to OrderedDict since we import it already Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/BuildClassObject.py | 32 ++++++-------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index 88465c59ea30..e7259b2d3d50 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -11,8 +11,8 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from collections import OrderedDict, namedtuple from Common.DataType import * -import collections ## PcdClassObject # @@ -165,17 +165,17 @@ class StructurePcd(PcdClassObject): self.StructuredPcdIncludeFile = [] if StructuredPcdIncludeFile is None else StructuredPcdIncludeFile self.PackageDecs = Packages self.DefaultStoreName = [default_store] - self.DefaultValues = collections.OrderedDict() + self.DefaultValues = OrderedDict() self.PcdMode = None - self.SkuOverrideValues = collections.OrderedDict() + self.SkuOverrideValues = OrderedDict() self.FlexibleFieldName = None self.StructName = None self.PcdDefineLineNo = 0 self.PkgPath = "" self.DefaultValueFromDec = "" self.ValueChain = set() - self.PcdFieldValueFromComm = collections.OrderedDict() - self.PcdFieldValueFromFdf = collections.OrderedDict() + self.PcdFieldValueFromComm = OrderedDict() + self.PcdFieldValueFromFdf = OrderedDict() def __repr__(self): return self.TypeName @@ -189,9 +189,9 @@ class StructurePcd(PcdClassObject): self.DefaultValueFromDec = DefaultValue def AddOverrideValue (self, FieldName, Value, SkuName, DefaultStoreName, FileName="", LineNo=0): if SkuName not in self.SkuOverrideValues: - self.SkuOverrideValues[SkuName] = collections.OrderedDict() + self.SkuOverrideValues[SkuName] = OrderedDict() if DefaultStoreName not in self.SkuOverrideValues[SkuName]: - self.SkuOverrideValues[SkuName][DefaultStoreName] = collections.OrderedDict() + self.SkuOverrideValues[SkuName][DefaultStoreName] = OrderedDict() if FieldName in self.SkuOverrideValues[SkuName][DefaultStoreName]: del self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] self.SkuOverrideValues[SkuName][DefaultStoreName][FieldName] = [Value.strip(), FileName, LineNo] @@ -241,21 +241,7 @@ class StructurePcd(PcdClassObject): self.PcdFieldValueFromComm = PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm else self.PcdFieldValueFromComm self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf -## LibraryClassObject -# -# This Class defines LibraryClassObject used in BuildDatabase -# -# @param object: Inherited from object class -# @param Name: Input value for LibraryClassName, default is None -# @param SupModList: Input value for SupModList, default is [] -# -# @var LibraryClass: To store value for LibraryClass -# @var SupModList: To store value for SupModList -# -class LibraryClassObject(object): - def __init__(self, Name = None, SupModList = []): - self.LibraryClass = Name - self.SupModList = SupModList +LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModList'], verbose=False) ## ModuleBuildClassObject # @@ -323,7 +309,7 @@ class ModuleBuildClassObject(object): self.Binaries = [] self.Sources = [] - self.LibraryClasses = collections.OrderedDict() + self.LibraryClasses = OrderedDict() self.Libraries = [] self.Protocols = [] self.Ppis = [] -- 2.16.2.windows.1