From 7e2ccccace24636f29ddc210b94606abd4c7e42b Mon Sep 17 00:00:00 2001 From: kx Date: Tue, 4 Jun 2024 06:43:08 +0300 Subject: Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305b --- .../Python/Workspace/MetaFileCommentParser.py | 90 +++++++++++----------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/MetaFileCommentParser.py') diff --git a/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py b/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py index 3737ae3511..333d56f3d7 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileCommentParser.py @@ -1,45 +1,45 @@ -## @file -# This file is used to check format of comments -# -# Copyright (c) 2012, Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: BSD-2-Clause-Patent -# - -from CommonDataClass.DataClass import ( - MODEL_PCD_PATCHABLE_IN_MODULE, - MODEL_PCD_DYNAMIC_EX, - MODEL_PCD_DYNAMIC, - MODEL_EFI_GUID, - MODEL_EFI_PPI, - MODEL_EFI_PROTOCOL -) -from Common.BuildToolError import FORMAT_INVALID -import Common.EdkLogger as EdkLogger - -UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES", - "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED", - "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES") -ErrorMsgMap = { - MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s", - MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.", - MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.", - MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s." -} - -def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList): - if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]: - CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC]) - elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]: - CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) - elif SectionType == MODEL_EFI_PROTOCOL: - CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) - -def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg): - for Comment in Comments: - for Word in Comment[0].replace('#', ' ').split(): - if Word in Usages: - return - EdkLogger.error( - "Parser", FORMAT_INVALID, - ErrorMsg % (InfFile, LineNo, Value) - ) +## @file +# This file is used to check format of comments +# +# Copyright (c) 2012, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +from CommonDataClass.DataClass import ( + MODEL_PCD_PATCHABLE_IN_MODULE, + MODEL_PCD_DYNAMIC_EX, + MODEL_PCD_DYNAMIC, + MODEL_EFI_GUID, + MODEL_EFI_PPI, + MODEL_EFI_PROTOCOL +) +from Common.BuildToolError import FORMAT_INVALID +import Common.EdkLogger as EdkLogger + +UsageList = ("PRODUCES", "PRODUCED", "ALWAYS_PRODUCES", "ALWAYS_PRODUCED", "SOMETIMES_PRODUCES", + "SOMETIMES_PRODUCED", "CONSUMES", "CONSUMED", "ALWAYS_CONSUMES", "ALWAYS_CONSUMED", + "SOMETIMES_CONSUMES", "SOMETIMES_CONSUMED", "SOMETIME_CONSUMES") +ErrorMsgMap = { + MODEL_EFI_GUID : "The usage for this GUID is not listed in this INF: %s[%d]:%s", + MODEL_EFI_PPI : "The usage for this PPI is not listed in this INF: %s[%d]:%s.", + MODEL_EFI_PROTOCOL : "The usage for this Protocol is not listed in this INF: %s[%d]:%s.", + MODEL_PCD_DYNAMIC : "The usage for this PCD is not listed in this INF: %s[%d]:%s." +} + +def CheckInfComment(SectionType, Comments, InfFile, LineNo, ValueList): + if SectionType in [MODEL_PCD_PATCHABLE_IN_MODULE, MODEL_PCD_DYNAMIC_EX, MODEL_PCD_DYNAMIC]: + CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0]+'.'+ValueList[1], ErrorMsgMap[MODEL_PCD_DYNAMIC]) + elif SectionType in [MODEL_EFI_GUID, MODEL_EFI_PPI]: + CheckUsage(Comments, UsageList, InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) + elif SectionType == MODEL_EFI_PROTOCOL: + CheckUsage(Comments, UsageList + ("TO_START", "BY_START"), InfFile, LineNo, ValueList[0], ErrorMsgMap[SectionType]) + +def CheckUsage(Comments, Usages, InfFile, LineNo, Value, ErrorMsg): + for Comment in Comments: + for Word in Comment[0].replace('#', ' ').split(): + if Word in Usages: + return + EdkLogger.error( + "Parser", FORMAT_INVALID, + ErrorMsg % (InfFile, LineNo, Value) + ) -- cgit v1.2.3