From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 85F7D21127CB6 for ; Mon, 10 Sep 2018 15:18:14 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2018 15:18:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,357,1531810800"; d="scan'208";a="72138375" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga008.jf.intel.com with ESMTP; 10 Sep 2018 15:18:12 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Liming Gao , Yonghong Zhu Date: Mon, 10 Sep 2018 15:18:06 -0700 Message-Id: <62c9f6520a9540ff8042dbbc550de4821ae35884.1536175711.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 v2 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: Mon, 10 Sep 2018 22:18:14 -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